diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-04-14 12:54:16 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-04-14 12:54:16 +0200 |
commit | d3ce9bed6869618fc3c2cd963f0ad7babb43bbaa (patch) | |
tree | c080eaa110775a2025c93f9e1c2be57d88cb5972 /test | |
parent | test: extend testcase_mdadm_basic() with RAID 5 and 10 (diff) | |
download | systemd-d3ce9bed6869618fc3c2cd963f0ad7babb43bbaa.tar.xz systemd-d3ce9bed6869618fc3c2cd963f0ad7babb43bbaa.zip |
test: add a test case for MD + LVM + ext4
Diffstat (limited to 'test')
-rwxr-xr-x | test/TEST-64-UDEV-STORAGE/test.sh | 25 | ||||
-rwxr-xr-x | test/units/testsuite-64.sh | 50 |
2 files changed, 74 insertions, 1 deletions
diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index 0e684e01a0..d2660d3951 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -474,6 +474,31 @@ testcase_mdadm_basic() { rm -f "${TESTDIR:?}"/mdadmbasic*.img } +testcase_mdadm_lvm() { + if ! _host_has_feature "mdadm" || ! _host_has_feature "lvm"; then + echo "Missing mdadm tools/modules or LVM tools, skipping the test..." + return 77 + fi + + local qemu_opts=("-device ahci,id=ahci0") + local diskpath i size + + for i in {0..4}; do + diskpath="${TESTDIR:?}/mdadmlvm${i}.img" + + dd if=/dev/zero of="$diskpath" bs=1M count=64 + qemu_opts+=( + "-device ide-hd,bus=ahci0.$i,drive=drive$i,model=foobar,serial=deadbeefmdadmlvm$i" + "-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i" + ) + done + + KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" + QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" + test_run_one "${1:?}" || return $? + + rm -f "${TESTDIR:?}"/mdadmlvm*.img +} # Allow overriding which tests should be run from the "outside", useful for manual # testing (make -C test/... TESTCASES="testcase1 testcase2") if [[ -v "TESTCASES" && -n "$TESTCASES" ]]; then diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index cd259f2ef0..cc016a774c 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -620,7 +620,55 @@ testcase_mdadm_basic() { mdadm -v --stop "$raid_dev" udevadm settle helper_check_device_symlinks - # Reassemble it and check if all requires symlinks exist + # Reassemble it and check if all required symlinks exist + mdadm --assemble "$raid_dev" --name "$raid_name" -v + udevadm wait --settle --timeout=30 "${expected_symlinks[@]}" + helper_check_device_symlinks +} + +testcase_mdadm_lvm() { + local part_name raid_name raid_dev uuid vgroup + local expected_symlinks=() + local devices=( + /dev/disk/by-id/ata-foobar_deadbeefmdadmlvm{0..4} + ) + + ls -l "${devices[@]}" + + raid_name="mdlvm" + raid_dev="/dev/md/$raid_name" + part_name="${raid_name}_part" + vgroup="${raid_name}_vg" + uuid="aaaaaaaa:bbbbbbbb:ffffffff:00001010" + expected_symlinks=( + "$raid_dev" + "/dev/$vgroup/mypart1" # LVM partition + "/dev/$vgroup/mypart2" # LVM partition + "/dev/disk/by-id/md-name-H:$raid_name" + "/dev/disk/by-id/md-uuid-$uuid" + "/dev/disk/by-label/$part_name" # ext4 partition + ) + # Create a RAID 10 with LVM + ext4 + echo y | mdadm --create "$raid_dev" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/ata-foobar_deadbeefmdadmlvm{0..3} -v -f --level=10 --raid-devices=4 + udevadm wait --settle --timeout=30 "$raid_dev" + # Create an LVM on the MD + lvm pvcreate -y "$raid_dev" + lvm pvs + lvm vgcreate "$vgroup" -y "$raid_dev" + lvm vgs + lvm vgchange -ay "$vgroup" + lvm lvcreate -y -L 4M "$vgroup" -n mypart1 + lvm lvcreate -y -L 8M "$vgroup" -n mypart2 + lvm lvs + udevadm wait --settle --timeout=30 "/dev/$vgroup/mypart1" "/dev/$vgroup/mypart2" + mkfs.ext4 -L "$part_name" "/dev/$vgroup/mypart2" + udevadm wait --settle --timeout=30 "${expected_symlinks[@]}" + # Disassemble the array + lvm vgchange -an "$vgroup" + mdadm -v --stop "$raid_dev" + udevadm settle + helper_check_device_symlinks + # Reassemble it and check if all required symlinks exist mdadm --assemble "$raid_dev" --name "$raid_name" -v udevadm wait --settle --timeout=30 "${expected_symlinks[@]}" helper_check_device_symlinks |