Checks that a config source, selector or recorder behaves the way the server expects.
Each check takes a plug-in and returns a promise of
{:pass? true|false
:failures [{:reason :keyword :message "..."} ...]}
The checks don't call is themselves, so you can use them from
clojure.test, cljs.test, nbb or any other runner:
(deftest my-recorder-meets-the-contract
(let [{:keys [pass? failures]} @(test-kit/check-recorder my-recorder)]
(is pass? (pr-str failures))))
On ClojureScript, wait on the promise with your runner's async support instead of deref.
Checks that a config source, selector or recorder behaves the way the
server expects.
Each check takes a plug-in and returns a promise of
{:pass? true|false
:failures [{:reason :keyword :message "..."} ...]}
The checks don't call `is` themselves, so you can use them from
clojure.test, cljs.test, nbb or any other runner:
(deftest my-recorder-meets-the-contract
(let [{:keys [pass? failures]} @(test-kit/check-recorder my-recorder)]
(is pass? (pr-str failures))))
On ClojureScript, wait on the promise with your runner's async support
instead of deref.(check-config-source source)(check-config-source source
{:keys [timeout-ms calls] :or {timeout-ms 5000 calls 3}})Calls a config source :calls times (default 3) and checks each result.
Every call has to finish within :timeout-ms (default 5,000). Returning a
map of valid experiment configs passes, and so does throwing or rejecting,
since the server handles that by keeping its last good configs. Returning
anything else fails.
Reasons: :hangs, :not-a-map, :invalid-experiment.
Calls a config source `:calls` times (default 3) and checks each result. Every call has to finish within `:timeout-ms` (default 5,000). Returning a map of valid experiment configs passes, and so does throwing or rejecting, since the server handles that by keeping its last good configs. Returning anything else fails. Reasons: `:hangs`, `:not-a-map`, `:invalid-experiment`.
(check-recorder recorder)(check-recorder recorder
{:keys [timeout-ms concurrency read-back]
:or {timeout-ms 5000 concurrency 50}})Sends a recorder one of each kind of exposure and feedback record, then
:concurrency (default 50) records at once, and checks that no call throws,
rejects or takes longer than :timeout-ms.
If you pass :read-back, a function that returns (or returns a promise of)
everything the recorder has stored, the check also confirms that every
record arrived.
Reasons: :throws, :hangs, :concurrent-failure, :missing-records.
Sends a recorder one of each kind of exposure and feedback record, then `:concurrency` (default 50) records at once, and checks that no call throws, rejects or takes longer than `:timeout-ms`. If you pass `:read-back`, a function that returns (or returns a promise of) everything the recorder has stored, the check also confirms that every record arrived. Reasons: `:throws`, `:hangs`, `:concurrent-failure`, `:missing-records`.
(check-selector selector)(check-selector selector
{:keys [timeout-ms repeats] :or {timeout-ms 5000 repeats 5}})Calls a selector with a range of valid requests (different weights, sticky keys and supported arms) and checks what it returns.
The selector fails the check if it throws or doesn't answer within
:timeout-ms. It also fails if it picks an arm other than :default that
isn't in the config, or that the client didn't list as supported. Each
request is sent :repeats times (default 5), and for hashed requests
with a sticky key the selector has to give the same answer every time.
Reasons: :throws, :hangs, :unconfigured-arm, :unsupported-arm,
:unstable.
Calls a selector with a range of valid requests (different weights, sticky keys and supported arms) and checks what it returns. The selector fails the check if it throws or doesn't answer within `:timeout-ms`. It also fails if it picks an arm other than `:default` that isn't in the config, or that the client didn't list as supported. Each request is sent `:repeats` times (default 5), and for `hashed` requests with a sticky key the selector has to give the same answer every time. Reasons: `:throws`, `:hangs`, `:unconfigured-arm`, `:unsupported-arm`, `:unstable`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |