mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
test: add a test case for MD + LVM + ext4
This commit is contained in:
parent
1bb3887595
commit
d3ce9bed68
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue