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

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