diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2018-04-30 11:59:53 +0200 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2018-04-30 16:49:38 +0200 |
commit | e12cc85b070ec62144c5bfc8036041fee4b3692e (patch) | |
tree | d6e82d564dc6b35d9e5274080f5fa8b344ae1813 /nixos | |
parent | 69d4bdc55788efb3a34a831cf341e5e69484fadc (diff) | |
download | nixpkgs-e12cc85b070ec62144c5bfc8036041fee4b3692e.tar nixpkgs-e12cc85b070ec62144c5bfc8036041fee4b3692e.tar.gz nixpkgs-e12cc85b070ec62144c5bfc8036041fee4b3692e.tar.bz2 nixpkgs-e12cc85b070ec62144c5bfc8036041fee4b3692e.tar.lz nixpkgs-e12cc85b070ec62144c5bfc8036041fee4b3692e.tar.xz nixpkgs-e12cc85b070ec62144c5bfc8036041fee4b3692e.tar.zst nixpkgs-e12cc85b070ec62144c5bfc8036041fee4b3692e.zip |
nixos/osquery: add test
Some time ago I fixed the broken package `osquery` (see #39336). I had to test the package manually by starting the daemon locally, however this doesn't ensure that the module is still functional. In order to cover the package *and* the integration with the NixOS module I thought that adding a testcase might be the best idea. The current testcase does the following things: * Starts an `osqueryd` service in a test machine with customized logger path and PID file * Ensures that the `osqueryd.service` unit is running * Checks if the customized flags (`pidfile`, `logger_path`) are applied to `osquery`. * Performs a simple test query against the `etc_hosts` database to check if the basic funcitonality of `osquery` (storing system information into a database) works fine.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/release.nix | 1 | ||||
-rw-r--r-- | nixos/tests/osquery.nix | 28 |
2 files changed, 29 insertions, 0 deletions
diff --git a/nixos/release.nix b/nixos/release.nix index 4994cd98302..4ad947f11d1 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -307,6 +307,7 @@ in rec { tests.influxdb = callTest tests/influxdb.nix {}; tests.ipv6 = callTest tests/ipv6.nix {}; tests.jenkins = callTest tests/jenkins.nix {}; + tests.osquery = callTest tests/osquery.nix {}; tests.plasma5 = callTest tests/plasma5.nix {}; tests.plotinus = callTest tests/plotinus.nix {}; tests.keymap = callSubTests tests/keymap.nix {}; diff --git a/nixos/tests/osquery.nix b/nixos/tests/osquery.nix new file mode 100644 index 00000000000..281dbcff664 --- /dev/null +++ b/nixos/tests/osquery.nix @@ -0,0 +1,28 @@ +import ./make-test.nix ({ pkgs, lib, ... }: + +with lib; + +{ + name = "osquery"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ ma27 ]; + }; + + machine = { + services.osquery.enable = true; + services.osquery.loggerPath = "/var/log/osquery/logs"; + services.osquery.pidfile = "/var/run/osqueryd.pid"; + }; + + testScript = '' + $machine->start; + $machine->waitForUnit("osqueryd.service"); + + $machine->succeed("echo 'SELECT address FROM etc_hosts LIMIT 1;' | osqueryi | grep '127.0.0.1'"); + $machine->succeed( + "echo 'SELECT value FROM osquery_flags WHERE name = \"logger_path\";' | osqueryi | grep /var/log/osquery/logs" + ); + + $machine->succeed("echo 'SELECT value FROM osquery_flags WHERE name = \"pidfile\";' | osqueryi | grep /var/run/osqueryd.pid"); + ''; +}) |