summary refs log tree commit diff
path: root/nixos/tests/netdata.nix
blob: 9bd147968e4b1acd0318e3940546b1704a5dc34c (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
# This test runs netdata and checks for data via apps.plugin

import ./make-test.nix ({ pkgs, ...} : {
  name = "netdata";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ cransom ];
  };

  nodes = {
    netdata =
      { pkgs, ... }:
        {
          environment.systemPackages = with pkgs; [ curl jq ];
          services.netdata.enable = true;
        };
    };

  testScript = ''
    startAll;

    $netdata->waitForUnit("netdata.service");

    # wait for the service to listen before sending a request
    $netdata->waitForOpenPort(19999);

    # check if the netdata main page loads.
    $netdata->succeed("curl --fail http://localhost:19999/");

    # check if netdata can read disk ops for root owned processes.
    # if > 0, successful. verifies both netdata working and
    # apps.plugin has elevated capabilities.
    my $cmd = <<'CMD';
    curl -s http://localhost:19999/api/v1/data\?chart=users.pwrites | \
       jq -e '[.data[range(10)][.labels | indices("root")[0]]] | add | . > 0'
    CMD
    $netdata->waitUntilSucceeds($cmd);
  '';
})