Katja Echo is a test library tool that helps performing tests on these specific use cases:
- Testing riemann client implementations: instead of starting and running the riemann.io server, one can use Katja Echo that will listen and interact with the any riemann.io client faking the riemann.io server behaviour
- If an application uses riemann.io, Katja Echo allows you to run tests without defining special configurations to start the riemann.io before running any test. In other words, you don't need to start a riemann.io server
- During specific tests (like: load, performance or integration), Katja Echo can be used to track the values sended. Later, use Riemann queries (or calling Katja Echo APIs) to inspect the values.
Besides the above listed itens, riemann.io implements a simple protocol and query parsing which are good exercises as well suitable to use Erlang.
This project has an aim to help testing and not intends to be a full Riemann implementation.
This project uses rebar3 as main build tool.
-
Compile:
$ rebar3 compile
-
Running tests:
$ rebar3 as test check
Add katja_echo
as an application dependency (use test profile if needed):
{deps, [
{katja_echo, "0.1.0"}
]}.
The following configuration is assumed as default values:
[
{katja_echo, [
{port, 5555},
{pool, []},
{callback, katja_echo_user}
]}
].
When testing, a typical test case looks like this:
Fun = fun (_Event) -> ok end,
{ok, Pid} = katja_echo:start_link(),
% sending riemann events using any client
% call katja_echo query. Or call the riemann client query function
Events = katja_echo:query(Fun, "service = \"my service\"").
Katja Echo can receive and send messages using Riemann Protocol Buffer.
Also query message was based on Riemann Query and the respective tests implementation.
The grammar was implemented based on Riemann antlr grammar.
The following links are great source of knowledge about how to write a scanner and parer using yecc/leex:
- yecc
- leex
- Tokenizing and parsing in Elixir with yecc and leex
- Internationalization and localization support for Elixir
- Leex And Yecc
- A simple example of how to use Leex and Yecc
- HTML parsing in Elixir with leex and yecc
- How to use leex and yecc in Elixir
- Writing a lexer and parser
- Parsing with leex and yecc
- Simple project to play with leex and yecc.
MIT.