diff options
author | Graham Christensen <graham@grahamc.com> | 2022-04-07 14:29:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-07 14:29:29 -0400 |
commit | 3a2c2dc3e8f0a20e3ae66f58af23c48bbd360309 (patch) | |
tree | ab0ba942742da116da903fcc619c15b87a3d721f /nixos/tests | |
parent | 4a514c8baeacfc21dd278a8d42e6a8dbbd9bc7af (diff) | |
parent | 3f992e25f131f4a6ce83efddcec6297e683adcc2 (diff) |
Merge pull request #166130 from DeterminateSystems/zpool-expand
zpool-auto-expand-partitions: init at 0.1.0, update auto-expand service
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) + ''; + }; } |