18971c
From 1a2c9bbd2d611c801df3f342d5302f91602d77d6 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Wed, 12 Aug 2015 14:42:03 +0200
18971c
Subject: [PATCH] TEST-30-ISCSI: switch to scsi-target-utils
18971c
18971c
netbsd-iscsi is not available on RHEL
18971c
18971c
Beef up the testsuite to use the two targets over different
18971c
interfaces.
18971c
18971c
Test the new iSCSI parameters rd.iscsi.waitnet and rd.iscsi.testroute.
18971c
18971c
(cherry picked from commit c22c43f81a5f15c8759e6aa69773d0e9010c4741)
18971c
---
18971c
 README.testsuite                  |  20 ++---
18971c
 test/TEST-30-ISCSI/server-init.sh |  24 +++++-
18971c
 test/TEST-30-ISCSI/targets        |  25 -------
18971c
 test/TEST-30-ISCSI/test.sh        | 119 +++++++++++++++++++++---------
18971c
 4 files changed, 117 insertions(+), 71 deletions(-)
18971c
 delete mode 100644 test/TEST-30-ISCSI/targets
18971c
18971c
diff --git a/README.testsuite b/README.testsuite
18971c
index f4955e04..247ed3aa 100644
18971c
--- a/README.testsuite
18971c
+++ b/README.testsuite
18971c
@@ -1,14 +1,16 @@
18971c
 For the testsuite to work, you will have to install at least the following software packages:
18971c
-dash
18971c
-asciidoc
18971c
-mdadm
18971c
-lvm2
18971c
-cryptsetup
18971c
-nfs-utils
18971c
-netbsd-iscsi
18971c
-nbd
18971c
-dhcp (dhcp-server on openSUSE)
18971c
+dash \
18971c
+bridge-utils \
18971c
+asciidoc \
18971c
+mdadm \
18971c
+lvm2 \
18971c
+cryptsetup \
18971c
+nfs-utils \
18971c
+nbd \
18971c
+dhcp-server \
18971c
+scsi-target-utils \
18971c
 iscsi-initiator-utils
18971c
+
18971c
 TEST-04-FULL-SYSTEMD: systemd >= 187
18971c
 
18971c
 How to run the testsuite:
18971c
diff --git a/test/TEST-30-ISCSI/server-init.sh b/test/TEST-30-ISCSI/server-init.sh
18971c
index 4bdd5e3c..64a47556 100755
18971c
--- a/test/TEST-30-ISCSI/server-init.sh
18971c
+++ b/test/TEST-30-ISCSI/server-init.sh
18971c
@@ -12,10 +12,30 @@ ip link set lo up
18971c
 ip link set dev eth0 name ens3
18971c
 ip addr add 192.168.50.1/24 dev ens3
18971c
 ip link set ens3 up
18971c
+ip link set dev eth1 name ens4
18971c
+ip addr add 192.168.51.1/24 dev ens4
18971c
+ip link set ens4 up
18971c
 >/var/lib/dhcpd/dhcpd.leases
18971c
 chmod 777 /var/lib/dhcpd/dhcpd.leases
18971c
-dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases
18971c
+dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
18971c
+
18971c
+tgtd
18971c
+tgtadm --lld iscsi --mode target --op new --tid 1 --targetname iqn.2009-06.dracut:target0
18971c
+tgtadm --lld iscsi --mode target --op new --tid 2 --targetname iqn.2009-06.dracut:target1
18971c
+tgtadm --lld iscsi --mode target --op new --tid 3 --targetname iqn.2009-06.dracut:target2
18971c
+tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /dev/sdb
18971c
+tgtadm --lld iscsi --mode logicalunit --op new --tid 2 --lun 2 -b /dev/sdc
18971c
+tgtadm --lld iscsi --mode logicalunit --op new --tid 3 --lun 3 -b /dev/sdd
18971c
+tgtadm --lld iscsi --mode target --op bind --tid 1 -I 192.168.50.101
18971c
+tgtadm --lld iscsi --mode target --op bind --tid 2 -I 192.168.51.101
18971c
+tgtadm --lld iscsi --mode target --op bind --tid 3 -I 192.168.50.101
18971c
+
18971c
+
18971c
 # Wait forever for the VM to die
18971c
-/usr/sbin/iscsi-target -D -t iqn.2009-06.dracut
18971c
+echo "Serving iSCSI"
18971c
+while :; do
18971c
+	[ -n "$(jobs -rp)" ] && echo > /dev/watchdog
18971c
+	sleep 10
18971c
+done
18971c
 mount -n -o remount,ro /
