mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
nixos/tests/mutable-users: use specialisations instead of multiple machines
This commit is contained in:
parent
fda8ac99d5
commit
cc536b4cb8
@ -7,19 +7,19 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||||||
};
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
machine = { ... }: {
|
machine = {
|
||||||
users.mutableUsers = false;
|
specialisation.immutable.configuration = {
|
||||||
};
|
users.mutableUsers = false;
|
||||||
mutable = { ... }: {
|
};
|
||||||
users.mutableUsers = true;
|
|
||||||
users.users.dry-test.isNormalUser = true;
|
specialisation.mutable.configuration = {
|
||||||
|
users.mutableUsers = true;
|
||||||
|
users.users.dry-test.isNormalUser = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = {nodes, ...}: let
|
testScript = ''
|
||||||
immutableSystem = nodes.machine.config.system.build.toplevel;
|
|
||||||
mutableSystem = nodes.mutable.config.system.build.toplevel;
|
|
||||||
in ''
|
|
||||||
machine.start()
|
machine.start()
|
||||||
machine.wait_for_unit("default.target")
|
machine.wait_for_unit("default.target")
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||||||
machine.succeed("sudo useradd foobar")
|
machine.succeed("sudo useradd foobar")
|
||||||
assert "foobar" in machine.succeed("cat /etc/passwd")
|
assert "foobar" in machine.succeed("cat /etc/passwd")
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"${immutableSystem}/bin/switch-to-configuration test"
|
"/run/booted-system/specialisation/immutable/bin/switch-to-configuration test"
|
||||||
)
|
)
|
||||||
assert "foobar" not in machine.succeed("cat /etc/passwd")
|
assert "foobar" not in machine.succeed("cat /etc/passwd")
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||||||
with subtest("Password is wrapped in mutable mode"):
|
with subtest("Password is wrapped in mutable mode"):
|
||||||
assert "/run/current-system/" in machine.succeed("which passwd")
|
assert "/run/current-system/" in machine.succeed("which passwd")
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"${mutableSystem}/bin/switch-to-configuration test"
|
"/run/booted-system/specialisation/mutable/bin/switch-to-configuration test"
|
||||||
)
|
)
|
||||||
assert "/run/wrappers/" in machine.succeed("which passwd")
|
assert "/run/wrappers/" in machine.succeed("which passwd")
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
|||||||
expected_hashes[file] = machine.succeed(f"sha256sum {file}")
|
expected_hashes[file] = machine.succeed(f"sha256sum {file}")
|
||||||
expected_stats[file] = machine.succeed(f"stat {file}")
|
expected_stats[file] = machine.succeed(f"stat {file}")
|
||||||
|
|
||||||
machine.succeed("/run/current-system/bin/switch-to-configuration dry-activate")
|
machine.succeed("/run/booted-system/specialisation/mutable/bin/switch-to-configuration dry-activate")
|
||||||
|
|
||||||
machine.fail('test -e /home/dry-test') # home was not recreated
|
machine.fail('test -e /home/dry-test') # home was not recreated
|
||||||
for file in files_to_check:
|
for file in files_to_check:
|
||||||
|
Loading…
Reference in New Issue
Block a user