nixos/telegraf: add test

This commit is contained in:
Jörg Thalheim 2019-01-21 11:30:11 +00:00
parent 777b0f89fd
commit ecd1129dee
No known key found for this signature in database
GPG Key ID: CA4106B8D7CC79FA
2 changed files with 31 additions and 0 deletions

View File

@ -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 {};

30
nixos/tests/telegraf.nix Normal file
View File

@ -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");
'';
})