diff options
author | WilliButz <wbutz@cyberfnord.de> | 2019-06-27 18:11:09 +0200 |
---|---|---|
committer | WilliButz <wbutz@cyberfnord.de> | 2019-07-08 16:10:00 +0200 |
commit | d90242029047942bd159242417f2fda03c795582 (patch) | |
tree | 09ee18dc31b114407ade251baf39f31964d54339 /nixos/tests/loki.nix | |
parent | 3f598c0faaf2d0e113654d69809f93a8fd729bec (diff) |
nixos/tests: add test for loki
Diffstat (limited to 'nixos/tests/loki.nix')
-rw-r--r-- | nixos/tests/loki.nix | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/nixos/tests/loki.nix b/nixos/tests/loki.nix new file mode 100644 index 000000000000..9c3058d02f84 --- /dev/null +++ b/nixos/tests/loki.nix @@ -0,0 +1,37 @@ +import ./make-test.nix ({ lib, pkgs, ... }: + +{ + name = "loki"; + + meta = with lib.maintainers; { + maintainers = [ willibutz ]; + }; + + machine = { ... }: { + services.loki = { + enable = true; + configFile = "${pkgs.grafana-loki.src}/cmd/loki/loki-local-config.yaml"; + }; + systemd.services.promtail = { + description = "Promtail service for Loki test"; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ExecStart = '' + ${pkgs.grafana-loki}/bin/promtail --config.file ${pkgs.grafana-loki.src}/cmd/promtail/promtail-local-config.yaml + ''; + DynamicUser = true; + }; + }; + }; + + testScript = '' + $machine->start; + $machine->waitForUnit("loki.service"); + $machine->waitForUnit("promtail.service"); + $machine->waitForOpenPort(3100); + $machine->waitForOpenPort(9080); + $machine->succeed("echo 'Loki Ingestion Test' > /var/log/testlog"); + $machine->waitUntilSucceeds("${pkgs.grafana-loki}/bin/logcli --addr='http://localhost:3100' query --no-labels '{job=\"varlogs\",filename=\"/var/log/testlog\"}' | grep -q 'Loki Ingestion Test'"); + ''; +}) |