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.

+29
+1
nixos/release.nix
··· 307 307 tests.influxdb = callTest tests/influxdb.nix {}; 308 308 tests.ipv6 = callTest tests/ipv6.nix {}; 309 309 tests.jenkins = callTest tests/jenkins.nix {}; 310 + tests.osquery = callTest tests/osquery.nix {}; 310 311 tests.plasma5 = callTest tests/plasma5.nix {}; 311 312 tests.plotinus = callTest tests/plotinus.nix {}; 312 313 tests.keymap = callSubTests tests/keymap.nix {};
+28
nixos/tests/osquery.nix
··· 1 + import ./make-test.nix ({ pkgs, lib, ... }: 2 + 3 + with lib; 4 + 5 + { 6 + name = "osquery"; 7 + meta = with pkgs.stdenv.lib.maintainers; { 8 + maintainers = [ ma27 ]; 9 + }; 10 + 11 + machine = { 12 + services.osquery.enable = true; 13 + services.osquery.loggerPath = "/var/log/osquery/logs"; 14 + services.osquery.pidfile = "/var/run/osqueryd.pid"; 15 + }; 16 + 17 + testScript = '' 18 + $machine->start; 19 + $machine->waitForUnit("osqueryd.service"); 20 + 21 + $machine->succeed("echo 'SELECT address FROM etc_hosts LIMIT 1;' | osqueryi | grep '127.0.0.1'"); 22 + $machine->succeed( 23 + "echo 'SELECT value FROM osquery_flags WHERE name = \"logger_path\";' | osqueryi | grep /var/log/osquery/logs" 24 + ); 25 + 26 + $machine->succeed("echo 'SELECT value FROM osquery_flags WHERE name = \"pidfile\";' | osqueryi | grep /var/run/osqueryd.pid"); 27 + ''; 28 + })