fab351
From 15ff303dde65e97ba224a9f2cc6275cbaafee52c Mon Sep 17 00:00:00 2001
fab351
From: Lubomir Rintel <lkundrak@v3.sk>
fab351
Date: Mon, 10 Jun 2019 16:05:23 +0200
fab351
Subject: [PATCH] test/BONDBRIDGETEAMVLAN: don't assert against ifcfg files
fab351
fab351
The network-manager module writes keyfiles instead of ifcfg files. Just
fab351
check whether the configuration got actually applied correctly.
fab351
fab351
(cherry picked from commit 9dfd73bcbd899d8da4bc680fa8b3326c47b939bd)
fab351
---
fab351
 test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh |  6 +-----
fab351
 test/TEST-70-BONDBRIDGETEAMVLAN/test.sh        | 12 ++++++------
fab351
 2 files changed, 7 insertions(+), 11 deletions(-)
fab351
fab351
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh
fab351
index 8c33ff0f..083e0f59 100755
fab351
--- a/test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh
fab351
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh
fab351
@@ -10,11 +10,7 @@ echo "made it to the rootfs! Powering down."
fab351
 
fab351
 (
fab351
     echo OK
fab351
-    ip -o -4 address show scope global | while read n if rest; do echo $if;done | sort
fab351
-    for i in /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-*; do
fab351
-	echo $i
fab351
-	grep -v 'UUID=' $i
fab351
-    done
fab351
+    ip -o -4 address show scope global |sed -n 's/^[^:]*: \([^ ]*\) *\(.*\) scope.*/\1 \2/p' |sort
fab351
     echo EOF
fab351
 ) > /dev/sda
fab351
 
fab351
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh
fab351
index 5618baee..b6dd080c 100755
fab351
--- a/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh
fab351
+++ b/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh
fab351
@@ -112,8 +112,8 @@ client_test() {
fab351
         done
fab351
     } < "$TESTDIR"/client.img || return 1
fab351
 
fab351
-    if [[ "$check" != "$CONF" ]]; then
fab351
-        echo "Expected: '$check'"
fab351
+    if [[ ! "$CONF" =~ ^$check$ ]]; then
fab351
+        echo "Expected: /^$check\$/"
fab351
         echo
fab351
         echo
fab351
         echo "Got:      '$CONF'"
fab351
@@ -150,7 +150,7 @@ ip=192.168.57.104::192.168.57.1:24:test:ens5.0004:none
fab351
 rd.neednet=1
fab351
 root=nfs:192.168.50.1:/nfs/client bootdev=ens3
fab351
 " \
fab351
-    'ens3 ens5.0004 ens5.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-ens5.0004 # Generated by dracut initrd NAME="ens5.0004" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.57.104" PREFIX="24" GATEWAY="192.168.57.1" TYPE=Vlan DEVICE="ens5.0004" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5.3 # Generated by dracut initrd NAME="ens5.3" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.56.103" PREFIX="24" GATEWAY="192.168.56.1" TYPE=Vlan DEVICE="ens5.3" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan0001 # Generated by dracut initrd NAME="vlan0001" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.54.101" PREFIX="24" GATEWAY="192.168.54.1" TYPE=Vlan DEVICE="vlan0001" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan2 # Generated by dracut initrd NAME="vlan2" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.55.102" PREFIX="24" GATEWAY="192.168.55.1" TYPE=Vlan DEVICE="vlan2" VLAN=yes PHYSDEV="ens5" EOF ' \
fab351
+    'ens3 inet 192\.168\.50\.[0-9]*/24 brd 192\.168\.50\.255 ens5\.0004 inet 192\.168\.57\.104/24 brd 192\.168\.57\.255 ens5\.3 inet 192\.168\.56\.103/24 brd 192\.168\.56\.255 vlan0001 inet 192\.168\.54\.101/24 brd 192\.168\.54\.255 vlan2 inet 192\.168\.55\.102/24 brd 192\.168\.55\.255 EOF ' \
fab351
     || return 1
fab351
 
fab351
     client_test "Multiple Bonds" \
fab351
@@ -163,7 +163,7 @@ ip=bond1:dhcp
fab351
 rd.neednet=1
fab351
 root=nfs:192.168.50.1:/nfs/client bootdev=bond0
fab351
 " \
fab351
-    '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 ' \
fab351
+    'bond0 inet 192\.168\.50\.[0-9]*/24 brd 192\.168\.50\.255 bond1 inet 192\.168\.51\.[0-9]*/24 brd 192\.168\.51\.255 EOF ' \
fab351
     || return 1
fab351
 
fab351
     client_test "Multiple Bridges" \
fab351
@@ -176,7 +176,7 @@ ip=br1:dhcp
fab351
 rd.neednet=1
fab351
 root=nfs:192.168.50.1:/nfs/client bootdev=br0
fab351
 " \
fab351
-    '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 ' \
fab351
+    'br0 inet 192\.168\.50\.[0-9]*/24 brd 192\.168\.50\.255 br1 inet 192\.168\.51\.[0-9]*/24 brd 192\.168\.51\.255 EOF ' \
fab351
     || return 1
fab351
 
fab351
     kill_server
fab351
@@ -260,7 +260,7 @@ test_setup() {
fab351
         export initdir="$TESTDIR"/mnt/nfs/client
fab351
         . "$basedir"/dracut-init.sh
fab351
         inst_multiple sh shutdown poweroff stty cat ps ln ip \
fab351
-            mount dmesg mkdir cp ping grep ls sort
fab351
+            mount dmesg mkdir cp ping grep ls sort sed
fab351
         for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
fab351
             [[ -f ${_terminfodir}/l/linux ]] && break
fab351
         done
fab351