nixos/collectd: add nixos test

This commit is contained in:
Guillaume Girol 2021-12-22 12:00:00 +00:00 committed by Bjørn Forsman
parent 284756dda0
commit b55a253e15
3 changed files with 39 additions and 0 deletions

View File

@ -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 {};

33
nixos/tests/collectd.nix Normal file
View File

@ -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}")
'';
})

View File

@ -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";