mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
abe218950c
You can now run a test in the nixos/tests directory directly using nix-build, e.g. $ nix-build '<nixos/tests/login.nix>' -A test This gets rid of having to add the test to nixos/tests/default.nix. (Of course, you still need to add it to nixos/release.nix if you want Hydra to run the test.)
40 lines
1.2 KiB
Nix
40 lines
1.2 KiB
Nix
# This test runs logstash and checks if messages flows and
|
|
# elasticsearch is started.
|
|
|
|
import ./make-test.nix {
|
|
|
|
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");
|
|
'';
|
|
}
|