mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
Merge pull request #23081 from mrc0mmand/more-md-tests
test: extend the MD coverage with more RAID levels and LVM
This commit is contained in:
commit
c905eb45de
@ -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
|
||||
|
@ -536,7 +536,7 @@ testcase_long_sysfs_path() {
|
||||
}
|
||||
|
||||
testcase_mdadm_basic() {
|
||||
local raid_name uuid
|
||||
local part_name raid_name raid_dev uuid
|
||||
local expected_symlinks=()
|
||||
local devices=(
|
||||
/dev/disk/by-id/ata-foobar_deadbeefmdadm{0..4}
|
||||
@ -544,26 +544,132 @@ testcase_mdadm_basic() {
|
||||
|
||||
ls -l "${devices[@]}"
|
||||
|
||||
echo "Mirror raid"
|
||||
echo "Mirror raid (RAID 1)"
|
||||
raid_name="mdmirror"
|
||||
raid_dev="/dev/md/$raid_name"
|
||||
part_name="${raid_name}_part"
|
||||
uuid="aaaaaaaa:bbbbbbbb:cccccccc:00000001"
|
||||
expected_symlinks=(
|
||||
"/dev/md/$raid_name"
|
||||
"/dev/disk/by-id/md-name-H:mdmirror"
|
||||
"$raid_dev"
|
||||
"/dev/disk/by-id/md-name-H:$raid_name"
|
||||
"/dev/disk/by-id/md-uuid-$uuid"
|
||||
"/dev/disk/by-label/mdadm_mirror" # ext4 partition
|
||||
"/dev/disk/by-label/$part_name" # ext4 partition
|
||||
)
|
||||
# Create a simple RAID 1 with an ext4 filesystem
|
||||
echo y | mdadm --create "${expected_symlinks[0]}" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/ata-foobar_deadbeefmdadm{0..1} -v -f --level=1 --raid-devices=2
|
||||
udevadm wait --settle --timeout=30 "${expected_symlinks[0]}"
|
||||
mkfs.ext4 -L mdadm_mirror "/dev/md/$raid_name"
|
||||
echo y | mdadm --create "$raid_dev" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/ata-foobar_deadbeefmdadm{0..1} -v -f --level=1 --raid-devices=2
|
||||
udevadm wait --settle --timeout=30 "$raid_dev"
|
||||
mkfs.ext4 -L "$part_name" "$raid_dev"
|
||||
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
|
||||
# Disassemble the array
|
||||
mdadm -v --stop "${expected_symlinks[0]}"
|
||||
mdadm -v --stop "$raid_dev"
|
||||
udevadm settle
|
||||
helper_check_device_symlinks
|
||||
# Reassemble it and check if all requires symlinks exist
|
||||
mdadm --assemble "${expected_symlinks[0]}" --name "$raid_name" -v
|
||||
# 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
|
||||
# Cleanup
|
||||
mdadm -v --stop "$raid_dev"
|
||||
udevadm settle
|
||||
|
||||
echo "Parity raid (RAID 5)"
|
||||
raid_name="mdparity"
|
||||
raid_dev="/dev/md/$raid_name"
|
||||
part_name="${raid_name}_part"
|
||||
uuid="aaaaaaaa:bbbbbbbb:cccccccc:00000101"
|
||||
expected_symlinks=(
|
||||
"$raid_dev"
|
||||
"/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 simple RAID 5 with an ext4 filesystem
|
||||
echo y | mdadm --create "$raid_dev" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/ata-foobar_deadbeefmdadm{0..2} -v -f --level=5 --raid-devices=3
|
||||
udevadm wait --settle --timeout=30 "$raid_dev"
|
||||
mkfs.ext4 -L "$part_name" "$raid_dev"
|
||||
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
|
||||
# Disassemble the array
|
||||
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
|
||||
# Cleanup
|
||||
mdadm -v --stop "$raid_dev"
|
||||
udevadm settle
|
||||
|
||||
echo "Mirror + parity raid (RAID 10)"
|
||||
raid_name="mdmirpar"
|
||||
raid_dev="/dev/md/$raid_name"
|
||||
part_name="${raid_name}_part"
|
||||
uuid="aaaaaaaa:bbbbbbbb:cccccccc:00001010"
|
||||
expected_symlinks=(
|
||||
"$raid_dev"
|
||||
"/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 simple RAID 10 with an ext4 filesystem
|
||||
echo y | mdadm --create "$raid_dev" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/ata-foobar_deadbeefmdadm{0..3} -v -f --level=10 --raid-devices=4
|
||||
udevadm wait --settle --timeout=30 "$raid_dev"
|
||||
mkfs.ext4 -L "$part_name" "$raid_dev"
|
||||
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
|
||||
# Disassemble the array
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user