git.iko.soy/typeable/nixpkgs
on master help sign in
nixos: Make 'nesting.clone' work in NixOS tests (#62069)

nixos: Make 'nesting.clone' work in NixOS tests

commitb09c6ac05b870cc30a749cc294ef8e31b0ca4bd5 authorFlorian Klink <flokli@flokli.de> dateWed 29 May 2019, 14:45 (7 years ago) parent999b31acbc45b5
3 files changed+47−4
nixos/lib/build-vms.nix+4−4 nixos/tests/all-tests.nix+1 nixos/tests/nesting.nix+42
nixos/lib/build-vms.nix+4−4
@@ -32,14 +32,14 @@ rec {
3232
3333 import ./eval-config.nix {
3434 inherit system;
35− modules = configurations ++
35+ modules = configurations ++ extraConfigurations;
36+ baseModules = (import ../modules/module-list.nix) ++
3637 [ ../modules/virtualisation/qemu-vm.nix
3738 ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
3839 { key = "no-manual"; documentation.nixos.enable = false; }
3940 { key = "qemu"; system.build.qemu = qemu; }
40− ] ++ optional minimal ../modules/testing/minimal-kernel.nix
41− ++ extraConfigurations;
42− extraArgs = { inherit nodes; };
41+ { key = "nodes"; _module.args.nodes = nodes; }
42+ ] ++ optional minimal ../modules/testing/minimal-kernel.nix;
4343 };
4444
4545
nixos/tests/all-tests.nix+1
@@ -161,6 +161,7 @@ in
161161 nat.standalone = handleTest ./nat.nix { withFirewall = false; };
162162 ndppd = handleTest ./ndppd.nix {};
163163 neo4j = handleTest ./neo4j.nix {};
164+ nesting = handleTest ./nesting.nix {};
164165 netdata = handleTest ./netdata.nix {};
165166 networking.networkd = handleTest ./networking.nix { networkd = true; };
166167 networking.scripted = handleTest ./networking.nix { networkd = false; };
nixos/tests/nesting.nixnew file+42
@@ -0,0 +1,42 @@
1+import ./make-test.nix {
2+ name = "nesting";
3+ nodes = {
4+ clone = { pkgs, ... }: {
5+ environment.systemPackages = [ pkgs.cowsay ];
6+ nesting.clone = [
7+ ({ pkgs, ... }: {
8+ environment.systemPackages = [ pkgs.hello ];
9+ })
10+ ];
11+ };
12+ children = { pkgs, ... }: {
13+ environment.systemPackages = [ pkgs.cowsay ];
14+ nesting.children = [
15+ ({ pkgs, ... }: {
16+ environment.systemPackages = [ pkgs.hello ];
17+ })
18+ ];
19+ };
20+ };
21+ testScript = ''
22+ $clone->waitForUnit("default.target");
23+ $clone->succeed("cowsay hey");
24+ $clone->fail("hello");
25+
26+ # Nested clones do inherit from parent
27+ $clone->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
28+ $clone->succeed("cowsay hey");
29+ $clone->succeed("hello");
30+
31+
32+ $children->waitForUnit("default.target");
33+ $children->succeed("cowsay hey");
34+ $children->fail("hello");
35+
36+ # Nested children do not inherit from parent
37+ $children->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
38+ $children->fail("cowsay hey");
39+ $children->succeed("hello");
40+
41+ '';
42+}