diff --git a/nixos/tests/systemd-initrd-swraid.nix b/nixos/tests/systemd-initrd-swraid.nix index 997235ecfcd1..01fc9141997e 100644 --- a/nixos/tests/systemd-initrd-swraid.nix +++ b/nixos/tests/systemd-initrd-swraid.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, ... }: +{ lib, ... }: { name = "systemd-initrd-swraid"; @@ -41,30 +41,36 @@ specialisation.build-old-initrd.configuration.boot.initrd.systemd.enable = lib.mkForce false; }; - testScript = '' - # Create RAID - machine.succeed("mdadm --create --force /dev/md0 -n 2 --level=raid1 /dev/vdb /dev/vdc --metadata=0.90 --bitmap=internal") - machine.succeed("mkfs.ext4 -L testraid /dev/md0") - machine.succeed("mkdir -p /mnt && mount /dev/md0 /mnt && echo hello > /mnt/test && umount /mnt") + testScript = + { nodes, ... }: + let + boot-swraid = nodes.machine.specialisation.boot-swraid.configuration.system.build.toplevel; + in + # python + '' + # Create RAID + machine.succeed("mdadm --create --force /dev/md0 -n 2 --level=raid1 /dev/vdb /dev/vdc --metadata=0.90 --bitmap=internal") + machine.succeed("mkfs.ext4 -L testraid /dev/md0") + machine.succeed("mkdir -p /mnt && mount /dev/md0 /mnt && echo hello > /mnt/test && umount /mnt") - # Boot from the RAID - machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-swraid.conf") - machine.succeed("sync") - machine.crash() - machine.wait_for_unit("multi-user.target") + # Boot from the RAID + machine.succeed("${boot-swraid}/bin/switch-to-configuration boot") + machine.succeed("sync") + machine.crash() + machine.wait_for_unit("multi-user.target") - # Ensure we have successfully booted from the RAID - assert "(initrd)" in machine.succeed("systemd-analyze") # booted with systemd in stage 1 - assert "/dev/md0 on / type ext4" in machine.succeed("mount") - assert "hello" in machine.succeed("cat /test") - assert "md0" in machine.succeed("cat /proc/mdstat") + # Ensure we have successfully booted from the RAID + assert "(initrd)" in machine.succeed("systemd-analyze") # booted with systemd in stage 1 + assert "/dev/md0 on / type ext4" in machine.succeed("mount") + assert "hello" in machine.succeed("cat /test") + assert "md0" in machine.succeed("cat /proc/mdstat") - # Verify the RAID array was properly auto-detected and assembled - detail = machine.succeed("mdadm --detail /dev/md0") - assert "raid1" in detail, f"Expected raid1 in mdadm detail output: {detail}" - assert "/dev/vdb" in detail, f"Expected /dev/vdb in array: {detail}" - assert "/dev/vdc" in detail, f"Expected /dev/vdc in array: {detail}" + # Verify the RAID array was properly auto-detected and assembled + detail = machine.succeed("mdadm --detail /dev/md0") + assert "raid1" in detail, f"Expected raid1 in mdadm detail output: {detail}" + assert "/dev/vdb" in detail, f"Expected /dev/vdb in array: {detail}" + assert "/dev/vdc" in detail, f"Expected /dev/vdc in array: {detail}" - machine.wait_for_unit("mdmonitor.service") - ''; + machine.wait_for_unit("mdmonitor.service") + ''; }