summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorGuillaume Girol <symphorien+git@xlumurb.eu>2021-12-22 12:00:00 +0000
committerBjørn Forsman <bjorn.forsman@gmail.com>2021-12-23 00:08:43 +0100
commitb55a253e154160d2fde0db1e05ea3a16b46bcb18 (patch)
treee2fe1f05b3f6c8546e4f1bf04b40b8753de0aef5 /nixos
parent284756dda09515da74a29e4f4688c8f47b7e84b4 (diff)
nixos/collectd: add nixos test
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/collectd.nix33
2 files changed, 34 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 8f4d800abbfd..8ac2cb7fe790 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -70,6 +70,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}")
+ '';
+})