about summary refs log tree commit diff
path: root/nixos/tests/vector/api.nix
blob: 8aa3a0c1b771f5ea25281381158451afdc710ebc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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")
  '';
})