diff options
author | Graham Christensen <graham@grahamc.com> | 2022-04-07 13:03:47 -0400 |
---|---|---|
committer | Graham Christensen <graham@grahamc.com> | 2022-04-07 13:06:57 -0400 |
commit | 3f992e25f131f4a6ce83efddcec6297e683adcc2 (patch) | |
tree | 14c06a0efc174a882b9c04c4b4c98717d7030c08 /nixos/tests | |
parent | bd3e9c3d051f77338b38ea44cc28cfc465923f41 (diff) |
services.zfs.expandOnBoot: Test that it works
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/zfs.nix | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/nixos/tests/zfs.nix b/nixos/tests/zfs.nix index bf0165b88162d..0b44961a3deb5 100644 --- a/nixos/tests/zfs.nix +++ b/nixos/tests/zfs.nix @@ -127,4 +127,54 @@ in { }; installer = (import ./installer.nix { }).zfsroot; + + expand-partitions = makeTest { + name = "multi-disk-zfs"; + nodes = { + machine = { pkgs, ... }: { + environment.systemPackages = [ pkgs.parted ]; + boot.supportedFilesystems = [ "zfs" ]; + networking.hostId = "00000000"; + + virtualisation = { + emptyDiskImages = [ 20480 20480 20480 20480 20480 20480 ]; + }; + + specialisation.resize.configuration = { + services.zfs.expandOnBoot = [ "tank" ]; + }; + }; + }; + + testScript = { nodes, ... }: + '' + start_all() + machine.wait_for_unit("default.target") + print(machine.succeed('mount')) + + print(machine.succeed('parted --script /dev/vdb -- mklabel gpt')) + print(machine.succeed('parted --script /dev/vdb -- mkpart primary 1M 70M')) + + print(machine.succeed('parted --script /dev/vdc -- mklabel gpt')) + print(machine.succeed('parted --script /dev/vdc -- mkpart primary 1M 70M')) + + print(machine.succeed('zpool create tank mirror /dev/vdb1 /dev/vdc1 mirror /dev/vdd /dev/vde mirror /dev/vdf /dev/vdg')) + print(machine.succeed('zpool list -v')) + print(machine.succeed('mount')) + start_size = int(machine.succeed('df -k --output=size /tank | tail -n1').strip()) + + print(machine.succeed("/run/current-system/specialisation/resize/bin/switch-to-configuration test >&2")) + machine.wait_for_unit("zpool-expand-pools.service") + machine.wait_for_unit("zpool-expand@tank.service") + + print(machine.succeed('zpool list -v')) + new_size = int(machine.succeed('df -k --output=size /tank | tail -n1').strip()) + + if (new_size - start_size) > 20000000: + print("Disk grew appropriately.") + else: + print(f"Disk went from {start_size} to {new_size}, which doesn't seem right.") + exit(1) + ''; + }; } |