git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #39709 from Ma27/osquery-testcase

nixos/osquery: add test

commitc505e5777143a35828494e2c1e9744940b224a5d authorxeji <36407913+xeji@users.noreply.github.com> dateMon 30 Apr 2018, 16:59 (9 years ago) parentcf994a3e12cc85
2 files changed+29
nixos/release.nix+1 nixos/tests/osquery.nix+28
nixos/release.nix+1
@@ -307,6 +307,7 @@ in rec {
307307 tests.influxdb = callTest tests/influxdb.nix {};
308308 tests.ipv6 = callTest tests/ipv6.nix {};
309309 tests.jenkins = callTest tests/jenkins.nix {};
310+ tests.osquery = callTest tests/osquery.nix {};
310311 tests.plasma5 = callTest tests/plasma5.nix {};
311312 tests.plotinus = callTest tests/plotinus.nix {};
312313 tests.keymap = callSubTests tests/keymap.nix {};
nixos/tests/osquery.nixnew file+28
@@ -0,0 +1,28 @@
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+})