mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 15:11:25 +00:00
nixos/logstash: add test
This commit is contained in:
parent
1453be4740
commit
8b1ab6d912
@ -16,6 +16,7 @@ with import ../lib/testing.nix { inherit system minimal; };
|
||||
kde4 = makeTest (import ./kde4.nix);
|
||||
#kexec = makeTest (import ./kexec.nix);
|
||||
login = makeTest (import ./login.nix {});
|
||||
logstash = makeTest (import ./logstash.nix);
|
||||
latestKernel.login = makeTest (import ./login.nix ({ config, pkgs, ... }: { boot.kernelPackages = pkgs.linuxPackages_latest; }));
|
||||
misc = makeTest (import ./misc.nix);
|
||||
#mpich = makeTest (import ./mpich.nix);
|
||||
|
40
nixos/tests/logstash.nix
Normal file
40
nixos/tests/logstash.nix
Normal file
@ -0,0 +1,40 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
# This test runs logstash and checks if messages flows and elasticsearch is
|
||||
# started
|
||||
|
||||
{
|
||||
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");
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user