18971c
From 7b0ce59233f9e56e2115c921a51fac97e9e52a2a Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Mon, 4 Jul 2016 15:44:36 +0200
18971c
Subject: [PATCH] TEST-70-BONDBRIDGETEAMVLAN: add testcase for testsuite
18971c
18971c
multiple bonds
18971c
multiple bridges
18971c
multiple vlans
18971c
---
18971c
 .../99-idesymlinks.rules                      |   8 +
18971c
 test/TEST-70-BONDBRIDGETEAMVLAN/Makefile      |  10 +
18971c
 .../TEST-70-BONDBRIDGETEAMVLAN/client-init.sh |  22 ++
18971c
 test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd.conf    |  27 ++
18971c
 test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd2.conf   |  15 +
18971c
 test/TEST-70-BONDBRIDGETEAMVLAN/exports       |   1 +
18971c
 .../finished-false.sh                         |   2 +
18971c
 test/TEST-70-BONDBRIDGETEAMVLAN/hard-off.sh   |   3 +
18971c
 test/TEST-70-BONDBRIDGETEAMVLAN/hosts         |   5 +
18971c
 .../TEST-70-BONDBRIDGETEAMVLAN/server-init.sh | 117 +++++++
18971c
 test/TEST-70-BONDBRIDGETEAMVLAN/test.sh       | 308 ++++++++++++++++++
18971c
 11 files changed, 518 insertions(+)
18971c
 create mode 100644 test/TEST-70-BONDBRIDGETEAMVLAN/99-idesymlinks.rules
18971c
 create mode 100644 test/TEST-70-BONDBRIDGETEAMVLAN/Makefile
18971c
 create mode 100755 test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh
18971c
 create mode 100644 test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd.conf
18971c
 create mode 100644 test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd2.conf
18971c
 create mode 100644 test/TEST-70-BONDBRIDGETEAMVLAN/exports
18971c
 create mode 100755 test/TEST-70-BONDBRIDGETEAMVLAN/finished-false.sh
18971c
 create mode 100755 test/TEST-70-BONDBRIDGETEAMVLAN/hard-off.sh
18971c
 create mode 100644 test/TEST-70-BONDBRIDGETEAMVLAN/hosts
18971c
 create mode 100755 test/TEST-70-BONDBRIDGETEAMVLAN/server-init.sh
18971c
 create mode 100755 test/TEST-70-BONDBRIDGETEAMVLAN/test.sh
