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 lines
805 B
Nix
29 lines
805 B
Nix
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");
|
|
'';
|
|
})
|