Liking cljdoc? Tell your friends :D

riemann.test

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.
raw docstring

*core*clj

The core used in test mode

The core used in test mode
sourceraw docstring

*results*clj

A map of tap names to atoms of vectors of captured events.

A map of tap names to atoms of vectors of captured events.
sourceraw docstring

*taps*clj

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.
sourceraw docstring

*testing*clj

Are we currently in test mode?

Are we currently in test mode?
sourceraw docstring

deftestcljmacro

(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))))))
```
sourceraw docstring

fresh-resultsclj

(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.
sourceraw docstring

inject!clj

(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.
sourceraw docstring

iocljmacro

(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)})))
```
sourceraw docstring

lookupclj

(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.
sourceraw docstring

run-streamcljmacro

(run-stream stream inputs)

Applies inputs to stream, and returns outputs.

Applies inputs to stream, and returns outputs.
sourceraw docstring

run-stream-intervalscljmacro

(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.
sourceraw docstring

tapcljmacro

(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))
sourceraw docstring

tap-streamclj

(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.
sourceraw docstring

test-streamcljmacro

(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.
sourceraw docstring

test-stream-intervalscljmacro

(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.
sourceraw docstring

testscljmacro

(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.
sourceraw docstring

with-test-envcljmacro

(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]}
sourceraw docstring

with-test-streamcljmacro

(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
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close