nixosTests.systemd-initrd-swraid: test RAID auto-detection

I implemented this to verify whether or not #210210 was still an issue
and it turns out it had already been fixed. After a lot of investigating
I figured out that it was unintentionally fixed by #333643.

I tested this by duplicating this commit on top of the commit before
that PR and the commit after that PR to verify that PR actually fixed
the issue.
This commit is contained in:
Michael Hoang
2026-05-08 00:29:01 +02:00
parent ed67bc86e8
commit 23e5c76c19
+6 -11
View File
@@ -23,12 +23,7 @@
mdadm
e2fsprogs
]; # for mdadm and mkfs.ext4
boot.swraid = {
enable = true;
mdadmConf = ''
ARRAY /dev/md0 devices=/dev/vdb,/dev/vdc
'';
};
boot.swraid.enable = true;
environment.etc."mdadm.conf".text = ''
MAILADDR test@example.com
'';
@@ -64,12 +59,12 @@
assert "hello" in machine.succeed("cat /test")
assert "md0" in machine.succeed("cat /proc/mdstat")
expected_config = """MAILADDR test@example.com
# 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}"
ARRAY /dev/md0 devices=/dev/vdb,/dev/vdc
"""
got_config = machine.execute("cat /etc/mdadm.conf")[1]
assert expected_config == got_config, repr((expected_config, got_config))
machine.wait_for_unit("mdmonitor.service")
'';
}