Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/osquery: add test #39709

Merged
merged 1 commit into from Apr 30, 2018
Merged

nixos/osquery: add test #39709

merged 1 commit into from Apr 30, 2018

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Apr 30, 2018

Motivation for this change

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.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@globin
Copy link
Member

globin commented Apr 30, 2018

@GrahamcOfBorg test osquery

@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: tests.osquery

Partial log (click to expand)

Cannot nix-instantiate `tests.osquery' because:
error: while evaluating anonymous function at /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/nixos/release.nix:23:8, called from /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/lib/attrsets.nix:282:43:
while evaluating 'hydraJob' at /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/lib/customisation.nix:162:14, called from /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/nixos/release.nix:23:16:
while evaluating 'importTest' at /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/nixos/release.nix:15:26, called from /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/nixos/release.nix:23:26:
while evaluating anonymous function at /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/nixos/tests/make-test.nix:1:4, called from /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/nixos/release.nix:15:34:
anonymous function at /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/nixos/tests/osquery.nix:1:25 called with unexpected argument 'system', at /home/ofborg/ofborg3/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/builder-7c6f434c3/nixos/tests/make-test.nix:5:41

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: tests.osquery

Partial log (click to expand)

Cannot nix-instantiate `tests.osquery' because:
�[31;1merror:�[0m while evaluating anonymous function at �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/nixos/release.nix�[0m:23:8, called from �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/lib/attrsets.nix�[0m:282:43:
while evaluating 'hydraJob' at �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/lib/customisation.nix�[0m:162:14, called from �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/nixos/release.nix�[0m:23:16:
while evaluating 'importTest' at �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/nixos/release.nix�[0m:15:26, called from �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/nixos/release.nix�[0m:23:26:
while evaluating anonymous function at �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/nixos/tests/make-test.nix�[0m:1:4, called from �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/nixos/release.nix�[0m:15:34:
anonymous function at �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/nixos/tests/osquery.nix�[0m:1:25 called with unexpected argument 'system', at �[1m/var/lib/gc-of-borg/nix-test-rs-21/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-21/nixos/tests/make-test.nix�[0m:5:41

Some time ago I fixed the broken package `osquery` (see NixOS#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.
@xeji
Copy link
Contributor

xeji commented Apr 30, 2018

Test LGTM and runs locally. And the ... should have fixed it on ofborg as well 😄

@xeji
Copy link
Contributor

xeji commented Apr 30, 2018

@GrahamcOfBorg test osquery

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: tests.osquery

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: tests.osquery

Partial log (click to expand)

machine: exit status 1
syncing
machine: running command: sync
machine: exit status 0
test script finished in 32.62s
cleaning up
killing machine (pid 593)
vde_switch: EOF on stdin, cleaning up and exiting
vde_switch: Could not remove ctl dir '/build/vde1.ctl': Directory not empty
/nix/store/419fvbvqac8khi1ycpxx491isyjvvzzf-vm-test-run-osquery

@Ma27
Copy link
Member Author

Ma27 commented Apr 30, 2018

@xeji @globin yeah sorry for that, Borg seems happy now :-)

@xeji xeji merged commit c505e57 into NixOS:master Apr 30, 2018
@Ma27 Ma27 deleted the osquery-testcase branch April 30, 2018 15:40
@cstrahan
Copy link
Contributor

cstrahan commented May 1, 2018

Thanks a ton for maintaining this, @Ma27. I’ve felt disheartened from seeing the package break, but my life has been too busy to contribute in a meaningful capacity for a while now (though I hope that’ll change before the year is up).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants