Skip to content

Commit

Permalink
nixosTests.netdata: port to python
Browse files Browse the repository at this point in the history
  • Loading branch information
Br1ght0ne authored and Lassulus committed Nov 28, 2019
1 parent 1eb951d commit 085766f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions nixos/tests/netdata.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This test runs netdata and checks for data via apps.plugin

import ./make-test.nix ({ pkgs, ...} : {
import ./make-test-python.nix ({ pkgs, ...} : {
name = "netdata";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ cransom ];
Expand All @@ -16,23 +16,22 @@ import ./make-test.nix ({ pkgs, ...} : {
};

testScript = ''
startAll;
start_all()
$netdata->waitForUnit("netdata.service");
netdata.wait_for_unit("netdata.service")
# wait for the service to listen before sending a request
$netdata->waitForOpenPort(19999);
netdata.wait_for_open_port(19999)
# check if the netdata main page loads.
$netdata->succeed("curl --fail http://localhost:19999/");
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);
url = "http://localhost:19999/api/v1/data\?chart=users.pwrites"
filter = '[.data[range(10)][.labels | indices("root")[0]]] | add | . > 0'
cmd = f"curl -s {url} | jq -e '{filter}'"
netdata.wait_until_succeeds(cmd)
'';
})

0 comments on commit 085766f

Please sign in to comment.