18971c
 poweroff -f
18971c
diff --git a/test/TEST-30-ISCSI/targets b/test/TEST-30-ISCSI/targets
18971c
deleted file mode 100644
18971c
index 6a6872e5..00000000
18971c
--- a/test/TEST-30-ISCSI/targets
18971c
+++ /dev/null
18971c
@@ -1,25 +0,0 @@
18971c
-# $NetBSD: targets,v 1.2 2006/03/04 21:53:16 agc Exp $
18971c
-#
18971c
-# Structure of this file:
18971c
-#
18971c
-# + an extent is a straight (offset, length) pair of a file or device
18971c
-#   it's the lowest common storage denominator
18971c
-#   at least one is needed
18971c
-# + a device is made up of one or more extents or other devices
18971c
-#   devices can be added in a hierachical manner, to enhance resilience
18971c
-# + in this example, no device definitions are necessary, as the target
18971c
-#   will just use a simple extent for persistent storage
18971c
-# + a target is made up of 1 or more devices
18971c
-# The code does not support RAID1 recovery at present
18971c
-
18971c
-# Simple file showing 1 extent, mapped straight into 1 target
18971c
-
18971c
-# extents	file			start	length
18971c
-extent0		/dev/sdb	0	20971520
18971c
-extent1		/dev/sdc	0	20971520
18971c
-extent2		/dev/sdd	0	20971520
18971c
-
18971c
-# target	flags	storage		netmask
18971c
-target0		rw	extent0		192.168.50.0/24
18971c
-target1		rw	extent1		192.168.50.0/24
18971c
-target2		rw	extent2		192.168.50.0/24
18971c
diff --git a/test/TEST-30-ISCSI/test.sh b/test/TEST-30-ISCSI/test.sh
18971c
index a258c042..be3399a3 100755
18971c
--- a/test/TEST-30-ISCSI/test.sh
18971c
+++ b/test/TEST-30-ISCSI/test.sh
18971c
@@ -3,8 +3,10 @@ TEST_DESCRIPTION="root filesystem over iSCSI"
18971c
 
18971c
 KVERSION=${KVERSION-$(uname -r)}
18971c
 
18971c
-#DEBUGFAIL="rd.shell"
18971c
-#SERIAL="tcp:127.0.0.1:9999"
18971c
+#DEBUGFAIL="rd.shell rd.break rd.debug loglevel=7 "
18971c
+DEBUGFAIL="loglevel=1"
18971c
+#SERVER_DEBUG="rd.debug loglevel=7"
18971c
+SERIAL="tcp:127.0.0.1:9999"
18971c
 SERIAL="null"
18971c
 
