1# This test runs netdata and checks for data via apps.plugin
2
3import ./make-test-python.nix ({ pkgs, ...} : {
4 name = "netdata";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ cransom raitobezarius ];
7 };
8
9 nodes = {
10 netdata =
11 { pkgs, ... }:
12 {
13 environment.systemPackages = with pkgs; [ curl jq ];
14 services.netdata.enable = true;
15 };
16 };
17
18 testScript = ''
19 start_all()
20
21 netdata.wait_for_unit("netdata.service")
22
23 # wait for the service to listen before sending a request
24 netdata.wait_for_open_port(19999)
25
26 # check if the netdata main page loads.
27 netdata.succeed("curl --fail http://localhost:19999/")
28 netdata.succeed("sleep 4")
29
30 # check if netdata can read disk ops for root owned processes.
31 # if > 0, successful. verifies both netdata working and
32 # apps.plugin has elevated capabilities.
33 url = "http://localhost:19999/api/v1/data\?chart=users.pwrites"
34 filter = '[.data[range(10)][.labels | indices("root")[0]]] | add | . > 0'
35 cmd = f"curl -s {url} | jq -e '{filter}'"
36 netdata.wait_until_succeeds(cmd)
37 '';
38})