-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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/testing-python: Avoid infinite recursion in node definitions #144110
base: master
Are you sure you want to change the base?
Conversation
Pass a version of the nodes without `additionalPaths` to `testScript` in order to avoid infinite recursion when the test script refers to any of the nodes' toplevel closures.
mkTestScript = qemu_pkg: | ||
# Call the test script with the computed nodes. | ||
if lib.isFunction testScript | ||
then testScript { nodes = nodes qemu_pkg false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then testScript { nodes = nodes qemu_pkg false; } | |
# To avoid an infinite recursion (nodes -> testScript -> nodes), we force disable | |
# the effect of config.virtualisation.useNixStoreImage, so `testScript -> nodes` | |
# becomes `testScript -> nodes2` where `nodes2` does not reference the `testScript`. | |
then testScript { nodes = nodes qemu_pkg false; } |
inherit enableOCR skipLint passthru; | ||
testScript = mkTestScript pkgs.qemu_test; | ||
testName = name; | ||
qemu_pkg = pkgs.qemu_test; | ||
nodes = nodes pkgs.qemu_test; | ||
nodes = nodes pkgs.qemu_test true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be best if the testScript
could reuse this nodes
value instead; only invoking the configs an extra time, when lib.any (n: n.config.virtualisation.useNixStoreImage) nodes
.
I've translated this PR's logic into part of a module in #176557, |
This is a decomposition of the testing-python.nix and build-vms.nix files into modules. By refactoring the glue, we accomplish the following: - NixOS tests can now use `imports` and other module system features. - Network-wide test setup can now be reusable; example: - A setup with all VMs configured to use a DNS server - Split long, slow tests into multiple tests that import a common module that has most of the setup. - Type checking for the test arguments - (TBD) "generated" options reference docs - Aspects that had to be wired through all the glue are now in their own files. - Chief example: interactive.nix. - Also: network.nix In rewriting this, I've generally stuck as close as possible to the existing code; copying pieces of logic and rewiring them, without changing the logic itself. I've made two exceptions to this rule - Introduction of `extraDriverArgs` instead of hardcoded interactivity logic. - Incorporation of NixOS#144110 in testScript.nix. I might revert the latter and split it into a new commit.
This is a decomposition of the testing-python.nix and build-vms.nix files into modules. By refactoring the glue, we accomplish the following: - NixOS tests can now use `imports` and other module system features. - Network-wide test setup can now be reusable; example: - A setup with all VMs configured to use a DNS server - Split long, slow tests into multiple tests that import a common module that has most of the setup. - Type checking for the test arguments - (TBD) "generated" options reference docs - Aspects that had to be wired through all the glue are now in their own files. - Chief example: interactive.nix. - Also: network.nix In rewriting this, I've generally stuck as close as possible to the existing code; copying pieces of logic and rewiring them, without changing the logic itself. I've made two exceptions to this rule - Introduction of `extraDriverArgs` instead of hardcoded interactivity logic. - Incorporation of NixOS#144110 in testScript.nix. I might revert the latter and split it into a new commit.
This is a decomposition of the testing-python.nix and build-vms.nix files into modules. By refactoring the glue, we accomplish the following: - NixOS tests can now use `imports` and other module system features. - Network-wide test setup can now be reusable; example: - A setup with all VMs configured to use a DNS server - Split long, slow tests into multiple tests that import a common module that has most of the setup. - Type checking for the test arguments - (TBD) "generated" options reference docs - Aspects that had to be wired through all the glue are now in their own files. - Chief example: interactive.nix. - Also: network.nix In rewriting this, I've generally stuck as close as possible to the existing code; copying pieces of logic and rewiring them, without changing the logic itself. I've made two exceptions to this rule - Introduction of `extraDriverArgs` instead of hardcoded interactivity logic. - Incorporation of NixOS#144110 in testScript.nix. I might revert the latter and split it into a new commit.
This is a decomposition of the testing-python.nix and build-vms.nix files into modules. By refactoring the glue, we accomplish the following: - NixOS tests can now use `imports` and other module system features. - Network-wide test setup can now be reusable; example: - A setup with all VMs configured to use a DNS server - Split long, slow tests into multiple tests that import a common module that has most of the setup. - Type checking for the test arguments - (TBD) "generated" options reference docs - Aspects that had to be wired through all the glue are now in their own files. - Chief example: interactive.nix. - Also: network.nix In rewriting this, I've generally stuck as close as possible to the existing code; copying pieces of logic and rewiring them, without changing the logic itself. I've made two exceptions to this rule - Introduction of `extraDriverArgs` instead of hardcoded interactivity logic. - Incorporation of NixOS#144110 in testScript.nix. I might revert the latter and split it into a new commit.
This is a decomposition of the testing-python.nix and build-vms.nix files into modules. By refactoring the glue, we accomplish the following: - NixOS tests can now use `imports` and other module system features. - Network-wide test setup can now be reusable; example: - A setup with all VMs configured to use a DNS server - Split long, slow tests into multiple tests that import a common module that has most of the setup. - Type checking for the test arguments - (TBD) "generated" options reference docs - Aspects that had to be wired through all the glue are now in their own files. - Chief example: interactive.nix. - Also: network.nix In rewriting this, I've generally stuck as close as possible to the existing code; copying pieces of logic and rewiring them, without changing the logic itself. I've made two exceptions to this rule - Introduction of `extraDriverArgs` instead of hardcoded interactivity logic. - Incorporation of #144110 in testScript.nix. I might revert the latter and split it into a new commit.
This is a decomposition of the testing-python.nix and build-vms.nix files into modules. By refactoring the glue, we accomplish the following: - NixOS tests can now use `imports` and other module system features. - Network-wide test setup can now be reusable; example: - A setup with all VMs configured to use a DNS server - Split long, slow tests into multiple tests that import a common module that has most of the setup. - Type checking for the test arguments - (TBD) "generated" options reference docs - Aspects that had to be wired through all the glue are now in their own files. - Chief example: interactive.nix. - Also: network.nix In rewriting this, I've generally stuck as close as possible to the existing code; copying pieces of logic and rewiring them, without changing the logic itself. I've made two exceptions to this rule - Introduction of `extraDriverArgs` instead of hardcoded interactivity logic. - Incorporation of NixOS#144110 in testScript.nix. I might revert the latter and split it into a new commit.
Motivation for this change
This is a follow-up to #140792 and #144014.
#144014 solves the infinite recursion issue when
useNixStoreImage
isfalse
. This follow-up solves it in the general case by passing a version of the nodes withoutadditionalPaths
totestScript
.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)