Skip to content

Instantly share code, notes, and snippets.

@pharaujo
Last active August 29, 2015 14:25
Show Gist options
  • Save pharaujo/b94ecde0d1831335b7be to your computer and use it in GitHub Desktop.
Save pharaujo/b94ecde0d1831335b7be to your computer and use it in GitHub Desktop.
riemann: simple config with test
; -*- mode: clojure; -*-
; vim: filetype=clojure
(logging/init {:file "riemann.log" :console false})
; Listen on the local interface over TCP (5555) and UDP (5555)
; needs `io` to prevent side-effects in testing
(io
(let [host "127.0.0.1"]
(tcp-server {:host host})
(udp-server {:host host})))
; Expire old events from the index every 5 seconds.
(periodically-expire 5)
(let [index (default :ttl 30 (tap :test-index (index)))]
(streams
(where (service "service-to-index") index)))
(tests
(deftest index-test
(let [events [ {:service "service-to-index" :host "host1" :metric 1}
{:service "service-to-something" :host "host2" :metric 2} ]
expect [ {:service "service-to-index" :host "host1" :metric 1 :ttl 30} ]
index (:test-index (inject! events))]
(is (= index expect))
(riemann.test/test-stream (match :service "service-to-index") index expect))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment