mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
nixosTests/zfs: replace direct bootctl call with switch-to-configuration invocation
This commit is contained in:
@@ -121,82 +121,90 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript =
|
||||||
machine.wait_for_unit("multi-user.target")
|
{ nodes, ... }:
|
||||||
machine.succeed(
|
let
|
||||||
"zpool status",
|
samba = nodes.machine.specialisation.samba.configuration.system.build.toplevel;
|
||||||
"parted --script /dev/vdb mklabel msdos",
|
encryption = nodes.machine.specialisation.encryption.configuration.system.build.toplevel;
|
||||||
"parted --script /dev/vdb -- mkpart primary 1024M -1s",
|
forcepool = nodes.machine.specialisation.forcepool.configuration.system.build.toplevel;
|
||||||
"parted --script /dev/vdc mklabel msdos",
|
in
|
||||||
"parted --script /dev/vdc -- mkpart primary 1024M -1s",
|
# python
|
||||||
)
|
''
|
||||||
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
machine.succeed(
|
||||||
|
"zpool status",
|
||||||
|
"parted --script /dev/vdb mklabel msdos",
|
||||||
|
"parted --script /dev/vdb -- mkpart primary 1024M -1s",
|
||||||
|
"parted --script /dev/vdc mklabel msdos",
|
||||||
|
"parted --script /dev/vdc -- mkpart primary 1024M -1s",
|
||||||
|
)
|
||||||
|
|
||||||
with subtest("sharesmb works"):
|
with subtest("sharesmb works"):
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"zpool create rpool /dev/vdb1",
|
"zpool create rpool /dev/vdb1",
|
||||||
"zfs create -o mountpoint=legacy rpool/root",
|
"zfs create -o mountpoint=legacy rpool/root",
|
||||||
# shared datasets cannot have legacy mountpoint
|
# shared datasets cannot have legacy mountpoint
|
||||||
"zfs create rpool/shared_smb",
|
"zfs create rpool/shared_smb",
|
||||||
"bootctl set-default nixos-generation-1-specialisation-samba.conf",
|
"${samba}/bin/switch-to-configuration boot",
|
||||||
"sync",
|
"sync",
|
||||||
)
|
)
|
||||||
machine.crash()
|
machine.crash()
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.succeed("zfs set sharesmb=on rpool/shared_smb")
|
machine.succeed("zfs set sharesmb=on rpool/shared_smb")
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"smbclient -gNL localhost | grep rpool_shared_smb",
|
"smbclient -gNL localhost | grep rpool_shared_smb",
|
||||||
"umount /tmp/mnt",
|
"umount /tmp/mnt",
|
||||||
"zpool destroy rpool",
|
"zpool destroy rpool",
|
||||||
)
|
)
|
||||||
|
|
||||||
with subtest("encryption works"):
|
with subtest("encryption works"):
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
'echo password | zpool create -O mountpoint=legacy '
|
'echo password | zpool create -O mountpoint=legacy '
|
||||||
+ "-O encryption=aes-256-gcm -O keyformat=passphrase automatic /dev/vdb1",
|
+ "-O encryption=aes-256-gcm -O keyformat=passphrase automatic /dev/vdb1",
|
||||||
"zpool create -O mountpoint=legacy manual /dev/vdc1",
|
"zpool create -O mountpoint=legacy manual /dev/vdc1",
|
||||||
"echo otherpass | zfs create "
|
"echo otherpass | zfs create "
|
||||||
+ "-o encryption=aes-256-gcm -o keyformat=passphrase manual/encrypted",
|
+ "-o encryption=aes-256-gcm -o keyformat=passphrase manual/encrypted",
|
||||||
"zfs create -o encryption=aes-256-gcm -o keyformat=passphrase "
|
"zfs create -o encryption=aes-256-gcm -o keyformat=passphrase "
|
||||||
+ "-o keylocation=http://localhost/zfskey manual/httpkey",
|
+ "-o keylocation=http://localhost/zfskey manual/httpkey",
|
||||||
"bootctl set-default nixos-generation-1-specialisation-encryption.conf",
|
"${encryption}/bin/switch-to-configuration boot",
|
||||||
"sync",
|
"sync",
|
||||||
"zpool export automatic",
|
"zpool export automatic",
|
||||||
"zpool export manual",
|
"zpool export manual",
|
||||||
)
|
)
|
||||||
machine.crash()
|
machine.crash()
|
||||||
machine.start()
|
machine.start()
|
||||||
machine.wait_for_console_text("Starting password query on")
|
machine.wait_for_console_text("Starting password query on")
|
||||||
machine.send_console("password\n")
|
machine.send_console("password\n")
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"zfs get -Ho value keystatus manual/encrypted | grep -Fx unavailable",
|
"zfs get -Ho value keystatus manual/encrypted | grep -Fx unavailable",
|
||||||
"echo otherpass | zfs load-key manual/encrypted",
|
"echo otherpass | zfs load-key manual/encrypted",
|
||||||
"systemctl start manual-encrypted.mount",
|
"systemctl start manual-encrypted.mount",
|
||||||
"zfs load-key manual/httpkey",
|
"zfs load-key manual/httpkey",
|
||||||
"systemctl start manual-httpkey.mount",
|
"systemctl start manual-httpkey.mount",
|
||||||
"umount /automatic /manual/encrypted /manual/httpkey /manual",
|
"umount /automatic /manual/encrypted /manual/httpkey /manual",
|
||||||
"zpool destroy automatic",
|
"zpool destroy automatic",
|
||||||
"zpool destroy manual",
|
"zpool destroy manual",
|
||||||
)
|
)
|
||||||
|
|
||||||
with subtest("boot.zfs.forceImportAll works"):
|
with subtest("boot.zfs.forceImportAll works"):
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"rm /etc/hostid",
|
"rm /etc/hostid",
|
||||||
"zgenhostid deadcafe",
|
"zgenhostid deadcafe",
|
||||||
"zpool create forcepool /dev/vdb1 -O mountpoint=legacy",
|
"zpool create forcepool /dev/vdb1 -O mountpoint=legacy",
|
||||||
"bootctl set-default nixos-generation-1-specialisation-forcepool.conf",
|
"${forcepool}/bin/switch-to-configuration boot",
|
||||||
"rm /etc/hostid",
|
"rm /etc/hostid",
|
||||||
"sync",
|
"sync",
|
||||||
)
|
)
|
||||||
machine.crash()
|
machine.crash()
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.fail("zpool import forcepool")
|
machine.fail("zpool import forcepool")
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"systemctl start forcepool.mount",
|
"systemctl start forcepool.mount",
|
||||||
"mount | grep forcepool",
|
"mount | grep forcepool",
|
||||||
)
|
)
|
||||||
''
|
''
|
||||||
+ extraTest;
|
+ extraTest;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user