1# This test runs netdata and checks for data via apps.plugin
2
3import ./make-test-python.nix (
4 { pkgs, ... }:
5 {
6 name = "netdata";
7 meta = with pkgs.lib.maintainers; {
8 maintainers = [
9 cransom
10 raitobezarius
11 ];
12 };
13
14 nodes = {
15 netdata =
16 { pkgs, ... }:
17 {
18 environment.systemPackages = with pkgs; [
19 curl
20 jq
21 netdata
22 ];
23 services.netdata = {
24 enable = true;
25 package = pkgs.netdataCloud;
26 python.recommendedPythonPackages = true;
27
28 configDir."apps_groups.conf" = pkgs.writeText "apps_groups.conf" ''
29 netdata_test: netdata
30 '';
31 };
32 };
33 };
34
35 testScript = ''
36 start_all()
37
38 netdata.wait_for_unit("netdata.service")
39
40 # wait for the service to listen before sending a request
41 netdata.wait_for_open_port(19999)
42
43 # check if the netdata main page loads.
44 netdata.succeed("curl --fail http://127.0.0.1:19999")
45 netdata.succeed("sleep 4")
46
47 # check if netdata api shows correct os
48 url = "http://127.0.0.1:19999/api/v3/info"
49 filter = '.agents[0].application.os.os | . == "NixOS"'
50 cmd = f"curl -s {url} | jq -e '{filter}'"
51 netdata.wait_until_succeeds(cmd)
52
53 # check if the control socket is available
54 netdata.succeed("sudo netdatacli ping")
55 '';
56 }
57)