diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 13:54:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 13:54:25 +0000 |
commit | 9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a (patch) | |
tree | 2efb72864cc69e174c9c5ee33efb88a5f1553b48 /test/TEST-35-ISCSI-MULTI | |
parent | Initial commit. (diff) | |
download | dracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.tar.xz dracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.zip |
Adding upstream version 060+5.upstream/060+5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | test/TEST-35-ISCSI-MULTI/Makefile | 1 | ||||
-rwxr-xr-x | test/TEST-35-ISCSI-MULTI/client-init.sh | 24 | ||||
-rw-r--r-- | test/TEST-35-ISCSI-MULTI/client.link | 6 | ||||
-rwxr-xr-x | test/TEST-35-ISCSI-MULTI/create-client-root.sh | 33 | ||||
-rwxr-xr-x | test/TEST-35-ISCSI-MULTI/create-server-root.sh | 20 | ||||
-rw-r--r-- | test/TEST-35-ISCSI-MULTI/dhcpd.conf | 48 | ||||
-rwxr-xr-x | test/TEST-35-ISCSI-MULTI/finished-false.sh | 2 | ||||
-rwxr-xr-x | test/TEST-35-ISCSI-MULTI/hard-off.sh | 3 | ||||
-rw-r--r-- | test/TEST-35-ISCSI-MULTI/hosts | 8 | ||||
-rwxr-xr-x | test/TEST-35-ISCSI-MULTI/server-init.sh | 88 | ||||
-rw-r--r-- | test/TEST-35-ISCSI-MULTI/server.link | 6 | ||||
-rwxr-xr-x | test/TEST-35-ISCSI-MULTI/test.sh | 345 | ||||
-rwxr-xr-x | test/TEST-35-ISCSI-MULTI/wait-if-server.sh | 4 |
13 files changed, 588 insertions, 0 deletions
diff --git a/test/TEST-35-ISCSI-MULTI/Makefile b/test/TEST-35-ISCSI-MULTI/Makefile new file mode 100644 index 0000000..2dcab81 --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/Makefile @@ -0,0 +1 @@ +-include ../Makefile.testdir diff --git a/test/TEST-35-ISCSI-MULTI/client-init.sh b/test/TEST-35-ISCSI-MULTI/client-init.sh new file mode 100755 index 0000000..46a5e3f --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/client-init.sh @@ -0,0 +1,24 @@ +#!/bin/sh +. /lib/dracut-lib.sh + +export PATH=/usr/sbin:/usr/bin:/sbin:/bin +command -v plymouth > /dev/null 2>&1 && plymouth --quit +exec > /dev/console 2>&1 + +export TERM=linux +export PS1='initramfs-test:\w\$ ' +stty sane +echo "made it to the rootfs! Powering down." +while read -r dev _ fstype opts rest || [ -n "$dev" ]; do + [ "$fstype" != "ext4" ] && continue + echo "iscsi-OK $dev $fstype $opts" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker + break +done < /proc/mounts + +if getargbool 0 rd.shell; then + strstr "$(setsid --help)" "control" && CTTY="-c" + setsid $CTTY sh -i +fi + +sync +poweroff -f diff --git a/test/TEST-35-ISCSI-MULTI/client.link b/test/TEST-35-ISCSI-MULTI/client.link new file mode 100644 index 0000000..b992bfd --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/client.link @@ -0,0 +1,6 @@ +[Match] +OriginalName=* + +[Link] +NamePolicy=keep kernel database onboard slot path +MACAddressPolicy=keep diff --git a/test/TEST-35-ISCSI-MULTI/create-client-root.sh b/test/TEST-35-ISCSI-MULTI/create-client-root.sh new file mode 100755 index 0000000..267c93a --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/create-client-root.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +trap 'poweroff -f' EXIT + +# don't let udev and this script step on eachother's toes +for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do + : > "/etc/udev/rules.d/$x" +done +rm -f -- /etc/lvm/lvm.conf +udevadm control --reload +udevadm settle + +set -ex + +mkfs.ext4 -j -L singleroot -F /dev/disk/by-id/ata-disk_singleroot +mkdir -p /sysroot +mount -t ext4 /dev/disk/by-id/ata-disk_singleroot /sysroot +cp -a -t /sysroot /source/* +umount /sysroot +mdadm --create /dev/md0 --run --auto=yes --level=stripe --raid-devices=2 /dev/disk/by-id/ata-disk_raid0-1 /dev/disk/by-id/ata-disk_raid0-2 +mdadm -W /dev/md0 || : +lvm pvcreate -ff -y /dev/md0 +lvm vgcreate dracut /dev/md0 +lvm lvcreate -l 100%FREE -n root dracut +lvm vgchange -ay +mkfs.ext4 -j -L sysroot /dev/dracut/root +mount -t ext4 /dev/dracut/root /sysroot +cp -a -t /sysroot /source/* +umount /sysroot +lvm lvchange -a n /dev/dracut/root +echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker +sync +poweroff -f diff --git a/test/TEST-35-ISCSI-MULTI/create-server-root.sh b/test/TEST-35-ISCSI-MULTI/create-server-root.sh new file mode 100755 index 0000000..2dbc2da --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/create-server-root.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +trap 'poweroff -f' EXIT + +# don't let udev and this script step on eachother's toes +for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do + : > "/etc/udev/rules.d/$x" +done +rm -f -- /etc/lvm/lvm.conf +udevadm control --reload +udevadm settle + +mkfs.ext4 -L dracut /dev/disk/by-id/ata-disk_root +mkdir -p /root +mount -t ext4 /dev/disk/by-id/ata-disk_root /root +cp -a -t /root /source/* +mkdir -p /root/run +umount /root +echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker +poweroff -f diff --git a/test/TEST-35-ISCSI-MULTI/dhcpd.conf b/test/TEST-35-ISCSI-MULTI/dhcpd.conf new file mode 100644 index 0000000..fd306ea --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/dhcpd.conf @@ -0,0 +1,48 @@ +ddns-update-style none; + +use-host-decl-names true; + +subnet 192.168.50.0 netmask 255.255.255.0 { + option subnet-mask 255.255.255.0; + option routers 192.168.50.1; + next-server 192.168.50.1; + server-identifier 192.168.50.1; + option domain-name-servers 192.168.50.1; + option domain-search "example.com"; + option domain-name "other.com"; + + # MAC numbering scheme: + # NFSv3: last octet starts at 0x00 and works up + + group { + option root-path "iscsi:192.168.50.1:::1:iqn.2009-06.dracut:target0"; + + host iscsi-1 { + hardware ethernet 52:54:00:12:34:00; + fixed-address 192.168.50.101; + } + } +} + +subnet 192.168.51.0 netmask 255.255.255.0 { + option subnet-mask 255.255.255.0; + option routers 192.168.51.1; + next-server 192.168.51.1; + server-identifier 192.168.51.1; + option domain-name-servers 192.168.51.1; + option domain-search "example.com"; + option domain-name "other.com"; + + # MAC numbering scheme: + # NFSv3: last octet starts at 0x00 and works up + + group { + #option root-path "iscsi:192.168.51.1:::1:iqn.2009-06.dracut:target1"; + + host iscsi-2 { + hardware ethernet 52:54:00:12:34:01; + fixed-address 192.168.51.101; + } + + } +} diff --git a/test/TEST-35-ISCSI-MULTI/finished-false.sh b/test/TEST-35-ISCSI-MULTI/finished-false.sh new file mode 100755 index 0000000..ecdbef9 --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/finished-false.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exit 1 diff --git a/test/TEST-35-ISCSI-MULTI/hard-off.sh b/test/TEST-35-ISCSI-MULTI/hard-off.sh new file mode 100755 index 0000000..01acb19 --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/hard-off.sh @@ -0,0 +1,3 @@ +#!/bin/sh +getargbool 0 rd.shell || poweroff -f +getargbool 0 failme && poweroff -f diff --git a/test/TEST-35-ISCSI-MULTI/hosts b/test/TEST-35-ISCSI-MULTI/hosts new file mode 100644 index 0000000..f8c18b6 --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/hosts @@ -0,0 +1,8 @@ +127.0.0.1 localhost +192.168.50.1 server +192.168.50.2 server-ip +192.168.50.3 server-proto-ip +192.168.50.100 workstation1 +192.168.50.101 workstation2 +192.168.50.102 workstation3 +192.168.50.103 workstation4 diff --git a/test/TEST-35-ISCSI-MULTI/server-init.sh b/test/TEST-35-ISCSI-MULTI/server-init.sh new file mode 100755 index 0000000..a1c3b7e --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/server-init.sh @@ -0,0 +1,88 @@ +#!/bin/sh +exec < /dev/console > /dev/console 2>&1 +set -x +export PATH=/usr/sbin:/usr/bin:/sbin:/bin +export TERM=linux +export PS1='server:\w\$ ' +stty sane +echo "made it to the rootfs!" +echo server > /proc/sys/kernel/hostname + +wait_for_if_link() { + local cnt=0 + local li + while [ $cnt -lt 600 ]; do + li=$(ip -o link show dev "$1" 2> /dev/null) + [ -n "$li" ] && return 0 + sleep 0.1 + cnt=$((cnt + 1)) + done + return 1 +} + +wait_for_if_up() { + local cnt=0 + local li + while [ $cnt -lt 200 ]; do + li=$(ip -o link show up dev "$1") + [ -n "$li" ] && return 0 + sleep 0.1 + cnt=$((cnt + 1)) + done + return 1 +} + +wait_for_route_ok() { + local cnt=0 + while [ $cnt -lt 200 ]; do + li=$(ip route show) + [ -n "$li" ] && [ -z "${li##*"$1"*}" ] && return 0 + sleep 0.1 + cnt=$((cnt + 1)) + done + return 1 +} + +linkup() { + wait_for_if_link "$1" 2> /dev/null && ip link set "$1" up 2> /dev/null && wait_for_if_up "$1" 2> /dev/null +} + +wait_for_if_link enx525400123456 +wait_for_if_link enx525400123457 + +ip addr add 127.0.0.1/8 dev lo +ip link set lo up + +ip addr add 192.168.50.1/24 dev enx525400123456 +linkup enx525400123456 + +ip addr add 192.168.51.1/24 dev enx525400123457 +linkup enx525400123457 + +modprobe af_packet + +: > /var/lib/dhcpd/dhcpd.leases +chmod 777 /var/lib/dhcpd/dhcpd.leases +dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases & + +tgtd +tgtadm --lld iscsi --mode target --op new --tid 1 --targetname iqn.2009-06.dracut:target0 +tgtadm --lld iscsi --mode target --op new --tid 2 --targetname iqn.2009-06.dracut:target1 +tgtadm --lld iscsi --mode target --op new --tid 3 --targetname iqn.2009-06.dracut:target2 +tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /dev/disk/by-id/ata-disk_singleroot +tgtadm --lld iscsi --mode logicalunit --op new --tid 2 --lun 2 -b /dev/disk/by-id/ata-disk_raid0-1 +tgtadm --lld iscsi --mode logicalunit --op new --tid 3 --lun 3 -b /dev/disk/by-id/ata-disk_raid0-2 +tgtadm --lld iscsi --mode target --op bind --tid 1 -I 192.168.50.101 +tgtadm --lld iscsi --mode target --op bind --tid 2 -I 192.168.51.101 +tgtadm --lld iscsi --mode target --op bind --tid 3 -I 192.168.50.101 + +# Wait forever for the VM to die +echo "Serving iSCSI" +while pidof tgtd > /dev/null; do + : > /dev/watchdog + dmesg -c + sleep 1 +done +dmesg -c +mount -n -o remount,ro / +poweroff -f diff --git a/test/TEST-35-ISCSI-MULTI/server.link b/test/TEST-35-ISCSI-MULTI/server.link new file mode 100644 index 0000000..1d21856 --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/server.link @@ -0,0 +1,6 @@ +[Match] +OriginalName=* + +[Link] +NamePolicy=mac +MACAddressPolicy=keep diff --git a/test/TEST-35-ISCSI-MULTI/test.sh b/test/TEST-35-ISCSI-MULTI/test.sh new file mode 100755 index 0000000..3e649a8 --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/test.sh @@ -0,0 +1,345 @@ +#!/bin/bash + +# shellcheck disable=SC2034 +TEST_DESCRIPTION="root filesystem over multiple iSCSI with $USE_NETWORK" + +#DEBUGFAIL="rd.shell rd.break rd.debug loglevel=7 " +#SERVER_DEBUG="rd.debug loglevel=7" +#SERIAL="tcp:127.0.0.1:9999" + +run_server() { + # Start server first + echo "iSCSI TEST SETUP: Starting DHCP/iSCSI server" + + declare -a disk_args=() + declare -i disk_index=0 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/server.img serverroot 0 1 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/singleroot.img singleroot + qemu_add_drive_args disk_index disk_args "$TESTDIR"/raid0-1.img raid0-1 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/raid0-2.img raid0-2 + + "$testdir"/run-qemu \ + "${disk_args[@]}" \ + -serial "${SERIAL:-"file:$TESTDIR/server.log"}" \ + -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ + -net nic,macaddr=52:54:00:12:34:57,model=e1000 \ + -net socket,listen=127.0.0.1:12331 \ + -append "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot root=/dev/disk/by-id/ata-disk_serverroot rootfstype=ext4 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \ + -initrd "$TESTDIR"/initramfs.server \ + -pidfile "$TESTDIR"/server.pid -daemonize || return 1 + chmod 644 "$TESTDIR"/server.pid || return 1 + + # Cleanup the terminal if we have one + tty -s && stty sane + + if ! [[ $SERIAL ]]; then + while :; do + grep Serving "$TESTDIR"/server.log && break + echo "Waiting for the server to startup" + tail "$TESTDIR"/server.log + sleep 1 + done + else + echo Sleeping 10 seconds to give the server a head start + sleep 10 + fi +} + +run_client() { + local test_name=$1 + shift + echo "CLIENT TEST START: $test_name" + + declare -a disk_args=() + declare -i disk_index=0 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker + + test_marker_reset + "$testdir"/run-qemu \ + "${disk_args[@]}" \ + -net nic,macaddr=52:54:00:12:34:00,model=e1000 \ + -net nic,macaddr=52:54:00:12:34:01,model=e1000 \ + -net socket,connect=127.0.0.1:12331 \ + -append "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot rw rd.auto rd.retry=50 console=ttyS0,115200n81 selinux=0 rd.debug=0 rd.shell=0 $DEBUGFAIL $*" \ + -initrd "$TESTDIR"/initramfs.testing + if ! test_marker_check iscsi-OK; then + echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" + return 1 + fi + + echo "CLIENT TEST END: $test_name [OK]" + return 0 +} + +do_test_run() { + initiator=$(iscsi-iname) + run_client "netroot=iscsi target1 target2" \ + "root=LABEL=sysroot" \ + "ip=192.168.50.101:::255.255.255.0::enp0s1:off" \ + "ip=192.168.51.101:::255.255.255.0::enp0s2:off" \ + "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \ + "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \ + "rd.iscsi.initiator=$initiator" \ + || return 1 + + run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0" \ + "root=LABEL=sysroot" \ + "ip=192.168.50.101:::255.255.255.0::enp0s1:off" \ + "ip=192.168.51.101:::255.255.255.0::enp0s2:off" \ + "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \ + "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \ + "rd.iscsi.firmware" \ + "rd.iscsi.initiator=$initiator" \ + "rd.iscsi.waitnet=0" \ + || return 1 + + run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \ + "root=LABEL=sysroot" \ + "ip=192.168.50.101:::255.255.255.0::enp0s1:off" \ + "ip=192.168.51.101:::255.255.255.0::enp0s2:off" \ + "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \ + "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \ + "rd.iscsi.firmware" \ + "rd.iscsi.initiator=$initiator" \ + "rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \ + || return 1 + + run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0 default GW" \ + "root=LABEL=sysroot" \ + "ip=192.168.50.101::192.168.50.1:255.255.255.0::enp0s1:off" \ + "ip=192.168.51.101::192.168.51.1:255.255.255.0::enp0s2:off" \ + "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \ + "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \ + "rd.iscsi.firmware" \ + "rd.iscsi.initiator=$initiator" \ + "rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \ + || return 1 + + echo "All tests passed [OK]" + return 0 +} + +test_run() { + if ! run_server; then + echo "Failed to start server" 1>&2 + return 1 + fi + do_test_run + ret=$? + if [[ -s $TESTDIR/server.pid ]]; then + kill -TERM "$(cat "$TESTDIR"/server.pid)" + rm -f -- "$TESTDIR"/server.pid + fi + return $ret +} + +test_check() { + if ! command -v tgtd &> /dev/null || ! command -v tgtadm &> /dev/null; then + echo "Need tgtd and tgtadm from scsi-target-utils" + return 1 + fi +} + +test_setup() { + kernel=$KVERSION + # Create what will eventually be our root filesystem onto an overlay + rm -rf -- "$TESTDIR"/overlay + ( + # shellcheck disable=SC2030 + export initdir=$TESTDIR/overlay/source + # shellcheck disable=SC1090 + . "$PKGLIBDIR"/dracut-init.sh + ( + cd "$initdir" || exit + mkdir -p -- dev sys proc etc var/run tmp + mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin + mkdir -p -- var/lib/nfs/rpc_pipefs + ) + inst_multiple sh shutdown poweroff stty cat ps ln ip \ + mount dmesg mkdir cp ping grep setsid dd sync + for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do + [ -f ${_terminfodir}/l/linux ] && break + done + inst_multiple -o ${_terminfodir}/l/linux + inst_simple /etc/os-release + + inst_simple "${PKGLIBDIR}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh" + inst_simple "${PKGLIBDIR}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh" + inst_binary "${PKGLIBDIR}/dracut-util" "/usr/bin/dracut-util" + ln -s dracut-util "${initdir}/usr/bin/dracut-getarg" + ln -s dracut-util "${initdir}/usr/bin/dracut-getargs" + + inst ./client-init.sh /sbin/init + cp -a /etc/ld.so.conf* "$initdir"/etc + ldconfig -r "$initdir" + ) + + # second, install the files needed to make the root filesystem + ( + # shellcheck disable=SC2031 + # shellcheck disable=SC2030 + export initdir=$TESTDIR/overlay + # shellcheck disable=SC1090 + . "$PKGLIBDIR"/dracut-init.sh + inst_multiple sfdisk mkfs.ext4 poweroff cp umount setsid dd sync blockdev + inst_hook initqueue 01 ./create-client-root.sh + inst_hook initqueue/finished 01 ./finished-false.sh + ) + + # create an initramfs that will create the target root filesystem. + # We do it this way so that we do not risk trashing the host mdraid + # devices, volume groups, encrypted partitions, etc. + "$DRACUT" -l -i "$TESTDIR"/overlay / \ + -m "dash crypt lvm mdraid kernel-modules qemu" \ + -d "piix ide-gd_mod ata_piix ext4 sd_mod" \ + --no-hostonly-cmdline -N \ + -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 + rm -rf -- "$TESTDIR"/overlay + + declare -a disk_args=() + declare -i disk_index=0 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker 1 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/singleroot.img singleroot 200 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/raid0-1.img raid0-1 100 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/raid0-2.img raid0-2 100 + + # Invoke KVM and/or QEMU to actually create the target filesystem. + "$testdir"/run-qemu \ + "${disk_args[@]}" \ + -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd "$TESTDIR"/initramfs.makeroot || return 1 + test_marker_check dracut-root-block-created || return 1 + rm -- "$TESTDIR"/marker.img + + # shellcheck disable=SC2031 + export kernel=$KVERSION + rm -rf -- "$TESTDIR"/overlay + ( + mkdir -p "$TESTDIR"/overlay/source + # shellcheck disable=SC2031 + # shellcheck disable=SC2030 + export initdir=$TESTDIR/overlay/source + # shellcheck disable=SC1090 + . "$PKGLIBDIR"/dracut-init.sh + ( + cd "$initdir" || exit + mkdir -p dev sys proc etc var/run tmp var/lib/dhcpd /etc/iscsi + ) + inst /etc/passwd /etc/passwd + inst_multiple sh ls shutdown poweroff stty cat ps ln ip \ + dmesg mkdir cp ping modprobe tcpdump setsid \ + sleep mount chmod pidof + inst_multiple tgtd tgtadm + for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do + [ -f ${_terminfodir}/l/linux ] && break + done + inst_multiple -o ${_terminfodir}/l/linux + instmods iscsi_tcp crc32c ipv6 af_packet + [ -f /etc/netconfig ] && inst_multiple /etc/netconfig + type -P dhcpd > /dev/null && inst_multiple dhcpd + inst ./server-init.sh /sbin/init + inst ./hosts /etc/hosts + inst ./dhcpd.conf /etc/dhcpd.conf + inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc \ + {,/usr}/etc/protocols {,/usr}/etc/services \ + /etc/group /etc/os-release + + _nsslibs=$( + cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \ + | sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \ + | tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|' + ) + _nsslibs=${_nsslibs#|} + _nsslibs=${_nsslibs%|} + + inst_libdir_file -n "$_nsslibs" 'libnss_*.so*' + + cp -a /etc/ld.so.conf* "$initdir"/etc + ldconfig -r "$initdir" + dracut_kernel_post + ) + + # second, install the files needed to make the root filesystem + ( + # shellcheck disable=SC2031 + # shellcheck disable=SC2030 + export initdir=$TESTDIR/overlay + # shellcheck disable=SC1090 + . "$PKGLIBDIR"/dracut-init.sh + inst_multiple sfdisk mkfs.ext4 poweroff cp umount sync dd + inst_hook initqueue 01 ./create-server-root.sh + inst_hook initqueue/finished 01 ./finished-false.sh + ) + + # create an initramfs that will create the target root filesystem. + # We do it this way so that we do not risk trashing the host mdraid + # devices, volume groups, encrypted partitions, etc. + "$DRACUT" -l -i "$TESTDIR"/overlay / \ + -m "dash rootfs-block kernel-modules qemu" \ + -d "piix ide-gd_mod ata_piix ext4 sd_mod" \ + --nomdadmconf \ + --no-hostonly-cmdline -N \ + -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 + rm -rf -- "$TESTDIR"/overlay + + declare -a disk_args=() + # shellcheck disable=SC2034 + declare -i disk_index=0 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker 1 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/server.img root 60 + + # Invoke KVM and/or QEMU to actually create the target filesystem. + "$testdir"/run-qemu \ + "${disk_args[@]}" \ + -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd "$TESTDIR"/initramfs.makeroot || return 1 + test_marker_check dracut-root-block-created || return 1 + rm -- "$TESTDIR"/marker.img + + # Make an overlay with needed tools for the test harness + ( + # shellcheck disable=SC2031 + # shellcheck disable=SC2030 + export initdir=$TESTDIR/overlay + # shellcheck disable=SC1090 + . "$PKGLIBDIR"/dracut-init.sh + inst_multiple poweroff shutdown + inst_hook shutdown-emergency 000 ./hard-off.sh + inst_hook emergency 000 ./hard-off.sh + inst_simple ./client.link /etc/systemd/network/01-client.link + ) + # Make client's dracut image + "$DRACUT" -l -i "$TESTDIR"/overlay / \ + -o "plymouth dmraid nfs" \ + -a "debug ${USE_NETWORK}" \ + --no-hostonly-cmdline -N \ + -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1 + + ( + # shellcheck disable=SC2031 + export initdir="$TESTDIR"/overlay + # shellcheck disable=SC1090 + . "$PKGLIBDIR"/dracut-init.sh + rm "$initdir"/etc/systemd/network/01-client.link + inst_simple ./server.link /etc/systemd/network/01-server.link + inst_hook pre-mount 99 ./wait-if-server.sh + ) + # Make server's dracut image + "$DRACUT" -l -i "$TESTDIR"/overlay / \ + -a "dash rootfs-block debug kernel-modules network network-legacy" \ + -d "af_packet piix ide-gd_mod ata_piix ext4 sd_mod e1000 drbg" \ + --no-hostonly-cmdline -N \ + -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1 + + rm -rf -- "$TESTDIR"/overlay +} + +test_cleanup() { + if [[ -s $TESTDIR/server.pid ]]; then + kill -TERM "$(cat "$TESTDIR"/server.pid)" + rm -f -- "$TESTDIR"/server.pid + fi +} + +# shellcheck disable=SC1090 +. "$testdir"/test-functions diff --git a/test/TEST-35-ISCSI-MULTI/wait-if-server.sh b/test/TEST-35-ISCSI-MULTI/wait-if-server.sh new file mode 100755 index 0000000..b53e41f --- /dev/null +++ b/test/TEST-35-ISCSI-MULTI/wait-if-server.sh @@ -0,0 +1,4 @@ +#!/bin/sh +. /lib/net-lib.sh +wait_for_if_link enx525400123456 +wait_for_if_link enx525400123457 |