mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
41 lines
1.2 KiB
Nix
41 lines
1.2 KiB
Nix
# This test runs logstash and checks if messages flows and
|
|
# elasticsearch is started.
|
|
|
|
import ./make-test.nix {
|
|
name = "logstash";
|
|
|
|
nodes = {
|
|
one =
|
|
{ config, pkgs, ... }:
|
|
{
|
|
services = {
|
|
logstash = {
|
|
enable = true;
|
|
inputConfig = ''
|
|
exec { command => "echo flowers" interval => 1 type => "test" }
|
|
exec { command => "echo dragons" interval => 1 type => "test" }
|
|
'';
|
|
filterConfig = ''
|
|
if [type] == "test" {
|
|
grep { match => ["message", "flowers"] drop => true }
|
|
}
|
|
'';
|
|
outputConfig = ''
|
|
stdout { codec => rubydebug }
|
|
elasticsearch { embedded => true }
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
startAll;
|
|
|
|
$one->waitForUnit("logstash.service");
|
|
$one->waitUntilSucceeds("journalctl -n 20 _SYSTEMD_UNIT=logstash.service | grep flowers");
|
|
$one->fail("journalctl -n 20 _SYSTEMD_UNIT=logstash.service | grep dragons");
|
|
$one->waitUntilSucceeds("curl -s http://127.0.0.1:9200/_status?pretty=true | grep logstash");
|
|
'';
|
|
}
|