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