nixos/vector: Added testcase for verifying API endpoint
This commit is contained in:
parent
87cb265588
commit
1b27c58827
39
nixos/tests/vector/api.nix
Normal file
39
nixos/tests/vector/api.nix
Normal 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")
|
||||
'';
|
||||
})
|
@ -5,4 +5,5 @@
|
||||
|
||||
{
|
||||
file-sink = import ./file-sink.nix { inherit system pkgs; };
|
||||
api = import ./api.nix { inherit system pkgs; };
|
||||
}
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user