nixos/vector: Added testcase for verifying API endpoint

This commit is contained in:
Jonathan Davies 2024-05-21 17:16:02 +01:00
parent 87cb265588
commit 1b27c58827
No known key found for this signature in database
3 changed files with 42 additions and 2 deletions

View File

@ -0,0 +1,39 @@
import ../make-test-python.nix ({ lib, pkgs, ... }:
{
name = "vector-api";
meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
nodes.machineapi = { config, pkgs, ... }: {
services.vector = {
enable = true;
journaldAccess = false;
settings = {
api.enabled = true;
sources = {
demo_logs = {
type = "demo_logs";
format = "json";
};
};
sinks = {
file = {
type = "file";
inputs = [ "demo_logs" ];
path = "/var/lib/vector/logs.log";
encoding = { codec = "json"; };
};
};
};
};
};
testScript = ''
machineapi.wait_for_unit("vector")
machineapi.wait_for_open_port(8686)
machineapi.succeed("journalctl -o cat -u vector.service | grep 'API server running'")
machineapi.wait_until_succeeds("curl -sSf http://localhost:8686/health")
'';
})

View File

@ -5,4 +5,5 @@
{
file-sink = import ./file-sink.nix { inherit system pkgs; };
api = import ./api.nix { inherit system pkgs; };
}

View File

@ -39,8 +39,8 @@ import ../make-test-python.nix ({ lib, pkgs, ... }:
testScript = ''
machine.wait_for_unit("vector.service")
machine.wait_for_open_port(9598)
machine.succeed("journalctl -o cat -u vector.service | grep 'version=\"${pkgs.vector.version}\"'")
machine.succeed("journalctl -o cat -u vector.service | grep 'API is disabled'")
machine.wait_until_succeeds("journalctl -o cat -u vector.service | grep 'version=\"${pkgs.vector.version}\"'")
machine.wait_until_succeeds("journalctl -o cat -u vector.service | grep 'API is disabled'")
machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_build_info")
machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_component_received_bytes_total | grep journald")
machine.wait_until_succeeds("curl -sSf http://localhost:9598/metrics | grep vector_utilization | grep prometheus_exporter")