summaryrefslogtreecommitdiffstats
path: root/test/units/TEST-64-UDEV-STORAGE.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /test/units/TEST-64-UDEV-STORAGE.sh
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtest/units/TEST-64-UDEV-STORAGE.sh (renamed from test/units/testsuite-64.sh)124
1 files changed, 97 insertions, 27 deletions
diff --git a/test/units/testsuite-64.sh b/test/units/TEST-64-UDEV-STORAGE.sh
index 65e5f6c..5ddddf5 100755
--- a/test/units/testsuite-64.sh
+++ b/test/units/TEST-64-UDEV-STORAGE.sh
@@ -148,7 +148,7 @@ check_device_units() {(
if ! check_device_unit "$log_level" "$path"; then
return 1
fi
- done < <(systemctl list-units --all --type=device --no-legend dev-* | awk '$1 !~ /dev-tty.+/ { print $1 }' | sed -e 's/\.device$//')
+ done < <(systemctl list-units --all --type=device --no-legend dev-* | awk '$1 !~ /dev-tty.+/ && $4 == "plugged" { print $1 }' | sed -e 's/\.device$//')
return 0
)}
@@ -168,7 +168,7 @@ helper_check_device_units() {(
check_device_units 1 "$@"
)}
-testcase_megasas2_basic() {
+testcase_virtio_scsi_basic() {
lsblk -S
[[ "$(lsblk --scsi --noheadings | wc -l)" -ge 128 ]]
}
@@ -239,16 +239,28 @@ testcase_nvme_subsystem() {
}
testcase_virtio_scsi_identically_named_partitions() {
- local num
+ local num_part num_disk i j
if [[ -v ASAN_OPTIONS || "$(systemd-detect-virt -v)" == "qemu" ]]; then
- num=$((4 * 4))
+ num_part=4
+ num_disk=4
else
- num=$((16 * 8))
+ num_part=8
+ num_disk=16
fi
+ for ((i = 0; i < num_disk; i++)); do
+ udevadm lock --device "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive$i" \
+ sfdisk "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive$i" <<EOF
+label: gpt
+
+$(for ((j = 1; j <= num_part; j++)); do echo 'name="Hello world", size=2M'; done)
+EOF
+ done
+
+ udevadm settle
lsblk --noheadings -a -o NAME,PARTLABEL
- [[ "$(lsblk --noheadings -a -o NAME,PARTLABEL | grep -c "Hello world")" -eq "$num" ]]
+ [[ "$(lsblk --noheadings -a -o NAME,PARTLABEL | grep -c "Hello world")" -eq "$((num_part * num_disk))" ]]
}
testcase_multipath_basic_failover() {
@@ -270,6 +282,18 @@ blacklist_exceptions {
blacklist {
}
EOF
+
+ udevadm lock --device /dev/disk/by-id/wwn-0xdeaddeadbeef0000 \
+ sfdisk /dev/disk/by-id/wwn-0xdeaddeadbeef0000 <<EOF
+label: gpt
+
+name="first_partition", size=5M
+uuid="deadbeef-dead-dead-beef-000000000000", name="failover_part", size=5M
+EOF
+ udevadm settle
+ udevadm lock --device /dev/disk/by-id/wwn-0xdeaddeadbeef0000-part2 \
+ mkfs.ext4 -U "deadbeef-dead-dead-beef-111111111111" -L "failover_vol" /dev/disk/by-id/wwn-0xdeaddeadbeef0000-part2
+
modprobe -v dm_multipath
systemctl start multipathd.service
systemctl status multipathd.service
@@ -362,7 +386,7 @@ testcase_simultaneous_events_1() {
else
num_part=10
iterations=100
- timeout=30
+ timeout=60
fi
for disk in {0..9}; do
@@ -521,9 +545,15 @@ testcase_lvm_basic() {
local i iterations partitions part timeout
local vgroup="MyTestGroup$RANDOM"
local devices=(
- /dev/disk/by-id/ata-foobar_deadbeeflvm{0..3}
+ /dev/disk/by-id/scsi-0systemd_foobar_deadbeeflvm{0..3}
)
+ . /etc/os-release
+ if [[ "$ID" == "ubuntu" ]]; then
+ echo "LVM on Ubuntu is broken, skipping the test" | tee --append /skipped
+ exit 77
+ fi
+
if [[ -v ASAN_OPTIONS || "$(systemd-detect-virt -v)" == "qemu" ]]; then
timeout=180
else
@@ -544,6 +574,7 @@ testcase_lvm_basic() {
lvm lvs
udevadm wait --settle --timeout="$timeout" "/dev/$vgroup/mypart1" "/dev/$vgroup/mypart2"
mkfs.ext4 -L mylvpart1 "/dev/$vgroup/mypart1"
+ udevadm trigger --settle "/dev/$vgroup/mypart1"
udevadm wait --settle --timeout="$timeout" "/dev/disk/by-label/mylvpart1"
helper_check_device_symlinks "/dev/disk" "/dev/$vgroup"
helper_check_device_units
@@ -599,6 +630,7 @@ testcase_lvm_basic() {
cryptsetup open --key-file=/etc/lvm_keyfile "/dev/$vgroup/mypart2" "lvmluksmap"
udevadm wait --settle --timeout="$timeout" "/dev/mapper/lvmluksmap"
mkfs.ext4 -L lvmluksfs "/dev/mapper/lvmluksmap"
+ udevadm trigger --settle "/dev/mapper/lvmluksmap"
udevadm wait --settle --timeout="$timeout" "/dev/disk/by-label/lvmluksfs"
# Make systemd "interested" in the mount by adding it to /etc/fstab
echo "/dev/disk/by-label/lvmluksfs /tmp/lvmluksmnt ext4 defaults 0 2" >>/etc/fstab
@@ -693,9 +725,14 @@ testcase_lvm_basic() {
testcase_btrfs_basic() {
local dev_stub i label mpoint uuid
local devices=(
- /dev/disk/by-id/ata-foobar_deadbeefbtrfs{0..3}
+ /dev/disk/by-id/scsi-0systemd_foobar_deadbeefbtrfs{0..3}
)
+ if ! modinfo btrfs; then
+ echo "This test requires the btrfs kernel module but it is not installed, skipping the test" | tee --append /skipped
+ exit 77
+ fi
+
ls -l "${devices[@]}"
echo "Single device: default settings"
@@ -731,10 +768,10 @@ EOF
uuid="deadbeef-dead-dead-beef-000000000002"
label="btrfs_mdisk"
udevadm lock \
- --device=/dev/disk/by-id/ata-foobar_deadbeefbtrfs0 \
- --device=/dev/disk/by-id/ata-foobar_deadbeefbtrfs1 \
- --device=/dev/disk/by-id/ata-foobar_deadbeefbtrfs2 \
- --device=/dev/disk/by-id/ata-foobar_deadbeefbtrfs3 \
+ --device=/dev/disk/by-id/scsi-0systemd_foobar_deadbeefbtrfs0 \
+ --device=/dev/disk/by-id/scsi-0systemd_foobar_deadbeefbtrfs1 \
+ --device=/dev/disk/by-id/scsi-0systemd_foobar_deadbeefbtrfs2 \
+ --device=/dev/disk/by-id/scsi-0systemd_foobar_deadbeefbtrfs3 \
mkfs.btrfs -f -M -d raid10 -m raid10 -L "$label" -U "$uuid" "${devices[@]}"
udevadm wait --settle --timeout=30 "/dev/disk/by-uuid/$uuid" "/dev/disk/by-label/$label"
btrfs filesystem show
@@ -755,9 +792,10 @@ EOF
for ((i = 0; i < ${#devices[@]}; i++)); do
# Intentionally use weaker cipher-related settings, since we don't care
# about security here as it's a throwaway LUKS partition
- cryptsetup luksFormat -q \
- --use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \
- --uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile
+ udevadm lock --device="${devices[$i]}" \
+ cryptsetup luksFormat -q \
+ --use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \
+ --uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile
udevadm wait --settle --timeout=30 "/dev/disk/by-uuid/deadbeef-dead-dead-beef-11111111111$i" "/dev/disk/by-label/encdisk$i"
# Add the device into /etc/crypttab, reload systemd, and then activate
# the device so we can create a filesystem on it later
@@ -824,14 +862,28 @@ testcase_iscsi_lvm() {
local vgroup="iscsi_lvm$RANDOM"
local expected_symlinks=()
local devices=(
- /dev/disk/by-id/ata-foobar_deadbeefiscsi{0..3}
+ /dev/disk/by-id/scsi-0systemd_foobar_deadbeefiscsi{0..3}
)
+ . /etc/os-release
+ if [[ "$ID" == "ubuntu" ]]; then
+ echo "LVM on Ubuntu is broken, skipping the test" | tee --append /skipped
+ exit 77
+ fi
+
ls -l "${devices[@]}"
- # Start the target daemon
- systemctl start tgtd
- systemctl status tgtd
+ # Start the target daemon (debian names it tgt.service so make sure we handle that)
+ if systemctl list-unit-files tgt.service; then
+ systemctl start tgt
+ systemctl status tgt
+ elif systemctl list-unit-files tgtd.service; then
+ systemctl start tgtd
+ systemctl status tgtd
+ else
+ echo "This test requires tgtd but it is not installed, skipping ..." | tee --append /skipped
+ exit 77
+ fi
echo "iSCSI LUNs backed by devices"
# See RFC3721 and RFC7143
@@ -867,7 +919,7 @@ testcase_iscsi_lvm() {
mpoint="$(mktemp -d /iscsi_storeXXX)"
expected_symlinks=()
# Use the first device as it's configured with larger capacity
- mkfs.ext4 -L iscsi_store "${devices[0]}"
+ udevadm lock --device "${devices[0]}" mkfs.ext4 -L iscsi_store "${devices[0]}"
udevadm wait --settle --timeout=30 "${devices[0]}"
mount "${devices[0]}" "$mpoint"
for i in {1..4}; do
@@ -903,6 +955,7 @@ testcase_iscsi_lvm() {
lvm lvs
udevadm wait --settle --timeout=30 "/dev/$vgroup/mypart1" "/dev/$vgroup/mypart2"
mkfs.ext4 -L mylvpart1 "/dev/$vgroup/mypart1"
+ udevadm trigger --settle "/dev/$vgroup/mypart1"
udevadm wait --settle --timeout=30 "/dev/disk/by-label/mylvpart1"
helper_check_device_symlinks "/dev/disk" "/dev/$vgroup"
helper_check_device_units
@@ -950,6 +1003,16 @@ testcase_long_sysfs_path() {
stat /sys/block/vda
readlink -f /sys/block/vda/dev
+ dev="/dev/vda"
+ udevadm lock --device "$dev" sfdisk "$dev" <<EOF
+label: gpt
+
+name="test_swap", size=32M
+uuid="deadbeef-dead-dead-beef-000000000000", name="test_part", size=5M
+EOF
+ udevadm settle
+ udevadm lock --device "${dev}1" mkswap -U "deadbeef-dead-dead-beef-111111111111" -L "swap_vol" "${dev}1"
+ udevadm lock --device "${dev}2" mkfs.ext4 -U "deadbeef-dead-dead-beef-222222222222" -L "data_vol" "${dev}2"
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
# Try to mount the data partition manually (using its label)
@@ -992,7 +1055,7 @@ testcase_mdadm_basic() {
local i part_name raid_name raid_dev uuid
local expected_symlinks=()
local devices=(
- /dev/disk/by-id/ata-foobar_deadbeefmdadm{0..4}
+ /dev/disk/by-id/scsi-0systemd_foobar_deadbeefmdadm{0..4}
)
ls -l "${devices[@]}"
@@ -1009,9 +1072,11 @@ testcase_mdadm_basic() {
"/dev/disk/by-label/$part_name" # ext4 partition
)
# Create a simple RAID 1 with an ext4 filesystem
- 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
+ echo y | mdadm --create "$raid_dev" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/scsi-0systemd_foobar_deadbeefmdadm{0..1} -v -f --level=1 --raid-devices=2
udevadm wait --settle --timeout=30 "$raid_dev"
+ # udevd does not lock md devices, hence we need to trigger uevent after creating filesystem.
mkfs.ext4 -L "$part_name" "$raid_dev"
+ udevadm trigger --settle "$raid_dev"
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
for i in {0..9}; do
echo "Disassemble - reassemble loop, iteration #$i"
@@ -1038,9 +1103,10 @@ testcase_mdadm_basic() {
"/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
+ echo y | mdadm --create "$raid_dev" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/scsi-0systemd_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 trigger --settle "$raid_dev"
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
for i in {0..9}; do
echo "Disassemble - reassemble loop, iteration #$i"
@@ -1078,10 +1144,11 @@ testcase_mdadm_basic() {
"/dev/disk/by-id/md-uuid-$uuid-part3"
)
# 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
+ echo y | mdadm --create "$raid_dev" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/scsi-0systemd_foobar_deadbeefmdadm{0..3} -v -f --level=10 --raid-devices=4
udevadm wait --settle --timeout=30 "$raid_dev"
# Partition the raid device
# Here, 'udevadm lock' is meaningless, as udevd does not lock MD devices.
+ # We need to trigger uevents after sfdisk and mkfs.
sfdisk --wipe=always "$raid_dev" <<EOF
label: gpt
@@ -1089,8 +1156,10 @@ uuid="deadbeef-dead-dead-beef-111111111111", name="mdpart1", size=8M
uuid="deadbeef-dead-dead-beef-222222222222", name="mdpart2", size=32M
uuid="deadbeef-dead-dead-beef-333333333333", name="mdpart3", size=16M
EOF
+ udevadm trigger --settle --parent-match "$raid_dev"
udevadm wait --settle --timeout=30 "/dev/disk/by-id/md-uuid-$uuid-part2"
mkfs.ext4 -L "$part_name" "/dev/disk/by-id/md-uuid-$uuid-part2"
+ udevadm trigger --settle "/dev/disk/by-id/md-uuid-$uuid-part2"
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
for i in {0..9}; do
echo "Disassemble - reassemble loop, iteration #$i"
@@ -1112,7 +1181,7 @@ 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}
+ /dev/disk/by-id/scsi-0systemd_foobar_deadbeefmdadmlvm{0..4}
)
ls -l "${devices[@]}"
@@ -1131,7 +1200,7 @@ testcase_mdadm_lvm() {
"/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
+ echo y | mdadm --create "$raid_dev" --name "$raid_name" --uuid "$uuid" /dev/disk/by-id/scsi-0systemd_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"
@@ -1144,6 +1213,7 @@ testcase_mdadm_lvm() {
lvm lvs
udevadm wait --settle --timeout=30 "/dev/$vgroup/mypart1" "/dev/$vgroup/mypart2"
mkfs.ext4 -L "$part_name" "/dev/$vgroup/mypart2"
+ udevadm trigger --settle "/dev/$vgroup/mypart2"
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
# Disassemble the array
lvm vgchange -an "$vgroup"