|
113 | 113 | :throw-exceptions false})] |
114 | 114 | (:status response) => 503))) |
115 | 115 |
|
116 | | -(fact "errors will not cause circuit to break if bad-request-pred is true, with :throw-exceptions false" |
| 116 | +(fact "errors will not cause circuit to break if client-error? is true, with :throw-exceptions false" |
117 | 117 | (rest-driven |
118 | 118 | [{:method :GET |
119 | 119 | :url "/"} |
|
125 | 125 | (let [command-key (keyword (str (UUID/randomUUID)))] |
126 | 126 | (dotimes [_ 30] |
127 | 127 | (http/get url {:throw-exceptions false |
128 | | - :hystrix/command-key command-key |
129 | | - :hystrix/bad-request-pred client-error?}) => (contains {:status 400})) |
| 128 | + :hystrix/command-key command-key}) => (contains {:status 400})) |
130 | 129 | (Thread/sleep 600) ;sleep to wait for Hystrix health snapshot |
131 | 130 | (http/get url {:throw-exceptions false |
132 | 131 | :hystrix/command-key command-key}) => (contains {:status 200})))) |
133 | 132 |
|
134 | | -(fact "errors will not cause circuit to break if bad-request-pred is true, with :throw-exceptions true" |
| 133 | +(fact "errors will not cause circuit to break if client-error? is true, with :throw-exceptions true" |
135 | 134 | (rest-driven |
136 | 135 | [{:method :GET |
137 | 136 | :url "/"} |
|
143 | 142 | (let [command-key (keyword (str (UUID/randomUUID)))] |
144 | 143 | (dotimes [_ 30] |
145 | 144 | (http/get url {:throw-exceptions true |
146 | | - :hystrix/command-key command-key |
147 | | - :hystrix/bad-request-pred client-error?}) => (throws ExceptionInfo)) |
| 145 | + :hystrix/command-key command-key}) => (throws ExceptionInfo)) |
148 | 146 | (Thread/sleep 600) ;sleep to wait for Hystrix health snapshot |
149 | 147 | (http/get url {:throw-exceptions false |
150 | 148 | :hystrix/command-key command-key}) => (contains {:status 200})))) |
151 | 149 |
|
152 | | -(fact "errors will cause circuit to break if bad-request-pred is false" |
153 | | - (rest-driven |
154 | | - [{:method :GET |
155 | | - :url "/"} |
156 | | - {:status 400 |
157 | | - :times 30}] |
158 | | - (let [command-key (keyword (str (UUID/randomUUID)))] |
159 | | - (dotimes [_ 30] |
160 | | - (http/get url {:throw-exceptions false |
161 | | - :hystrix/command-key command-key |
162 | | - :hystrix/bad-request-pred (constantly false)}) => (contains {:status 400})) |
163 | | - (Thread/sleep 600) ;sleep to wait for Hystrix health snapshot |
164 | | - (http/get url {:throw-exceptions false |
165 | | - :hystrix/command-key command-key}) => (contains {:status 503})))) |
166 | | - |
167 | 150 | (fact "status-codes predicate matches only given status codes" |
168 | 151 | (let [predicate (status-codes 100 200 300)] |
169 | 152 | (predicate {} {:status 100}) => true |
|
197 | 180 |
|
198 | 181 | (fact "add-hook with user-defaults will override base configuration, but not call configuration" |
199 | 182 | (rest-driven |
200 | | - [{:method :GET |
201 | | - :url "/"} |
202 | | - {:status 500 |
203 | | - :times 3}] |
204 | | - (make-hystrix-call {}) |
205 | | - => (throws clojure.lang.ExceptionInfo "clj-http: status 500") |
| 183 | + [{:method :GET |
| 184 | + :url "/"} |
| 185 | + {:status 500 |
| 186 | + :times 3}] |
| 187 | + (make-hystrix-call {}) |
| 188 | + => (throws clojure.lang.ExceptionInfo "clj-http: status 500") |
206 | 189 | ;set custom default for fallback-fn |
207 | | - (remove-hook) |
208 | | - (add-hook {:hystrix/fallback-fn (constantly "bar")}) |
209 | | - (make-hystrix-call {}) => "bar" |
210 | | - (make-hystrix-call {:hystrix/fallback-fn (constantly "baz")}) => "baz") |
| 190 | + (remove-hook) |
| 191 | + (add-hook {:hystrix/fallback-fn (constantly "bar")}) |
| 192 | + (make-hystrix-call {}) => "bar" |
| 193 | + (make-hystrix-call {:hystrix/fallback-fn (constantly "baz")}) => "baz") |
211 | 194 | (remove-hook) |
212 | 195 | (add-hook)) |
213 | 196 |
|
|
216 | 199 | ;verify hystrix is enabled by exceeding the default timeout (1000 ms) |
217 | 200 | (http/with-additional-middleware [wrap-hystrix] |
218 | 201 | (rest-driven |
219 | | - [{:method :GET |
220 | | - :url "/"} |
221 | | - {:status 200 |
222 | | - :after 1500}] |
223 | | - (make-hystrix-call {}) |
224 | | - => (throws clojure.lang.ExceptionInfo "clj-http: status 503"))) |
| 202 | + [{:method :GET |
| 203 | + :url "/"} |
| 204 | + {:status 200 |
| 205 | + :after 1500}] |
| 206 | + (make-hystrix-call {}) |
| 207 | + => (throws clojure.lang.ExceptionInfo "clj-http: status 503"))) |
225 | 208 |
|
226 | 209 | ;verify custom defaults are supported |
227 | 210 | (http/with-additional-middleware |
228 | 211 | [(partial wrap-hystrix {:hystrix/fallback-fn (constantly {:status 404})})] |
229 | 212 | (rest-driven |
230 | | - [{:method :GET |
231 | | - :url "/"} |
232 | | - {:status 500}] |
233 | | - (make-hystrix-call {}) |
234 | | - => (throws clojure.lang.ExceptionInfo "clj-http: status 404")))) |
| 213 | + [{:method :GET |
| 214 | + :url "/"} |
| 215 | + {:status 500}] |
| 216 | + (make-hystrix-call {}) |
| 217 | + => (throws clojure.lang.ExceptionInfo "clj-http: status 404")))) |
0 commit comments