summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJaka Hudoklin <jakahudoklin@gmail.com>2013-11-01 14:09:17 +0100
committerJaka Hudoklin <jakahudoklin@gmail.com>2013-11-01 17:18:57 +0100
commit8b1ab6d912b690329cff8a6ef0da2559488aeede (patch)
tree6d5c391a8913c4119939ba94fef13d9dca94e4de /nixos
parent1453be4740f9735a2a66480a68f3648cab7684d2 (diff)
downloadnixpkgs-8b1ab6d912b690329cff8a6ef0da2559488aeede.tar
nixpkgs-8b1ab6d912b690329cff8a6ef0da2559488aeede.tar.gz
nixpkgs-8b1ab6d912b690329cff8a6ef0da2559488aeede.tar.bz2
nixpkgs-8b1ab6d912b690329cff8a6ef0da2559488aeede.tar.lz
nixpkgs-8b1ab6d912b690329cff8a6ef0da2559488aeede.tar.xz
nixpkgs-8b1ab6d912b690329cff8a6ef0da2559488aeede.tar.zst
nixpkgs-8b1ab6d912b690329cff8a6ef0da2559488aeede.zip
nixos/logstash: add test
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/default.nix1
-rw-r--r--nixos/tests/logstash.nix40
2 files changed, 41 insertions, 0 deletions
diff --git a/nixos/tests/default.nix b/nixos/tests/default.nix
index ce5776c8e46..574e1dd2f8b 100644
--- a/nixos/tests/default.nix
+++ b/nixos/tests/default.nix
@@ -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);
diff --git a/nixos/tests/logstash.nix b/nixos/tests/logstash.nix
new file mode 100644
index 00000000000..ee309d39f87
--- /dev/null
+++ b/nixos/tests/logstash.nix
@@ -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");
+  '';
+}