diff options
| author | Guillaume Girol <symphorien+git@xlumurb.eu> | 2021-12-22 12:00:00 +0000 |
|---|---|---|
| committer | Jonathan Ringer <jonringer@users.noreply.github.com> | 2022-02-09 21:21:56 -0800 |
| commit | 23110dec7a4c8b304cf6ff99e603f2897a766328 (patch) | |
| tree | 2e3eee1e6395b91ac78255a59e6547405dd2c2db | |
| parent | nixos/wireless: don't attempt fallback on WPA3 only networks (diff) | |
| download | nixpkgs-23110dec7a4c8b304cf6ff99e603f2897a766328.tar.gz | |
nixos/collectd: add nixos test
(cherry picked from commit b55a253e154160d2fde0db1e05ea3a16b46bcb18)
| -rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
| -rw-r--r-- | nixos/tests/collectd.nix | 33 | ||||
| -rw-r--r-- | pkgs/tools/system/collectd/default.nix | 5 |
3 files changed, 39 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 70d0c635b02d..de105d59eb53 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -68,6 +68,7 @@ in cloud-init = handleTest ./cloud-init.nix {}; cntr = handleTest ./cntr.nix {}; cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {}; + collectd = handleTest ./collectd.nix {}; consul = handleTest ./consul.nix {}; containers-bridge = handleTest ./containers-bridge.nix {}; containers-custom-pkgs.nix = handleTest ./containers-custom-pkgs.nix {}; diff --git a/nixos/tests/collectd.nix b/nixos/tests/collectd.nix new file mode 100644 index 000000000000..cb196224a231 --- /dev/null +++ b/nixos/tests/collectd.nix @@ -0,0 +1,33 @@ +import ./make-test-python.nix ({ pkgs, ... }: { + name = "collectd"; + meta = { }; + + machine = + { pkgs, ... }: + + { + services.collectd = { + enable = true; + plugins = { + rrdtool = '' + DataDir "/var/lib/collectd/rrd" + ''; + load = ""; + }; + }; + environment.systemPackages = [ pkgs.rrdtool ]; + }; + + testScript = '' + machine.wait_for_unit("collectd.service") + hostname = machine.succeed("hostname").strip() + file = f"/var/lib/collectd/rrd/{hostname}/load/load.rrd" + machine.wait_for_file(file); + machine.succeed(f"rrdinfo {file} | logger") + # check that this file contains a shortterm metric + machine.succeed(f"rrdinfo {file} | grep -F 'ds[shortterm].min = '") + # check that there are frequent updates + machine.succeed(f"cp {file} before") + machine.wait_until_fails(f"cmp before {file}") + ''; +}) diff --git a/pkgs/tools/system/collectd/default.nix b/pkgs/tools/system/collectd/default.nix index 600c5cbfecd3..cdd51aa9fa3e 100644 --- a/pkgs/tools/system/collectd/default.nix +++ b/pkgs/tools/system/collectd/default.nix @@ -2,6 +2,7 @@ , autoreconfHook , pkg-config , libtool +, nixosTests , ... }@args: let @@ -41,6 +42,10 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; + passthru.tests = { + inherit (nixosTests) collectd; + }; + meta = with lib; { description = "Daemon which collects system performance statistics periodically"; homepage = "https://collectd.org"; |
