Skip to content

Commit b80ee08

Browse files
committed
ci: use /dev/disk/by-id
Due to parallel probing of the linux kernel `/dev/sd*` can't be used to reliably address a hard disk. This can be seen by the many spurious failures of the dracut CI, where `mdadm` failed with error 524 or tests failed due to the success marker message written to the wrong disk. * don't rely on `/dev/sd*` but use disk ids and `/dev/disk/by-id/ata-disk_<name>` * specify the exact qemu machine architecture `-M q35` needed for the disk ids. A later patch will move this to `run-qemu`, when all tests are converted * due to `-M q35` the interface names have changed from `ens2` -> `enp0s1` and `ens3` -> `enp0s2`
1 parent 5912f4f commit b80ee08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+918
-840
lines changed

test/TEST-01-BASIC/99-idesymlinks.rules

-8
This file was deleted.

test/TEST-01-BASIC/create-root.sh

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
#!/bin/sh
2+
3+
trap 'poweroff -f' EXIT
4+
25
# don't let udev and this script step on eachother's toes
36
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
47
: > "/etc/udev/rules.d/$x"
58
done
69
rm -f -- /etc/lvm/lvm.conf
710
udevadm control --reload
8-
set -e
9-
# save a partition at the beginning for future flagging purposes
10-
sfdisk /dev/sda << EOF
11-
,1M
12-
,
13-
EOF
14-
1511
udevadm settle
16-
mkfs.ext3 -L ' rdinit=/bin/sh' /dev/sda2
12+
13+
set -ex
14+
15+
mkfs.ext3 -L ' rdinit=/bin/sh' /dev/disk/by-id/ata-disk_root
1716
mkdir -p /root
18-
mount /dev/sda2 /root
17+
mount /dev/disk/by-id/ata-disk_root /root
1918
cp -a -t /root /source/*
2019
mkdir -p /root/run
2120
umount /root
22-
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
23-
sync
21+
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
2422
poweroff -f

test/TEST-01-BASIC/test-init.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export PATH=/sbin:/bin:/usr/sbin:/usr/bin
77
command -v plymouth > /dev/null 2>&1 && plymouth --quit
88
exec > /dev/console 2>&1
99

10-
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdb
10+
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
11+
1112
export TERM=linux
1213
export PS1='initramfs-test:\w\$ '
1314
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
@@ -20,5 +21,4 @@ if getargbool 0 rd.shell; then
2021
fi
2122
echo "Powering down."
2223
mount -n -o remount,ro /
23-
sync
2424
poweroff -f

test/TEST-01-BASIC/test.sh

+22-13
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ KVERSION=${KVERSION-$(uname -r)}
88
# DEBUGFAIL="rd.shell rd.break"
99

1010
test_run() {
11-
dd if=/dev/zero of="$TESTDIR"/result bs=1M count=1
11+
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
12+
declare -a disk_args=()
13+
# shellcheck disable=SC2034
14+
declare -i disk_index=0
15+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
16+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root
17+
1218
"$testdir"/run-qemu \
13-
-drive format=raw,index=0,media=disk,file="$TESTDIR"/root.ext3 \
14-
-drive format=raw,index=1,media=disk,file="$TESTDIR"/result \
19+
"${disk_args[@]}" \
1520
-watchdog i6300esb -watchdog-action poweroff \
1621
-append "panic=1 systemd.crash_reboot \"root=LABEL= rdinit=/bin/sh\" rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL" \
1722
-initrd "$TESTDIR"/initramfs.testing || return 1
18-
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success "$TESTDIR"/result || return 1
23+
24+
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success "$TESTDIR"/marker.img
1925
}
2026

2127
test_setup() {
22-
rm -f -- "$TESTDIR"/root.ext3
23-
# Create the blank file to use as a root filesystem
24-
dd if=/dev/zero of="$TESTDIR"/root.ext3 bs=1M count=80
25-
2628
kernel=$KVERSION
2729
# Create what will eventually be our root filesystem onto an overlay
2830
(
@@ -72,7 +74,6 @@ test_setup() {
7274
inst_multiple sfdisk mkfs.ext3 poweroff cp umount sync dd
7375
inst_hook initqueue 01 ./create-root.sh
7476
inst_hook initqueue/finished 01 ./finished-false.sh
75-
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
7677
)
7778

7879
# create an initramfs that will create the target root filesystem.
@@ -85,13 +86,22 @@ test_setup() {
8586
--no-hostonly-cmdline -N \
8687
-f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1
8788
rm -rf -- "$TESTDIR"/overlay
88-
# Invoke KVM and/or QEMU to actually create the target filesystem.
8989

90+
dd if=/dev/zero of="$TESTDIR"/root.img bs=1MiB count=80
91+
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
92+
declare -a disk_args=()
93+
# shellcheck disable=SC2034
94+
declare -i disk_index=0
95+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
96+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root
97+
98+
# Invoke KVM and/or QEMU to actually create the target filesystem.
9099
"$testdir"/run-qemu \
91-
-drive format=raw,index=0,media=disk,file="$TESTDIR"/root.ext3 \
100+
"${disk_args[@]}" \
92101
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
93102
-initrd "$TESTDIR"/initramfs.makeroot || return 1
94-
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created "$TESTDIR"/root.ext3 || return 1
103+
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created "$TESTDIR"/marker.img || return 1
104+
rm -- "$TESTDIR"/marker.img
95105

96106
(
97107
# shellcheck disable=SC2031
@@ -101,7 +111,6 @@ test_setup() {
101111
inst_multiple poweroff shutdown dd
102112
inst_hook shutdown-emergency 000 ./hard-off.sh
103113
inst_hook emergency 000 ./hard-off.sh
104-
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
105114
)
106115
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
107116
-a "debug watchdog" \

test/TEST-02-SYSTEMD/99-idesymlinks.rules

-8
This file was deleted.

test/TEST-02-SYSTEMD/create-root.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
#!/bin/sh
2+
3+
trap 'poweroff -f' EXIT
4+
25
# don't let udev and this script step on eachother's toes
36
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
47
: > "/etc/udev/rules.d/$x"
58
done
69
rm -f -- /etc/lvm/lvm.conf
710
udevadm control --reload
811
set -e
9-
# save a partition at the beginning for future flagging purposes
10-
sfdisk /dev/sda << EOF
11-
,1M
12-
,
13-
EOF
1412

1513
udevadm settle
16-
mkfs.ext3 -L dracut /dev/sda2
14+
mkfs.ext3 -L dracut /dev/disk/by-id/ata-disk_root
1715
mkdir -p /root
18-
mount /dev/sda2 /root
16+
mount /dev/disk/by-id/ata-disk_root /root
1917
cp -a -t /root /source/*
2018
mkdir -p /root/run
2119
umount /root
22-
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
20+
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
2321
poweroff -f

test/TEST-02-SYSTEMD/test-init.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/bin/sh
2+
: > /dev/watchdog
3+
24
. /lib/dracut-lib.sh
35

46
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
57
command -v plymouth > /dev/null 2>&1 && plymouth --quit
68
exec > /dev/console 2>&1
79

8-
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
10+
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
11+
912
export TERM=linux
1013
export PS1='initramfs-test:\w\$ '
1114
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
@@ -18,5 +21,4 @@ if getargbool 0 rd.shell; then
1821
fi
1922
echo "Powering down."
2023
mount -n -o remount,ro /
21-
sync
2224
poweroff -f

test/TEST-02-SYSTEMD/test.sh

+23-12
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ KVERSION="${KVERSION-$(uname -r)}"
77
# Uncomment this to debug failures
88
#DEBUGFAIL="rd.shell=1 rd.break=pre-mount"
99
test_run() {
10+
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
11+
declare -a disk_args=()
12+
# shellcheck disable=SC2034
13+
declare -i disk_index=0
14+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
15+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root
16+
1017
"$testdir"/run-qemu \
11-
-drive format=raw,index=0,media=disk,file="$TESTDIR"/root.ext3 \
18+
"${disk_args[@]}" \
1219
-append "panic=1 systemd.crash_reboot root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.shell=0 $DEBUGFAIL" \
13-
-initrd "$TESTDIR"/initramfs.testing
14-
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success "$TESTDIR"/root.ext3 || return 1
20+
-initrd "$TESTDIR"/initramfs.testing || return 1
21+
22+
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-success "$TESTDIR"/marker.img
1523
}
1624

1725
test_setup() {
18-
rm -f -- "$TESTDIR"/root.ext3
19-
# Create the blank file to use as a root filesystem
20-
dd if=/dev/zero of="$TESTDIR"/root.ext3 bs=1M count=80
21-
2226
kernel=$KVERSION
2327
# Create what will eventually be our root filesystem onto an overlay
2428
(
@@ -69,7 +73,6 @@ test_setup() {
6973
inst_multiple sfdisk mkfs.ext3 poweroff cp umount dd
7074
inst_hook initqueue 01 ./create-root.sh
7175
inst_hook initqueue/finished 01 ./finished-false.sh
72-
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
7376
)
7477

7578
# create an initramfs that will create the target root filesystem.
@@ -82,13 +85,22 @@ test_setup() {
8285
--no-hostonly-cmdline -N \
8386
-f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1
8487
rm -rf -- "$TESTDIR"/overlay
85-
# Invoke KVM and/or QEMU to actually create the target filesystem.
8688

89+
dd if=/dev/zero of="$TESTDIR"/root.img bs=1MiB count=80
90+
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
91+
declare -a disk_args=()
92+
# shellcheck disable=SC2034
93+
declare -i disk_index=0
94+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
95+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root
96+
97+
# Invoke KVM and/or QEMU to actually create the target filesystem.
8798
"$testdir"/run-qemu \
88-
-drive format=raw,index=0,media=disk,file="$TESTDIR"/root.ext3 \
99+
"${disk_args[@]}" \
89100
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
90101
-initrd "$TESTDIR"/initramfs.makeroot || return 1
91-
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created "$TESTDIR"/root.ext3 || return 1
102+
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created "$TESTDIR"/marker.img || return 1
103+
rm -- "$TESTDIR"/marker.img
92104

93105
(
94106
# shellcheck disable=SC2031
@@ -99,7 +111,6 @@ test_setup() {
99111
inst_hook shutdown-emergency 000 ./hard-off.sh
100112
inst_hook pre-pivot 000 ./systemd-analyze.sh
101113
inst_hook emergency 000 ./hard-off.sh
102-
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
103114
)
104115
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
105116
-a "debug systemd" \

test/TEST-03-USR-MOUNT/99-idesymlinks.rules

-8
This file was deleted.

test/TEST-03-USR-MOUNT/create-root.sh

+11-22
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
11
#!/bin/sh
2+
3+
trap 'poweroff -f' EXIT
4+
25
# don't let udev and this script step on eachother's toes
3-
set -x
46
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
57
: > "/etc/udev/rules.d/$x"
68
done
79
rm -f -- /etc/lvm/lvm.conf
810
udevadm control --reload
9-
udevadm settle
1011
set -e
11-
# save a partition at the beginning for future flagging purposes
12-
sfdisk /dev/sda << EOF
13-
,1M
14-
,
15-
EOF
16-
17-
sfdisk /dev/sdb << EOF
18-
,1M
19-
,
20-
EOF
2112

2213
udevadm settle
2314
modprobe btrfs
24-
mkfs.btrfs -L dracut /dev/sda2
25-
mkfs.btrfs -L dracutusr /dev/sdb2
26-
btrfs device scan /dev/sda2
27-
btrfs device scan /dev/sdb2
15+
mkfs.btrfs -L dracut /dev/disk/by-id/ata-disk_root
16+
mkfs.btrfs -L dracutusr /dev/disk/by-id/ata-disk_usr
17+
btrfs device scan /dev/disk/by-id/ata-disk_root
18+
btrfs device scan /dev/disk/by-id/ata-disk_usr
2819
mkdir -p /root
29-
mount -t btrfs /dev/sda2 /root
20+
mount -t btrfs /dev/disk/by-id/ata-disk_root /root
3021
[ -d /root/usr ] || mkdir -p /root/usr
31-
mount -t btrfs /dev/sdb2 /root/usr
22+
mount -t btrfs /dev/disk/by-id/ata-disk_usr /root/usr
3223
btrfs subvolume create /root/usr/usr
3324
umount /root/usr
34-
mount -t btrfs -o subvol=usr /dev/sdb2 /root/usr
25+
mount -t btrfs -o subvol=usr /dev/disk/by-id/ata-disk_usr /root/usr
3526
cp -a -t /root /source/*
3627
mkdir -p /root/run
3728
btrfs filesystem sync /root/usr
3829
btrfs filesystem sync /root
3930
umount /root/usr
4031
umount /root
41-
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
42-
udevadm settle
43-
sync
32+
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
4433
poweroff -f

test/TEST-03-USR-MOUNT/fstab

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/dev/sda2 / btrfs defaults 0 0
2-
/dev/sdb2 /usr btrfs subvol=usr,ro 0 0
1+
/dev/disk/by-id/ata-disk_root / btrfs defaults 0 0
2+
/dev/disk/by-id/ata-disk_usr /usr btrfs subvol=usr,ro 0 0

test/TEST-03-USR-MOUNT/test-init.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/sh
2-
32
: > /dev/watchdog
43

54
. /lib/dracut-lib.sh
@@ -8,9 +7,8 @@ export PATH=/sbin:/bin:/usr/sbin:/usr/bin
87
command -v plymouth > /dev/null 2>&1 && plymouth --quit
98
exec > /dev/console 2>&1
109

11-
if ismounted /usr; then
12-
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdc
13-
fi
10+
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
11+
1412
export TERM=linux
1513
export PS1='initramfs-test:\w\$ '
1614
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
@@ -23,5 +21,4 @@ if getargbool 0 rd.shell; then
2321
fi
2422
echo "Powering down."
2523
mount -n -o remount,ro /
26-
sync
2724
poweroff -f

0 commit comments

Comments
 (0)