A tool to test Riemann (the event stream processor) from the outside.
##Why did you build this?
Partly because I struggled with testing index search based logic using the built in testing functionality. And partly because my ruby foo is stronger so I hit it with my preferred hammer.
-
Make sure riemann is on your PATH.
export PATH:$PATH:/path/to/riemann/bin
-
Make sure you've got ruby at the right version with the appropriate gems installed.
-
Run
rspec --format doc riemann_spec.rb
Just some helper code to make testing Riemann as a black box easier.
This includes:
-
Some helper code that's called in the
before(:all)
block it will start up riemann with your config. This is all contained inriemann_runner.rb
. -
Some code to pretend to be a logstash server (since this is what I'll be sending some events to). This too is started in the
before(:all)
block. The code for this is infake_logstash.rb
. It starts a multithreaded socket server and parses all lines to it as JSON and pops them in an array. In the 'before(:each)` block we reset that array to make sure the tests are as isolated as possible. -
At the end in the
after(:all)
block we stop riemann.
Tests do one of two things:
-
Send events to Riemann and then check the index to see if the index is in the expected state.
-
Send events to Riemann and then check the events received by the fake logstash server to see if Riemann emitted the events we expected.
- Liberal use of
sleep(x)
seems smelly. - Tests don't reset the index so you have to be careful since the state of Riemann's index may impact later tests.
- I'm sure it could be much tidier.
- It could be a gem.
##What next?
Dunno. Shout if you have ideas. Make PRs if you have written code that would help make this better. Tell me why this is a terrible way of doing it. All input welcome.