Fast, end-to-end, repeatable testing for entire Riemann configs. Provides a
tap
macro which taps the event stream and (in testing mode) records all
events that flow through that stream. Provides a variant of deftest that
initiates controlled time and sets up a fresh result set for taps, and a
function inject!
to apply events to streams and see what each tap
received.
Fast, end-to-end, repeatable testing for entire Riemann configs. Provides a `tap` macro which taps the event stream and (in testing mode) records all events that flow through that stream. Provides a variant of deftest that initiates controlled time and sets up a fresh result set for taps, and a function `inject!` to apply events to streams and see what each tap received.
A map of tap names to atoms of vectors of captured events.
A map of tap names to atoms of vectors of captured events.
An atom to a map of tap names to information about the taps; e.g. file and line number, for preventing collisions.
An atom to a map of tap names to information about the taps; e.g. file and line number, for preventing collisions.
(deftest name & body)
Like clojure.test deftest, but establishes a fresh time context and a fresh set of tap results for the duration of the body.
(deftest my-tap
(let [rs (test/inject! [{:time 2 :service "bar"}])]
(is (= 1 (count (:some-tap rs))))))
Like clojure.test deftest, but establishes a fresh time context and a fresh set of tap results for the duration of the body. ```clojure (deftest my-tap (let [rs (test/inject! [{:time 2 :service "bar"}])] (is (= 1 (count (:some-tap rs)))))) ```
(fresh-results taps)
Given a map of tap-names to _, builds a map of tap names to atoms of empty vectors, ready to receive events.
Given a map of tap-names to _, builds a map of tap names to atoms of empty vectors, ready to receive events.
(inject! events)
(inject! streams events)
Takes a sequence of streams, initiates controlled time and resets the scheduler, applies a sequence of events to those streams, and returns a map of tap names to the events each tap received. Absolutely NOT threadsafe; riemann.time.controlled is global. Streams may be omitted, in which case inject! applies events to the streams dynamic var.
Takes a sequence of streams, initiates controlled time and resets the scheduler, applies a sequence of events to those streams, and returns a map of tap names to the events each tap received. Absolutely NOT threadsafe; riemann.time.controlled is global. Streams may be omitted, in which case inject! applies events to the *streams* dynamic var.
(io & children)
A stream which suppresses side effects in test mode. When testing is true at compile time, returns a function that discards any incoming events. When testing is false, compiles to (sdo child1 child2 ...).
(io
(fn [e]
(http/put "http://my.service/callback", {:body (event->json e)})))
A stream which suppresses side effects in test mode. When *testing* is true at compile time, returns a function that discards any incoming events. When *testing* is false, compiles to (sdo child1 child2 ...). ```clojure (io (fn [e] (http/put "http://my.service/callback", {:body (event->json e)}))) ```
(lookup events host service)
Lookup an event by host/service in a vector of tapped events returned by inject!. If several matching events have passed through the tap, the last one will be returned.
Lookup an event by host/service in a vector of tapped events returned by inject!. If several matching events have passed through the tap, the last one will be returned.
(run-stream stream inputs)
Applies inputs to stream, and returns outputs.
Applies inputs to stream, and returns outputs.
(run-stream-intervals stream inputs-and-intervals)
Applies a seq of alternating events and intervals (in seconds) between them to stream, returning outputs.
Applies a seq of alternating events and intervals (in seconds) between them to stream, returning outputs.
(tap name & children)
A stream which records inbound events in the results map. Takes a globally unique name which identifies that tap in results.
When testing is false (at compile time!), tap has no effect; it compiles directly into (sdo child-streams).
When testing is true at compile time, tap records any events that arrive in the results map, and passes those events on to its children.
(rate 5 (tap :graph prod-graph-stream))
A stream which records inbound events in the *results* map. Takes a globally unique name which identifies that tap in *results*. When *testing* is false (at compile time!), tap has no effect; it compiles directly into (sdo child-streams). When *testing* is true at compile time, tap records any events that arrive in the results map, and passes those events on to its children. (rate 5 (tap :graph prod-graph-stream))
(tap-stream name child)
Called by tap
to construct a stream which records events in results
before forwarding to child.
Called by `tap` to construct a stream which records events in *results* before forwarding to child.
(test-stream stream inputs outputs)
Verifies that the given stream, taking inputs, forwards outputs to children.
Verifies that the given stream, taking inputs, forwards outputs to children.
(test-stream-intervals stream inputs-and-intervals outputs)
Verifies that run-stream-intervals, taking inputs/intervals, forwards outputs to children.
Verifies that run-stream-intervals, taking inputs/intervals, forwards outputs to children.
(tests & body)
Declares a new namespace named [ns]-test, requires some clojure.test and riemann.test helpers, and evaluates body in the context of that namespace. Restores the original namespace afterwards.
Declares a new namespace named [ns]-test, requires some clojure.test and riemann.test helpers, and evaluates body in the context of that namespace. Restores the original namespace afterwards.
(with-test-env & body)
Prepares a fresh set of taps, binds testing to true, initiates controlled time and resets the schedulerand runs body in an implicit do. Wrap your entire test suite (including defining the streams themselves) in this macro. Note that you'll have to use (eval) or (load-file), etc, in order for this to work because the binding takes effect at run time, not compile time--so make your compile time run time and wow this gets confusing.
(with-test-env
(eval '(let [s (tap :foo prn)]
(run-test! [s] [:hi]))))
prints :hi, and returns {:foo [:hi]}
Prepares a fresh set of taps, binds *testing* to true, initiates controlled time and resets the schedulerand runs body in an implicit do. Wrap your entire test suite (including defining the streams themselves) in this macro. Note that you'll have to use (eval) or (load-file), etc, in order for this to work because the binding takes effect at *run time*, not *compile time*--so make your compile time run time and wow this gets confusing. ```clojure (with-test-env (eval '(let [s (tap :foo prn)] (run-test! [s] [:hi])))) ``` prints :hi, and returns {:foo [:hi]}
(with-test-stream sym stream inputs outputs)
Exposes a fake index, verifies that the given stream, taking inputs, forwards outputs to children
Exposes a fake index, verifies that the given stream, taking inputs, forwards outputs to children
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close