1# This test runs logstash and checks if messages flows and 2# elasticsearch is started. 3 4import ./make-test.nix ({ pkgs, ...} : { 5 name = "logstash"; 6 meta = with pkgs.stdenv.lib.maintainers; { 7 maintainers = [ eelco chaoflow offline ]; 8 }; 9 10 nodes = { 11 one = 12 { config, pkgs, ... }: 13 { 14 services = { 15 logstash = { 16 enable = true; 17 inputConfig = '' 18 exec { command => "echo flowers" interval => 1 type => "test" } 19 exec { command => "echo dragons" interval => 1 type => "test" } 20 ''; 21 filterConfig = '' 22 if [message] =~ /dragons/ { 23 drop {} 24 } 25 ''; 26 outputConfig = '' 27 stdout { codec => rubydebug } 28 elasticsearch { embedded => true } 29 ''; 30 }; 31 }; 32 }; 33 }; 34 35 testScript = '' 36 startAll; 37 38 $one->waitForUnit("logstash.service"); 39 $one->waitUntilSucceeds("journalctl -n 20 _SYSTEMD_UNIT=logstash.service | grep flowers"); 40 $one->fail("journalctl -n 20 _SYSTEMD_UNIT=logstash.service | grep dragons"); 41 $one->waitUntilSucceeds("curl -s http://127.0.0.1:9200/_status?pretty=true | grep logstash"); 42 ''; 43})