18971c
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/99-idesymlinks.rules b/test/TEST-70-BONDBRIDGETEAMVLAN/99-idesymlinks.rules
18971c
new file mode 100644
18971c
index 00000000..d557790a
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/99-idesymlinks.rules
18971c
@@ -0,0 +1,8 @@
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/Makefile b/test/TEST-70-BONDBRIDGETEAMVLAN/Makefile
18971c
new file mode 100644
18971c
index 00000000..aad27059
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/Makefile
18971c
@@ -0,0 +1,10 @@
18971c
+all:
18971c
+	@$(MAKE) -s --no-print-directory -C ../.. all
18971c
+	@V=$(V) basedir=../.. testdir=../ ./test.sh --all
18971c
+setup:
18971c
+	@$(MAKE) --no-print-directory -C ../.. all
18971c
+	@basedir=../.. testdir=../ ./test.sh --setup
18971c
+clean:
18971c
+	@basedir=../.. testdir=../ ./test.sh --clean
18971c
+run:
18971c
+	@basedir=../.. testdir=../ ./test.sh --run
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh
18971c
new file mode 100755
18971c
index 00000000..2018393b
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh
18971c
@@ -0,0 +1,22 @@
18971c
+#!/bin/sh
18971c
+exec >/dev/console 2>&1
18971c
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
18971c
+strstr() { [ "${1#*$2*}" != "$1" ]; }
18971c
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
18971c
+export TERM=linux
18971c
+export PS1='initramfs-test:\w\$ '
18971c
+stty sane
18971c
+echo "made it to the rootfs! Powering down."
18971c
+
18971c
+(
18971c
+    echo OK
18971c
+    ip -o -4 address show scope global | while read n if rest; do echo $if;done
18971c
+    for i in /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-*; do
18971c
+	echo $i
18971c
+	grep -v 'UUID=' $i
18971c
+    done
18971c
+    echo EOF
18971c
+) > /dev/sda
18971c
+
18971c
+strstr "$CMDLINE" "rd.shell" && sh -i
18971c
+poweroff -f
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd.conf b/test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd.conf
18971c
new file mode 100644
18971c
index 00000000..ec810c29
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd.conf
18971c
@@ -0,0 +1,27 @@
18971c
+ddns-update-style none;
18971c
+
18971c
+use-host-decl-names true;
18971c
+
18971c
+subnet 192.168.50.0 netmask 255.255.255.0 {
18971c
+	option subnet-mask      255.255.255.0;
18971c
+	option routers          192.168.50.1;
18971c
+	next-server             192.168.50.1;
18971c
+	server-identifier       192.168.50.1;
18971c
+	option domain-name-servers 192.168.50.1;
18971c
+	option domain-search "example.com";
18971c
+	option domain-name "other.com";
18971c
+	option root-path "nfs:192.168.50.1:/nfs/client";
18971c
+	range 192.168.50.10 192.168.50.100;
18971c
+}
18971c
+
18971c
+subnet 192.168.51.0 netmask 255.255.255.0 {
18971c
+	option subnet-mask      255.255.255.0;
18971c
+	option routers          192.168.51.1;
18971c
+	next-server             192.168.51.1;
18971c
+	server-identifier       192.168.51.1;
18971c
+	option domain-name-servers 192.168.51.1;
18971c
+	option domain-search "example.com";
18971c
+	option domain-name "other.com";
18971c
+	option root-path "nfs:192.168.50.1:/nfs/client";
18971c
+	range 192.168.51.10 192.168.51.100;
18971c
+}
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd2.conf b/test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd2.conf
18971c
new file mode 100644
18971c
index 00000000..90f0c302
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd2.conf
18971c
@@ -0,0 +1,15 @@
18971c
+ddns-update-style none;
18971c
+
18971c
+use-host-decl-names true;
18971c
+
18971c
+subnet 192.168.51.0 netmask 255.255.255.0 {
18971c
+	option subnet-mask      255.255.255.0;
18971c
+	option routers          192.168.51.1;
18971c
+	next-server             192.168.51.1;
18971c
+	server-identifier       192.168.51.1;
18971c
+	option domain-name-servers 192.168.51.1;
18971c
+	option domain-search "example.com";
18971c
+	option domain-name "other.com";
18971c
+	option root-path "nfs:192.168.50.1:/nfs/client";
18971c
+	range 192.168.51.10 192.168.51.100;
18971c
+}
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/exports b/test/TEST-70-BONDBRIDGETEAMVLAN/exports
18971c
new file mode 100644
18971c
index 00000000..ff5f29b1
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/exports
18971c
@@ -0,0 +1 @@
18971c
+/nfs/client	192.168.50.0/24(rw,insecure,no_subtree_check,no_root_squash)
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/finished-false.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/finished-false.sh
18971c
new file mode 100755
18971c
index 00000000..ecdbef95
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/finished-false.sh
18971c
@@ -0,0 +1,2 @@
18971c
+#!/bin/sh
18971c
+exit 1
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/hard-off.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/hard-off.sh
18971c
new file mode 100755
18971c
index 00000000..12c3d5ac
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/hard-off.sh
18971c
@@ -0,0 +1,3 @@
18971c
+#!/bin/sh
18971c
+getarg rd.shell || poweroff -f
18971c
+getarg failme && poweroff -f
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/hosts b/test/TEST-70-BONDBRIDGETEAMVLAN/hosts
18971c
new file mode 100644
18971c
index 00000000..d02a4e9b
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/hosts
18971c
@@ -0,0 +1,5 @@
18971c
+127.0.0.1	localhost
18971c
+192.168.50.1	server
18971c
+192.168.50.100	client-if1
18971c
+192.168.50.101	client-if2
18971c
+192.168.50.102	client-if3
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/server-init.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/server-init.sh
18971c
new file mode 100755
18971c
index 00000000..9585a47c
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/server-init.sh
18971c
@@ -0,0 +1,117 @@
18971c
+#!/bin/sh
18971c
+exec </dev/console >/dev/console 2>&1
18971c
+set -x
18971c
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
18971c
+export TERM=linux
18971c
+export PS1='nfstest-server:\w\$ '
18971c
+stty sane
18971c
+echo "made it to the rootfs!"
18971c
+echo server > /proc/sys/kernel/hostname
18971c
+
18971c
+wait_for_if_link() {
18971c
+    local cnt=0
18971c
+    local li
18971c
+    while [ $cnt -lt 600 ]; do
18971c
+        li=$(ip -o link show dev $1 2>/dev/null)
18971c
+        [ -n "$li" ] && return 0
18971c
+        sleep 0.1
18971c
+        cnt=$(($cnt+1))
18971c
+    done
18971c
+    return 1
18971c
+}
18971c
+
18971c
+wait_for_if_up() {
18971c
+    local cnt=0
18971c
+    local li
18971c
+    while [ $cnt -lt 200 ]; do
18971c
+        li=$(ip -o link show up dev $1)
18971c
+        [ -n "$li" ] && return 0
18971c
+        sleep 0.1
18971c
+        cnt=$(($cnt+1))
18971c
+    done
18971c
+    return 1
18971c
+}
18971c
+
18971c
+wait_for_route_ok() {
18971c
+    local cnt=0
18971c
+    while [ $cnt -lt 200 ]; do
18971c
+        li=$(ip route show)
18971c
+        [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
18971c
+        sleep 0.1
18971c
+        cnt=$(($cnt+1))
18971c
+    done
18971c
+    return 1
18971c
+}
18971c
+
18971c
+linkup() {
18971c
+    wait_for_if_link $1 2>/dev/null\
18971c
+     && ip link set $1 up 2>/dev/null\
18971c
+     && wait_for_if_up $1 2>/dev/null
18971c
+}
18971c
+
18971c
+modprobe -b -q 8021q
18971c
+>/dev/watchdog
18971c
+ip addr add 127.0.0.1/8 dev lo
18971c
+linkup lo
18971c
+ip link set dev eth0 name ens3
18971c
+ip addr add 192.168.50.1/24 dev ens3
18971c
+linkup ens3
18971c
+>/dev/watchdog
18971c
+ip link set dev eth1 name ens4
18971c
+linkup ens4
18971c
+ip link add dev ens4.1 link ens4 type vlan id 1
18971c
+ip link add dev ens4.2 link ens4 type vlan id 2
18971c
+ip link add dev ens4.3 link ens4 type vlan id 3
18971c
+ip link add dev ens4.4 link ens4 type vlan id 4
18971c
+ip addr add 192.168.54.1/24 dev ens4.1
18971c
+ip addr add 192.168.55.1/24 dev ens4.2
18971c
+ip addr add 192.168.56.1/24 dev ens4.3
18971c
+ip addr add 192.168.57.1/24 dev ens4.4
18971c
+ip link set dev eth2 name ens5
18971c
+ip link set dev eth3 name ens6
18971c
+linkup ens4
18971c
+linkup ens5
18971c
+linkup ens6
18971c
+ip addr add 192.168.51.1/24 dev ens5
18971c
+linkup ens4
18971c
+>/dev/watchdog
18971c
+modprobe af_packet
18971c
+> /dev/watchdog
18971c
+modprobe sunrpc
18971c
+>/dev/watchdog
18971c
+mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
18971c
+>/dev/watchdog
18971c
+[ -x /sbin/portmap ] && portmap
18971c
+>/dev/watchdog
18971c
+[ -x /sbin/rpcbind ] && rpcbind
18971c
+>/dev/watchdog
18971c
+modprobe nfsd
18971c
+>/dev/watchdog
18971c
+mount -t nfsd nfsd /proc/fs/nfsd
18971c
+>/dev/watchdog
18971c
+exportfs -r
18971c
+>/dev/watchdog
18971c
+rpc.nfsd
18971c
+>/dev/watchdog
18971c
+rpc.mountd
18971c
+>/dev/watchdog
18971c
+rpc.idmapd
18971c
+>/dev/watchdog
18971c
+exportfs -r
18971c
+>/dev/watchdog
18971c
+>/var/lib/dhcpd/dhcpd.leases
18971c
+>/dev/watchdog
18971c
+chmod 777 /var/lib/dhcpd/dhcpd.leases
18971c
+>/dev/watchdog
18971c
+dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases ens3 ens5
18971c
+#echo -n 'V' > /dev/watchdog
18971c
+#sh -i
18971c
+#tcpdump -i ens3
18971c
+# Wait forever for the VM to die
18971c
+echo "Serving NFS mounts"
18971c
+while :; do
18971c
+	sleep 10
18971c
+	>/dev/watchdog
18971c
+done
18971c
+mount -n -o remount,ro /
18971c
+poweroff -f
18971c
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh
18971c
new file mode 100755
18971c
index 00000000..54ceb9e1
18971c
--- /dev/null
18971c
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh
18971c
@@ -0,0 +1,308 @@
18971c
+#!/bin/bash
18971c
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
18971c
+# ex: ts=8 sw=4 sts=4 et filetype=sh
18971c
+TEST_DESCRIPTION="root filesystem on NFS with bridging/bonding/vlan"
18971c
+KVERSION=${KVERSION-$(uname -r)}
18971c
+
18971c
+# Uncomment this to debug failures
18971c
+#DEBUGFAIL="rd.shell rd.break"
18971c
+#DEBUGFAIL="rd.shell rd.break rd.debug"
18971c
+#SERIAL="tcp:127.0.0.1:9999"
18971c
+
18971c
+run_server() {
18971c
+    # Start server first
18971c
+    echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
18971c
+
18971c
+    fsck -a "$TESTDIR"/server.ext3 || return 1
18971c
+    $testdir/run-qemu \
18971c
+        -hda "$TESTDIR"/server.ext3 \
18971c
+        -m 512M -smp 2 \
18971c
+        -display none \
18971c
+        -net socket,vlan=0,listen=127.0.0.1:12350 \
18971c
+        -net socket,vlan=1,listen=127.0.0.1:12351 \
18971c
+        -net socket,vlan=2,listen=127.0.0.1:12352 \
18971c
+        -net socket,vlan=3,listen=127.0.0.1:12353 \
18971c
+        -net nic,vlan=0,macaddr=52:54:01:12:34:56,model=e1000 \
18971c
+        -net nic,vlan=1,macaddr=52:54:01:12:34:57,model=e1000 \
18971c
+        -net nic,vlan=2,macaddr=52:54:01:12:34:58,model=e1000 \
18971c
+        -net nic,vlan=3,macaddr=52:54:01:12:34:59,model=e1000 \
18971c
+        ${SERIAL:+-serial "$SERIAL"} \
18971c
+        -watchdog i6300esb -watchdog-action poweroff \
18971c
+        -kernel /boot/vmlinuz-"$KVERSION" \
18971c
+        -append "loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
18971c
+        -initrd "$TESTDIR"/initramfs.server \
18971c
+        -pidfile "$TESTDIR"/server.pid -daemonize || return 1
18971c
+    sudo chmod 644 -- "$TESTDIR"/server.pid || return 1
18971c
+
18971c
+    # Cleanup the terminal if we have one
18971c
+    tty -s && stty sane
18971c
+
18971c
+    echo Sleeping 10 seconds to give the server a head start
18971c
+    sleep 10
18971c
+}
18971c
+
18971c
+client_test() {
18971c
+    local test_name="$1"
18971c
+    local do_vlan13="$2"
18971c
+    local cmdline="$3"
18971c
+    local check="$4"
18971c
+    local CONF
18971c
+
18971c
+    echo "CLIENT TEST START: $test_name"
18971c
+
18971c
+    [ "$do_vlan13" != "yes" ] && unset do_vlan13
18971c
+
18971c
+    # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
18971c
+    if ! dd if=/dev/zero of="$TESTDIR"/client.img bs=1M count=1; then
18971c
+        echo "Unable to make client sda image" 1>&2
18971c
+        return 1
18971c
+    fi
18971c
+
18971c
+    $testdir/run-qemu -hda "$TESTDIR"/client.img -m 256M -smp 2 -nographic \
18971c
+        -net socket,vlan=0,connect=127.0.0.1:12350 \
18971c
+        ${do_vlan13:+-net socket,vlan=1,connect=127.0.0.1:12351} \
18971c
+        -net socket,vlan=2,connect=127.0.0.1:12352 \
18971c
+        ${do_vlan13:+-net socket,vlan=3,connect=127.0.0.1:12353} \
18971c
+        -net nic,vlan=0,macaddr=52:54:00:12:34:01,model=e1000 \
18971c
+        -net nic,vlan=0,macaddr=52:54:00:12:34:02,model=e1000 \
18971c
+        -net nic,vlan=1,macaddr=52:54:00:12:34:03,model=e1000 \
18971c
+        -net nic,vlan=2,macaddr=52:54:00:12:34:04,model=e1000 \
18971c
+        -net nic,vlan=3,macaddr=52:54:00:12:34:05,model=e1000 \
18971c
+        -watchdog i6300esb -watchdog-action poweroff \
18971c
+        -kernel /boot/vmlinuz-"$KVERSION" \
18971c
+        -append "$cmdline rd.info $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
18971c
+        -initrd "$TESTDIR"/initramfs.testing
18971c
+
18971c
+    { 
18971c
+        read OK
18971c
+        if [[ "$OK" != "OK" ]]; then
18971c
+            echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
18971c
+            return 1
18971c
+        fi
18971c
+
18971c
+        while read line; do
18971c
+            [[ $line == END ]] && break
18971c
+            CONF+="$line "
18971c
+        done
18971c
+    } < "$TESTDIR"/client.img || return 1
18971c
+
18971c
+    if [[ "$check" != "$CONF" ]]; then
18971c
+        echo "Expected: '$check'"
18971c
+        echo
18971c
+        echo
18971c
+        echo "Got:      '$CONF'"
18971c
+        echo "CLIENT TEST END: $test_name [FAILED - BAD CONF]"
18971c
+        return 1
18971c
+    fi
18971c
+
18971c
+    echo "CLIENT TEST END: $test_name [OK]"
18971c
+    return 0
18971c
+}
18971c
+
18971c
+
18971c
+test_run() {
18971c
+    if ! run_server; then
18971c
+        echo "Failed to start server" 1>&2
18971c
+        return 1
18971c
+    fi
18971c
+    test_client || { kill_server; return 1; }
18971c
+}
18971c
+
18971c
+test_client() {
18971c
+    client_test "Multiple VLAN" \
18971c
+        "yes" \
18971c
+        "
18971c
+vlan=vlan0001:ens4
18971c
+vlan=vlan2:ens4
18971c
+vlan=ens4.3:ens4
18971c
+vlan=ens4.0004:ens4
18971c
+ip=ens3:dhcp
18971c
+ip=192.168.54.101::192.168.54.1:24:test:vlan0001:none
18971c
+ip=192.168.55.102::192.168.55.1:24:test:vlan2:none
18971c
+ip=192.168.56.103::192.168.56.1:24:test:ens4.3:none
18971c
+ip=192.168.57.104::192.168.57.1:24:test:ens4.0004:none
18971c
+rd.neednet=1
18971c
+root=nfs:192.168.50.1:/nfs/client bootdev=ens3
18971c
+" \
18971c
+    'ens3 ens4.0004 ens4.3 vlan0001 vlan2 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens3 # Generated by dracut initrd NAME="ens3" DEVICE="ens3" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Ethernet /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4.0004 # Generated by dracut initrd NAME="ens4.0004" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=none IPADDR="192.168.57.104" PREFIX="24" GATEWAY="192.168.57.1" TYPE=Vlan DEVICE="ens4.0004" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4.3 # Generated by dracut initrd NAME="ens4.3" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=none IPADDR="192.168.56.103" PREFIX="24" GATEWAY="192.168.56.1" TYPE=Vlan DEVICE="ens4.3" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan0001 # Generated by dracut initrd NAME="vlan0001" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=none IPADDR="192.168.54.101" PREFIX="24" GATEWAY="192.168.54.1" TYPE=Vlan DEVICE="vlan0001" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan2 # Generated by dracut initrd NAME="vlan2" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=none IPADDR="192.168.55.102" PREFIX="24" GATEWAY="192.168.55.1" TYPE=Vlan DEVICE="vlan2" VLAN=yes PHYSDEV="ens4" EOF ' \
18971c
+    || return 1
18971c
+
18971c
+    client_test "Multiple Bonds" \
18971c
+        "yes" \
18971c
+        "
18971c
+bond=bond0:ens4,ens5
18971c
+bond=bond1:ens6,ens7
18971c
+ip=bond0:dhcp
18971c
+ip=bond1:dhcp
18971c
+rd.neednet=1
18971c
+root=nfs:192.168.50.1:/nfs/client bootdev=bond0
18971c
+" \
18971c
+    'bond0 bond1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond0 # Generated by dracut initrd NAME="bond0" DEVICE="bond0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond0" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond1 # Generated by dracut initrd NAME="bond1" DEVICE="bond1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond1" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens7" EOF ' \
18971c
+    || return 1
18971c
+
18971c
+    client_test "Multiple Bridges" \
18971c
+        "no" \
18971c
+        "
18971c
+bridge=br0:ens4,ens5
18971c
+bridge=br1:ens6,ens7
18971c
+ip=br0:dhcp
18971c
+ip=br1:dhcp
18971c
+rd.neednet=1
18971c
+root=nfs:192.168.50.1:/nfs/client bootdev=br0
18971c
+" \
18971c
+    'br0 br1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br0 # Generated by dracut initrd NAME="br0" DEVICE="br0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br0" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br1 # Generated by dracut initrd NAME="br1" DEVICE="br1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br1" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens7" EOF ' \
18971c
+    || return 1
18971c
+
18971c
+    kill_server
18971c
+    return 0
18971c
+}
18971c
+
18971c
+test_setup() {
18971c
+     # Make server root
18971c
+    dd if=/dev/null of="$TESTDIR"/server.ext3 bs=1M seek=60
18971c
+    mke2fs -j -F -- "$TESTDIR"/server.ext3
18971c
+    mkdir -- "$TESTDIR"/mnt
18971c
+    sudo mount -o loop -- "$TESTDIR"/server.ext3 "$TESTDIR"/mnt
18971c
+
18971c
+    (
18971c
+        export initdir="$TESTDIR"/mnt
18971c
+        . "$basedir"/dracut-init.sh
18971c
+
18971c
+        (
18971c
+            cd "$initdir";
18971c
+            mkdir -p -- dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
18971c
+            mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
18971c
+            chmod 777 -- var/lib/rpcbind var/lib/nfs
18971c
+        )
18971c
+
18971c
+        for _f in modules.builtin.bin modules.builtin; do
18971c
+            [[ $srcmods/$_f ]] && break
18971c
+        done || {
18971c
+            dfatal "No modules.builtin.bin and modules.builtin found!"
18971c
+            return 1
18971c
+        }
18971c
+
18971c
+        for _f in modules.builtin.bin modules.builtin modules.order; do
18971c
+            [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
18971c
+        done
18971c
+
18971c
+        inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
18971c
+            dmesg mkdir cp ping exportfs \
18971c
+            modprobe rpc.nfsd rpc.mountd showmount tcpdump \
18971c
+            /etc/services sleep mount chmod
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
+        type -P portmap >/dev/null && inst_multiple portmap
18971c
+        type -P rpcbind >/dev/null && inst_multiple rpcbind
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
+        instmods nfsd sunrpc ipv6 lockd af_packet 8021q
18971c
+        inst_simple /etc/os-release
18971c
+        inst ./server-init.sh /sbin/init
18971c
+        inst ./hosts /etc/hosts
18971c
+        inst ./exports /etc/exports
18971c
+        inst ./dhcpd.conf /etc/dhcpd.conf
18971c
+        inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
18971c
+
18971c
+        inst_multiple rpc.idmapd /etc/idmapd.conf
18971c
+
18971c
+        inst_libdir_file 'libnfsidmap_nsswitch.so*'
18971c
+        inst_libdir_file 'libnfsidmap/*.so*'
18971c
+        inst_libdir_file 'libnfsidmap*.so*'
18971c
+
18971c
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
18971c
+            |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
18971c
+        _nsslibs=${_nsslibs#|}
18971c
+        _nsslibs=${_nsslibs%|}
18971c
+
18971c
+        inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
18971c
+
18971c
+        inst /etc/nsswitch.conf /etc/nsswitch.conf
18971c
+        inst /etc/passwd /etc/passwd
18971c
+        inst /etc/group /etc/group
18971c
+
18971c
+        cp -a -- /etc/ld.so.conf* "$initdir"/etc
18971c
+        ldconfig -r "$initdir"
18971c
+        dracut_kernel_post
18971c
+    )
18971c
+
18971c
+    # Make client root inside server root
18971c
+    (
18971c
+        export initdir="$TESTDIR"/mnt/nfs/client
18971c
+        . "$basedir"/dracut-init.sh
18971c
+        inst_multiple sh shutdown poweroff stty cat ps ln ip \
18971c
+            mount dmesg mkdir cp ping grep ls
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
+        (
18971c
+            cd "$initdir"
18971c
+            mkdir -p -- dev sys proc etc run
18971c
+            mkdir -p -- var/lib/nfs/rpc_pipefs
18971c
+        )
18971c
+        inst /etc/nsswitch.conf /etc/nsswitch.conf
18971c
+        inst /etc/passwd /etc/passwd
18971c
+        inst /etc/group /etc/group
18971c
+
18971c
+        inst_multiple rpc.idmapd /etc/idmapd.conf
18971c
+        inst_libdir_file 'libnfsidmap_nsswitch.so*'
18971c
+        inst_libdir_file 'libnfsidmap/*.so*'
18971c
+        inst_libdir_file 'libnfsidmap*.so*'
18971c
+
18971c
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
18971c
+            |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
18971c
+        _nsslibs=${_nsslibs#|}
18971c
+        _nsslibs=${_nsslibs%|}
18971c
+
18971c
+        inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
18971c
+
18971c
+        cp -a -- /etc/ld.so.conf* "$initdir"/etc
18971c
+        sudo ldconfig -r "$initdir"
18971c
+    )
18971c
+
18971c
+    sudo umount "$TESTDIR"/mnt
18971c
+    rm -fr -- "$TESTDIR"/mnt
18971c
+
18971c
+    # Make an overlay with needed tools for the test harness
18971c
+    (
18971c
+        export initdir="$TESTDIR"/overlay
18971c
+        . "$basedir"/dracut-init.sh
18971c
+        inst_multiple poweroff shutdown
18971c
+        inst_hook emergency 000 ./hard-off.sh
18971c
+        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
18971c
+    )
18971c
+
18971c
+    # Make server's dracut image
18971c
+    $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
18971c
+        --no-early-microcode \
18971c
+        -m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
18971c
+        -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
18971c
+        -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
18971c
+
18971c
+    # Make client's dracut image
18971c
+    $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
18971c
+        --no-early-microcode \
18971c
+        -o "plymouth" \
18971c
+        -a "debug" \
18971c
+        -d "af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
18971c
+        -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
18971c
+}
18971c
+
18971c
+kill_server() {
18971c
+    if [[ -s "$TESTDIR"/server.pid ]]; then
18971c
+        sudo kill -TERM -- $(cat "$TESTDIR"/server.pid)
18971c
+        rm -f -- "$TESTDIR"/server.pid
18971c
+    fi
18971c
+}
18971c
+
18971c
+test_cleanup() {
18971c
+    kill_server
18971c
+}
18971c
+
18971c
+. "$testdir"/test-functions