From ecd1129dee9add903e3fdc50fb208374c1434e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 21 Jan 2019 11:30:11 +0000 Subject: [PATCH] nixos/telegraf: add test --- nixos/tests/all-tests.nix | 1 + nixos/tests/telegraf.nix | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 nixos/tests/telegraf.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 9ee8ac2995be..8c2df2435a79 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -200,6 +200,7 @@ in syncthing-relay = handleTest ./syncthing-relay.nix {}; systemd = handleTest ./systemd.nix {}; taskserver = handleTest ./taskserver.nix {}; + telegraf = handleTest ./telegraf.nix {}; tomcat = handleTest ./tomcat.nix {}; tor = handleTest ./tor.nix {}; transmission = handleTest ./transmission.nix {}; diff --git a/nixos/tests/telegraf.nix b/nixos/tests/telegraf.nix new file mode 100644 index 000000000000..6776f8d8c37f --- /dev/null +++ b/nixos/tests/telegraf.nix @@ -0,0 +1,30 @@ +import ./make-test.nix ({ pkgs, ...} : { + name = "telegraf"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ mic92 ]; + }; + + machine = { ... }: { + services.telegraf.enable = true; + services.telegraf.extraConfig = { + agent.interval = "1s"; + agent.flush_interval = "1s"; + inputs.exec = { + commands = [ + "${pkgs.runtimeShell} -c 'echo example,tag=a i=42i'" + ]; + timeout = "5s"; + data_format = "influx"; + }; + outputs.file.files = ["/tmp/metrics.out"]; + outputs.file.data_format = "influx"; + }; + }; + + testScript = '' + startAll; + + $machine->waitForUnit("telegraf.service"); + $machine->waitUntilSucceeds("grep -q example /tmp/metrics.out"); + ''; +})