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

Fix meta.tests system #50233

Merged
merged 6 commits into from Nov 12, 2018
Merged

Fix meta.tests system #50233

merged 6 commits into from Nov 12, 2018

Conversation

Ekleog
Copy link
Member

@Ekleog Ekleog commented Nov 11, 2018

This will be easier reviewed commit-by-commit, I tried to add in useful commit messages.

I think this should handle the concerns raised at #44439 and #50230.

For those who want to read only the commit messages, here they are:

tests: refactor to carry the package set as an argument

This way, the package set will be possible to pass without re-importing
all the time

tests: split into a separate all-tests.nix file

This will make the list much easier to re-use, eg. for nixosTests

The drawback is that this approaches makes the

nix-build release.nix -A tests.opensmtpd.x86_64-linux

command about twice as slow (3s to 6s): it now has to evaluate nixpkgs
once for each architecture, instead of just having the hardcoded list of
tests that allowed to say “ok just evaluate for x86_64-linux”.

On the other hand, complete evaluation of release.nix should be much
faster because we no longer import nixpkgs for each test: testing with
the following command went from 30s to 18s, and that's just for a few
tests.

time nix-instantiate --eval --strict nixos/release.nix -A tests.nat

I initially wanted to test on the whole release.nix, but there are too
many broken tests and it takes too long to eval them all, especially
compared to the fact that the current implementation breaks some setup.

Given developers can just nix-build nixos/tests/my-test.nix, it sounds
like an overall win.

tests: disable some broken tests and/or restrict to x86_64

meta.tests: drop meta.needsVMSupport

Its job is already handled by requiredSystemFeatures

meta.tests: rename into passthru.tests

Nix currently rejects derivations in meta values. This works around
that limitation by using passthru instead.

Closes #50230

nixosTests: use the newly-extracted all-tests.nix

This way, the package set will be possible to pass without re-importing
all the time
This will make the list much easier to re-use, eg. for `nixosTests`

The drawback is that this approaches makes the
```
nix-build release.nix -A tests.opensmtpd.x86_64-linux
```
command about twice as slow (3s to 6s): it now has to evaluate `nixpkgs`
once for each architecture, instead of just having the hardcoded list of
tests that allowed to say “ok just evaluate for x86_64-linux”.

On the other hand, complete evaluation of `release.nix` should be much
faster because we no longer import `nixpkgs` for each test: testing with
the following command went from 30s to 18s, and that's just for a few
tests.
```
time nix-instantiate --eval --strict nixos/release.nix -A tests.nat
```
I initially wanted to test on the whole `release.nix`, but there are too
many broken tests and it takes too long to eval them all, especially
compared to the fact that the current implementation breaks some setup.

Given developers can just `nix-build nixos/tests/my-test.nix`, it sounds
like an overall win.
Its job is already handled by `requiredSystemFeatures`
Nix currently rejects derivations in `meta` values. This works around
that limitation by using `passthru` instead.

Closes NixOS#50230
@timokau
Copy link
Member

timokau commented Nov 11, 2018

Any reason to do this all in one PR? I think we could merge the relatively urgent meta -> passthru right now without much discussion, the rest maybe not. At least I don't know enough about it to thoroughly review it.

@Ekleog
Copy link
Member Author

Ekleog commented Nov 11, 2018

@timokau The meta -> passthru is not that urgent: currently the meta.tests lines are commented-out. Also, this is fixing the issues @Ericson2314 mentioned, and I don't think we'd have merged the initial PR if we had known them?

Then I must say I'm currently basically thinking “well, this already 3 months, can wait 1 more”, though I'm aware this will merge-conflict as soon as someone adds a test.

Anyway, I can split the “drop meta.needsVMSupport” and “rename to passthru.tests” commits in a separate PR if you'd rather, I was just thinking it'd be better to have nothing than a broken setup, in part because it encourages people to actually review it instead of thinking something along the lines of “well, it works good enough, there are more pressing PRs” :)

BTW let's check whether it actually works with ofborg.

@GrahamcOfBorg build opensmtpd.tests

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: opensmtpd.tests

Partial log (click to expand)

client: running command: sync
client: exit status 0
test script finished in 41.94s
cleaning up
killing smtp1 (pid 597)
killing smtp2 (pid 609)
killing client (pid 621)
vde_switch: EOF on stdin, cleaning up and exiting
vde_switch: Could not remove ctl dir '/build/vde1.ctl': Directory not empty
/nix/store/k46cncv2yvkk1r1lifwkjs9pyxv7qj3h-vm-test-run-opensmtpd

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: opensmtpd.tests

Partial log (click to expand)

smtp1: running command: sync
smtp1: exit status 0
test script finished in 111.09s
cleaning up
killing client (pid 631)
killing smtp2 (pid 643)
killing smtp1 (pid 657)
vde_switch: EOF on stdin, cleaning up and exiting
vde_switch: Could not remove ctl dir '/build/vde1.ctl': Directory not empty
/nix/store/drz0xhw9pw7hyb7qqqxz2appcpdnlyqk-vm-test-run-opensmtpd

@timokau
Copy link
Member

timokau commented Nov 11, 2018

Then I must say I'm currently basically thinking “well, this already 3 months, can wait 1 more”, though I'm aware this will merge-conflict as soon as someone adds a test.

Sure, whatever way you think works best. I know it can be very frustrating when you spend time improving something and then it goes stale forever. Bonus stress points if there are issues after merge. That happens and is hard to avoid without better tooling. I appreciate your efforts to improve the testing infrastructure :)

Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks wonderful! This solves all the issues I raised perfectly.

@Ericson2314
Copy link
Member

I understand the impatience, and can't see how anyone wouldn't think this is at least a step in the right direction, so I'll merge.

@Ericson2314 Ericson2314 merged commit df9334b into NixOS:master Nov 12, 2018
@Ekleog
Copy link
Member Author

Ekleog commented Nov 12, 2018

\o/ Thank you! :D

@samueldr
Copy link
Member

env -i nix-build -I . --option restrict-eval true ./nixos/release.nix -A tests.openssh
error: access to path '/nix/store/x29rrys4gmskxpzngwibnmriigycnb79-nixpkgs' is forbidden in restricted mode
(use '--show-trace' to show detailed location information)

This currently stops ofborg from testing tests, and I would hazard a guess it will also fail on Hydra.

@Ekleog
Copy link
Member Author

Ekleog commented Nov 14, 2018

A first attempt at figuring out this is at #50186 (comment)

Ekleog added a commit to Ekleog/nixpkgs that referenced this pull request Nov 14, 2018
The current behavior, breaking restrict-eval=true, had been introduced
in 209f8b1. See also [1].

This change uses a hack to identify whether we're evaluating in
restrict-eval, keeping the optimization when not and reverting to the
old behavior when evaluating in restrict-eval.

This should fix the issues that appeared at [2] and [3], that followed
the change making us actually use this `nixpkgs` argument for tests
since 83b27f6 [4].

CC: @roberth

[1] NixOS@209f8b1acd4c#commitcomment-28419462

[2] NixOS#50233 (comment)

[3] NixOS#50186

[4] NixOS#50233
@Ekleog
Copy link
Member Author

Ekleog commented Nov 14, 2018

@samueldr #50342 should solve this issue.

@Mic92
Copy link
Member

Mic92 commented Nov 15, 2018

nixops breakage documented here: #50419

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

6 participants