about summary refs log tree commit diff
path: root/nixos/tests/victoriametrics.nix
blob: 5e364b67bf87e1752cbd77a2b534b9a53fda381b (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
# This test runs influxdb and checks if influxdb is up and running

import ./make-test-python.nix ({ pkgs, ...} : {
  name = "victoriametrics";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ yorickvp ];
  };

  nodes = {
    one = { ... }: {
      services.victoriametrics.enable = true;
    };
  };

  testScript = ''
    start_all()

    one.wait_for_unit("victoriametrics.service")

    # write some points and run simple query
    out = one.succeed(
        "curl -f -d 'measurement,tag1=value1,tag2=value2 field1=123,field2=1.23' -X POST 'http://localhost:8428/write'"
    )
    cmd = (
        """curl -f -s -G 'http://localhost:8428/api/v1/export' -d 'match={__name__!=""}'"""
    )
    # data takes a while to appear
    one.wait_until_succeeds(f"[[ $({cmd} | wc -l) -ne 0 ]]")
    out = one.succeed(cmd)
    assert '"values":[123]' in out
    assert '"values":[1.23]' in out
  '';
})