18971c
 run_server() {
18971c
@@ -12,17 +14,17 @@ run_server() {
18971c
     echo "iSCSI TEST SETUP: Starting DHCP/iSCSI server"
18971c
 
18971c
     $testdir/run-qemu \
18971c
-        -hda $TESTDIR/server.ext3 \
18971c
-        -hdb $TESTDIR/root.ext3 \
18971c
-        -hdc $TESTDIR/iscsidisk2.img \
18971c
-        -hdd $TESTDIR/iscsidisk3.img \
18971c
-        -m 256M  -smp 2 \
18971c
+        -drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
18971c
+        -drive format=raw,index=1,media=disk,file=$TESTDIR/root.ext3 \
18971c
+        -drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
18971c
+        -drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
18971c
+        -m 512M  -smp 2 \
18971c
         -display none \
18971c
         -serial $SERIAL \
18971c
         -net nic,macaddr=52:54:00:12:34:56,model=e1000 \
18971c
+        -net nic,macaddr=52:54:00:12:34:57,model=e1000 \
18971c
         -net socket,listen=127.0.0.1:12330 \
18971c
-        -kernel /boot/vmlinuz-$KVERSION \
18971c
-        -append "root=/dev/sda rootfstype=ext3 rw rd.debug loglevel=77 console=ttyS0,115200n81 selinux=0" \
18971c
+        -append "root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \
18971c
         -initrd $TESTDIR/initramfs.server \
18971c
         -pidfile $TESTDIR/server.pid -daemonize || return 1
18971c
     sudo chmod 644 $TESTDIR/server.pid || return 1
18971c
@@ -41,12 +43,12 @@ run_client() {
18971c
     dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1
18971c
 
18971c
     $testdir/run-qemu \
18971c
-        -hda $TESTDIR/client.img \
18971c
-        -m 256M -smp 2 -nographic \
18971c
+        -drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
18971c
+        -m 512M -smp 2 -nographic \
18971c
         -net nic,macaddr=52:54:00:12:34:00,model=e1000 \
18971c
+        -net nic,macaddr=52:54:00:12:34:01,model=e1000 \
18971c
         -net socket,connect=127.0.0.1:12330 \
18971c
-        -kernel /boot/vmlinuz-$KVERSION \
18971c
-        -append "$* rw quiet rd.auto rd.retry=5 rd.debug rd.info  console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
18971c
+        -append "rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug=0 $DEBUGFAIL $*" \
18971c
         -initrd $TESTDIR/initramfs.testing
18971c
     if ! grep -F -m 1 -q iscsi-OK $TESTDIR/client.img; then
18971c
 	echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
18971c
@@ -58,20 +60,58 @@ run_client() {
18971c
 }
18971c
 
18971c
 do_test_run() {
18971c
+    initiator=$(iscsi-iname)
18971c
 
18971c
     run_client "root=dhcp" \
18971c
-        "root=dhcp" \
18971c
+               "root=/dev/root netroot=dhcp ip=ens3:dhcp" \
18971c
+               "rd.iscsi.initiator=$initiator" \
18971c
+        || return 1
18971c
+
18971c
+    run_client "netroot=iscsi target0"\
18971c
+               "root=LABEL=singleroot netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0" \
18971c
+               "ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens3:off" \
18971c
+               "rd.iscsi.initiator=$initiator" \
18971c
+        || return 1
18971c
+
18971c
+    run_client "netroot=iscsi target1 target2" \
18971c
+               "root=LABEL=sysroot" \
18971c
+               "ip=192.168.50.101:::255.255.255.0::ens3:off" \
18971c
+               "ip=192.168.51.101:::255.255.255.0::ens4:off" \
18971c
+               "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
18971c
+               "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
18971c
+               "rd.iscsi.initiator=$initiator" \
18971c
+        || return 1
18971c
+
18971c
+    run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0" \
18971c
+	       "root=LABEL=sysroot" \
18971c
+               "ip=192.168.50.101:::255.255.255.0::ens3:off" \
18971c
+               "ip=192.168.51.101:::255.255.255.0::ens4:off" \
18971c
+	       "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
18971c
+               "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
18971c
+               "rd.iscsi.initiator=$initiator" \
18971c
+               "rd.waitnet=0 rd.retry=30" \
18971c
 	|| return 1
18971c
 
18971c
-    run_client "root=iscsi" \
18971c
-	"root=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0" \
18971c
-	"ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens3:off" \
18971c
+    run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
18971c
+	       "root=LABEL=sysroot" \
18971c
+               "ip=192.168.50.101:::255.255.255.0::ens3:off" \
18971c
+               "ip=192.168.51.101:::255.255.255.0::ens4:off" \
18971c
+	       "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
18971c
+               "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
18971c
+               "rd.iscsi.initiator=$initiator" \
18971c
+               "rd.waitnet=0 rd.iscsi.testroute=0 rd.retry=30" \
18971c
 	|| return 1
18971c
 
18971c
-    run_client "netroot=iscsi" \
18971c
-	"iscsi_firmware root=LABEL=sysroot ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens3:off" \
18971c
-	"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
18971c
+    run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0 default GW" \
18971c
+	       "root=LABEL=sysroot" \
18971c
+               "ip=192.168.50.101::192.168.50.1:255.255.255.0::ens3:off" \
18971c
+               "ip=192.168.51.101::192.168.51.1:255.255.255.0::ens4:off" \
18971c
+	       "netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
18971c
+               "netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
18971c
+               "rd.iscsi.initiator=$initiator" \
18971c
+               "rd.waitnet=0 rd.iscsi.testroute=0 rd.retry=30" \
18971c
 	|| return 1
18971c
+
18971c
     return 0
18971c
 }
18971c
 
18971c
@@ -105,15 +145,23 @@ test_setup() {
18971c
     (
18971c
         export initdir=$TESTDIR/overlay/source
18971c
         . $basedir/dracut-init.sh
18971c
+        (
18971c
+            cd "$initdir"
18971c
+            mkdir -p -- dev sys proc etc var/run tmp
18971c
+            mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
18971c
+            for i in bin sbin lib lib64; do
18971c
+                ln -sfnr usr/$i $i
18971c
+            done
18971c
+            mkdir -p -- var/lib/nfs/rpc_pipefs
18971c
+        )
18971c
         inst_multiple sh shutdown poweroff stty cat ps ln ip \
18971c
-            mount dmesg mkdir cp ping grep
18971c
+            mount dmesg mkdir cp ping grep setsid
18971c
         for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
18971c
             [ -f ${_terminfodir}/l/linux ] && break
18971c
         done
18971c
         inst_multiple -o ${_terminfodir}/l/linux
18971c
         inst_simple /etc/os-release
18971c
         inst ./client-init.sh /sbin/init
18971c
-        (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
18971c
         cp -a /etc/ld.so.conf* $initdir/etc
18971c
         sudo ldconfig -r "$initdir"
18971c
     )
18971c
@@ -122,7 +170,7 @@ test_setup() {
18971c
     (
18971c
         export initdir=$TESTDIR/overlay
18971c
         . $basedir/dracut-init.sh
18971c
-        inst_multiple sfdisk mkfs.ext3 poweroff cp umount
18971c
+        inst_multiple sfdisk mkfs.ext3 poweroff cp umount setsid
18971c
         inst_hook initqueue 01 ./create-root.sh
18971c
         inst_hook initqueue/finished 01 ./finished-false.sh
18971c
         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
18971c
@@ -132,8 +180,9 @@ test_setup() {
18971c
     # We do it this way so that we do not risk trashing the host mdraid
18971c
     # devices, volume groups, encrypted partitions, etc.
18971c
     $basedir/dracut.sh -l -i $TESTDIR/overlay / \
18971c
-        -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
18971c
+        -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
18971c
         -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
18971c
+        --no-hostonly-cmdline -N \
18971c
         -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
18971c
     rm -rf -- $TESTDIR/overlay
18971c
 
18971c
@@ -145,12 +194,11 @@ test_setup() {
18971c
     fi
18971c
     # Invoke KVM and/or QEMU to actually create the target filesystem.
18971c
     $testdir/run-qemu \
18971c
-        -hda $TESTDIR/root.ext3 \
18971c
-        -hdb $TESTDIR/client.img \
18971c
-        -hdc $TESTDIR/iscsidisk2.img \
18971c
-        -hdd $TESTDIR/iscsidisk3.img \
18971c
+        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
18971c
+        -drive format=raw,index=1,media=disk,file=$TESTDIR/client.img \
18971c
+        -drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
18971c
+        -drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
18971c
         -smp 2 -m 256M -nographic -net none \
18971c
-        -kernel "/boot/vmlinuz-$kernel" \
18971c
         -append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
18971c
         -initrd $TESTDIR/initramfs.makeroot  || return 1
18971c
     grep -F -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
18971c
@@ -163,9 +211,10 @@ test_setup() {
18971c
         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
18971c
     )
18971c
     sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
18971c
-        -o "dash plymouth dmraid" \
18971c
+        -o "dash plymouth dmraid nfs" \
18971c
         -a "debug" \
18971c
         -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
18971c
+        --no-hostonly-cmdline -N \
18971c
         -f $TESTDIR/initramfs.testing $KVERSION || return 1
18971c
 
18971c
     # Make server root
18971c
@@ -185,15 +234,14 @@ test_setup() {
18971c
         inst /etc/passwd /etc/passwd
18971c
         inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
18971c
             dmesg mkdir cp ping \
18971c
-            modprobe tcpdump \
18971c
+            modprobe tcpdump setsid \
18971c
             /etc/services sleep mount chmod
18971c
-        inst_multiple /usr/sbin/iscsi-target
18971c
+        inst_multiple tgtd tgtadm
18971c
         for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
18971c
             [ -f ${_terminfodir}/l/linux ] && break
18971c
         done
18971c
         inst_multiple -o ${_terminfodir}/l/linux
18971c
         instmods iscsi_tcp crc32c ipv6
18971c
-        inst ./targets /etc/iscsi/targets
18971c
         [ -f /etc/netconfig ] && inst_multiple /etc/netconfig
18971c
         type -P dhcpd >/dev/null && inst_multiple dhcpd
18971c
         [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
18971c
@@ -214,8 +262,9 @@ test_setup() {
18971c
 
18971c
     # Make server's dracut image
18971c
     $basedir/dracut.sh -l -i $TESTDIR/overlay / \
18971c
-        -m "dash udev-rules base rootfs-block debug kernel-modules" \
18971c
-        -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000" \
18971c
+        -a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
18971c
+        -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
18971c
+        --no-hostonly-cmdline -N \
18971c
         -f $TESTDIR/initramfs.server $KVERSION || return 1
18971c
 
18971c
 }