Blob Blame History Raw
From 1a2c9bbd2d611c801df3f342d5302f91602d77d6 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 12 Aug 2015 14:42:03 +0200
Subject: [PATCH] TEST-30-ISCSI: switch to scsi-target-utils

netbsd-iscsi is not available on RHEL

Beef up the testsuite to use the two targets over different
interfaces.

Test the new iSCSI parameters rd.iscsi.waitnet and rd.iscsi.testroute.

(cherry picked from commit c22c43f81a5f15c8759e6aa69773d0e9010c4741)
---
 README.testsuite                  |  20 ++++---
 test/TEST-30-ISCSI/server-init.sh |  24 +++++++-
 test/TEST-30-ISCSI/targets        |  25 --------
 test/TEST-30-ISCSI/test.sh        | 119 +++++++++++++++++++++++++++-----------
 4 files changed, 117 insertions(+), 71 deletions(-)
 delete mode 100644 test/TEST-30-ISCSI/targets

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