Blame SOURCES/0296-TEST-30-ISCSI-switch-to-scsi-target-utils.patch

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