nixos/collectd: add nixos test

main
Guillaume Girol 3 years ago committed by Bjørn Forsman
parent 284756dda0
commit b55a253e15
  1. 1
      nixos/tests/all-tests.nix
  2. 33
      nixos/tests/collectd.nix
  3. 5
      pkgs/tools/system/collectd/default.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 {};

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

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

Loading…
Cancel
Save