From 87cb26558857e505b15549e854f7bc63575ee1f9 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Tue, 21 May 2024 17:13:35 +0100 Subject: [PATCH] nixos/vector: Moved existing test to subdirectory --- nixos/tests/all-tests.nix | 2 +- nixos/tests/vector.nix | 53 -------------------------------- nixos/tests/vector/default.nix | 8 +++++ nixos/tests/vector/file-sink.nix | 49 +++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 54 deletions(-) delete mode 100644 nixos/tests/vector.nix create mode 100644 nixos/tests/vector/default.nix create mode 100644 nixos/tests/vector/file-sink.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 10daa1bbf6d2..3e4cfce7ae87 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1007,7 +1007,7 @@ in { vault-dev = handleTest ./vault-dev.nix {}; vault-postgresql = handleTest ./vault-postgresql.nix {}; vaultwarden = handleTest ./vaultwarden.nix {}; - vector = handleTest ./vector.nix {}; + vector = handleTest ./vector {}; vengi-tools = handleTest ./vengi-tools.nix {}; victoriametrics = handleTest ./victoriametrics.nix {}; vikunja = handleTest ./vikunja.nix {}; diff --git a/nixos/tests/vector.nix b/nixos/tests/vector.nix deleted file mode 100644 index 9c0d7e84fab3..000000000000 --- a/nixos/tests/vector.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ system ? builtins.currentSystem, config ? { } -, pkgs ? import ../.. { inherit system config; } }: - -with import ../lib/testing-python.nix { inherit system pkgs; }; -with pkgs.lib; - -{ - test1 = makeTest { - name = "vector-test1"; - meta.maintainers = [ pkgs.lib.maintainers.happysalada ]; - - nodes.machine = { config, pkgs, ... }: { - services.vector = { - enable = true; - journaldAccess = true; - settings = { - sources = { - journald.type = "journald"; - - vector_metrics.type = "internal_metrics"; - - vector_logs.type = "internal_logs"; - }; - - sinks = { - file = { - type = "file"; - inputs = [ "journald" "vector_logs" ]; - path = "/var/lib/vector/logs.log"; - encoding = { codec = "json"; }; - }; - - prometheus_exporter = { - type = "prometheus_exporter"; - inputs = [ "vector_metrics" ]; - address = "[::]:9598"; - }; - }; - }; - }; - }; - - # ensure vector is forwarding the messages appropriately - testScript = '' - machine.wait_for_unit("vector.service") - machine.wait_for_open_port(9598) - 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") - machine.wait_for_file("/var/lib/vector/logs.log") - ''; - }; -} diff --git a/nixos/tests/vector/default.nix b/nixos/tests/vector/default.nix new file mode 100644 index 000000000000..cf7fe9b968f9 --- /dev/null +++ b/nixos/tests/vector/default.nix @@ -0,0 +1,8 @@ +{ system ? builtins.currentSystem +, config ? { } +, pkgs ? import ../../.. { inherit system config; } +}: + +{ + file-sink = import ./file-sink.nix { inherit system pkgs; }; +} diff --git a/nixos/tests/vector/file-sink.nix b/nixos/tests/vector/file-sink.nix new file mode 100644 index 000000000000..d101963bc206 --- /dev/null +++ b/nixos/tests/vector/file-sink.nix @@ -0,0 +1,49 @@ +import ../make-test-python.nix ({ lib, pkgs, ... }: + +{ + name = "vector-test1"; + meta.maintainers = [ pkgs.lib.maintainers.happysalada ]; + + nodes.machine = { config, pkgs, ... }: { + services.vector = { + enable = true; + journaldAccess = true; + settings = { + sources = { + journald.type = "journald"; + + vector_metrics.type = "internal_metrics"; + + vector_logs.type = "internal_logs"; + }; + + sinks = { + file = { + type = "file"; + inputs = [ "journald" "vector_logs" ]; + path = "/var/lib/vector/logs.log"; + encoding = { codec = "json"; }; + }; + + prometheus_exporter = { + type = "prometheus_exporter"; + inputs = [ "vector_metrics" ]; + address = "[::]:9598"; + }; + }; + }; + }; + }; + + # ensure vector is forwarding the messages appropriately + 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("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") + machine.wait_for_file("/var/lib/vector/logs.log") + ''; +})