nixos: Make nesting.children work in NixOS tests
We differentiate between modules and baseModules in the VM builder for NixOS tests. This way, nesting.children, eventhough it doesn't inherit from parent, still has enough config to actually complete the test. Otherwise, the qemu modules would not be loaded, for example, and a nesting.children statement would not evaluate.
This commit is contained in:
@@ -32,14 +32,14 @@ rec {
|
||||
|
||||
import ./eval-config.nix {
|
||||
inherit system;
|
||||
modules = configurations ++
|
||||
modules = configurations ++ extraConfigurations;
|
||||
baseModules = (import ../modules/module-list.nix) ++
|
||||
[ ../modules/virtualisation/qemu-vm.nix
|
||||
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
|
||||
{ key = "no-manual"; documentation.nixos.enable = false; }
|
||||
{ key = "qemu"; system.build.qemu = qemu; }
|
||||
{ key = "nodes"; _module.args.nodes = nodes; }
|
||||
] ++ optional minimal ../modules/testing/minimal-kernel.nix
|
||||
++ extraConfigurations;
|
||||
] ++ optional minimal ../modules/testing/minimal-kernel.nix;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +1,42 @@
|
||||
import ./make-test.nix {
|
||||
name = "nesting";
|
||||
machine = { pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.cowsay ];
|
||||
nesting.clone = [
|
||||
({ pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.hello ];
|
||||
})
|
||||
];
|
||||
nodes = {
|
||||
clone = { pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.cowsay ];
|
||||
nesting.clone = [
|
||||
({ pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.hello ];
|
||||
})
|
||||
];
|
||||
};
|
||||
children = { pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.cowsay ];
|
||||
nesting.children = [
|
||||
({ pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.hello ];
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
testScript = ''
|
||||
$machine->waitForUnit("default.target");
|
||||
$machine->succeed("cowsay hey");
|
||||
$machine->fail("hello");
|
||||
$clone->waitForUnit("default.target");
|
||||
$clone->succeed("cowsay hey");
|
||||
$clone->fail("hello");
|
||||
|
||||
# Nested clones do inherit from parent
|
||||
$machine->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
|
||||
$machine->succeed("cowsay hey");
|
||||
$machine->succeed("hello");
|
||||
$clone->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
|
||||
$clone->succeed("cowsay hey");
|
||||
$clone->succeed("hello");
|
||||
|
||||
|
||||
$children->waitForUnit("default.target");
|
||||
$children->succeed("cowsay hey");
|
||||
$children->fail("hello");
|
||||
|
||||
# Nested children do not inherit from parent
|
||||
$children->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
|
||||
$children->fail("cowsay hey");
|
||||
$children->succeed("hello");
|
||||
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user