nixos/tests: add test for loki

This commit is contained in:
WilliButz 2019-06-27 18:11:09 +02:00
parent 3f598c0faa
commit d902420290
No known key found for this signature in database
GPG key ID: 92582A10F1179CB2
2 changed files with 38 additions and 0 deletions

View file

@ -139,6 +139,7 @@ in
#lightdm = handleTest ./lightdm.nix {};
limesurvey = handleTest ./limesurvey.nix {};
login = handleTest ./login.nix {};
loki = handleTest ./loki.nix {};
#logstash = handleTest ./logstash.nix {};
mailcatcher = handleTest ./mailcatcher.nix {};
mathics = handleTest ./mathics.nix {};

37
nixos/tests/loki.nix Normal file
View file

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