From b07262bb0425be8c48bd0c85922a02b7ff6e6373 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Thu, 14 Oct 2021 10:58:08 +0800 Subject: [PATCH] thorough tests on network --- tests/scripts/kexec-kdump-test/init.sh | 48 +++++++++++++++++++ .../testcases/nfs-kdump-bonding/0-server.sh | 41 ++++++++++++++++ .../testcases/nfs-kdump-bonding/1-client.sh | 32 +++++++++++++ .../nfs-kdump-bridge_over_bonding/0-server.sh | 41 ++++++++++++++++ .../nfs-kdump-bridge_over_bonding/1-client.sh | 32 +++++++++++++ .../nfs-kdump-vlan_over_bonding/0-server.sh | 32 +++++++++++++ .../nfs-kdump-vlan_over_bonding/1-client.sh | 32 +++++++++++++ .../nfs-kdump-vlan_over_phy/0-server.sh | 32 +++++++++++++ .../nfs-kdump-vlan_over_phy/1-client.sh | 33 +++++++++++++ 9 files changed, 323 insertions(+) create mode 100755 tests/scripts/testcases/nfs-kdump-bonding/0-server.sh create mode 100755 tests/scripts/testcases/nfs-kdump-bonding/1-client.sh create mode 100755 tests/scripts/testcases/nfs-kdump-bridge_over_bonding/0-server.sh create mode 100755 tests/scripts/testcases/nfs-kdump-bridge_over_bonding/1-client.sh create mode 100755 tests/scripts/testcases/nfs-kdump-vlan_over_bonding/0-server.sh create mode 100755 tests/scripts/testcases/nfs-kdump-vlan_over_bonding/1-client.sh create mode 100755 tests/scripts/testcases/nfs-kdump-vlan_over_phy/0-server.sh create mode 100755 tests/scripts/testcases/nfs-kdump-vlan_over_phy/1-client.sh diff --git a/tests/scripts/kexec-kdump-test/init.sh b/tests/scripts/kexec-kdump-test/init.sh index deacb51c..361a2570 100755 --- a/tests/scripts/kexec-kdump-test/init.sh +++ b/tests/scripts/kexec-kdump-test/init.sh @@ -40,6 +40,54 @@ test_passed() { exit 0 } +setup_bond_connection() { + nmcli con add type bond ifname mybond0 + nmcli con add type ethernet ifname eth0 master mybond0 + nmcli con up bond-slave-eth0 || return 1 +} + +setup_team_connection() { + nmcli con add type team ifname myteam0 + nmcli con add type ethernet ifname eth0 master myteam0 + nmcli con up team-slave-eth0 || return 1 +} + +setup_bridige_over_bond_connection() { + setup_bond_connection || return 1 + nmcli con add type bridge ifname br0 + nmcli con modify bond-mybond0 master br0 slave-type bridge + nmcli con up bond-mybond0 || return 1 + +} + +setup_vlan_over_phy_connection() { + nmcli connection add type vlan con-name vlan9 dev eth0 vlan.id 9 + nmcli c up vlan9 || return 1 +} + +setup_vlan_over_bond_connection() { + setup_bond_connection || return 1 + nmcli c add type vlan con-name vlan9 dev mybond0 id 9 + nmcli c up vlan9 || return 1 +} + +setup_vlan_over_team_connection() { + setup_team_connection || return 1 + nmcli c add type vlan con-name vlan9 dev myteam0 id 9 + nmcli c up vlan9 || return 1 +} + +setup_bridge_over_vlan_over_team_connection() { + setup_vlan_over_team_connection || return 1 + # if STP enabled, a forwarding delay of 15 seconds on boot + # would occur. So disable STP. + nmcli con add type bridge ifname br0 stp no + + nmcli con modify vlan9 master br0 slave-type bridge + nmcli c up vlan9 || return 1 + nmcli c up bridge-br0 || return 1 +} + test_failed() { echo -e "${_RED}TEST FAILED${_NC}" > /dev/ttyS1 echo -e "${_RED}kexec-kdump-test: TEST FAILED${_NC}" > /dev/ttyS0 diff --git a/tests/scripts/testcases/nfs-kdump-bonding/0-server.sh b/tests/scripts/testcases/nfs-kdump-bonding/0-server.sh new file mode 100755 index 00000000..cf54e70a --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump-bonding/0-server.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils dnsmasq" + + img_run_cmd "mkdir -p /srv/nfs/var/crash" + img_run_cmd "echo /srv/nfs 192.168.77.1/24\(rw,async,insecure,no_root_squash\) > /etc/exports" + img_run_cmd "systemctl enable nfs-server" + + img_run_cmd "touch /etc/systemd/resolved.conf" + img_run_cmd "echo DNSStubListener=no >> /etc/systemd/resolved.conf" + + img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf" + img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf" + img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf" + img_run_cmd "systemctl enable dnsmasq" + + img_run_cmd 'echo DEVICE="eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo BOOTPROTO="none" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo ONBOOT="yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo PREFIX="24" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo IPADDR="192.168.77.1" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo TYPE="Ethernet" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + + img_add_qemu_cmd "-nic socket,listen=:8010,mac=52:54:00:12:34:56" +} + +# Executed when VM boots +on_test() { + while true; do + if has_valid_vmcore_dir /srv/nfs/var/crash; then + # Wait a few seconds so client finish it's work to generate a full log + sleep 5 + + test_passed + fi + + sleep 1 + done +} diff --git a/tests/scripts/testcases/nfs-kdump-bonding/1-client.sh b/tests/scripts/testcases/nfs-kdump-bonding/1-client.sh new file mode 100755 index 00000000..ae1b74d0 --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump-bonding/1-client.sh @@ -0,0 +1,32 @@ +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils" + img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57" +} + +on_test() { + local boot_count=$(get_test_boot_count) + local nfs_server=192.168.77.1 + + if [ "$boot_count" -eq 1 ]; then + setup_bond_connection || test_failed "Failed to bring up bonding network connection" + cat << EOF > /etc/kdump.conf +nfs $nfs_server:/srv/nfs +core_collector makedumpfile -l --message-level 7 -d 31 +EOF + + ip addr show + while ! ping -c 1 $nfs_server -W 1; do + sleep 1 + done + + kdumpctl start || test_failed "Failed to start kdump" + + sync + + echo 1 > /proc/sys/kernel/sysrq + echo c > /proc/sysrq-trigger + else + shutdown -h 0 + fi +} diff --git a/tests/scripts/testcases/nfs-kdump-bridge_over_bonding/0-server.sh b/tests/scripts/testcases/nfs-kdump-bridge_over_bonding/0-server.sh new file mode 100755 index 00000000..cf54e70a --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump-bridge_over_bonding/0-server.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils dnsmasq" + + img_run_cmd "mkdir -p /srv/nfs/var/crash" + img_run_cmd "echo /srv/nfs 192.168.77.1/24\(rw,async,insecure,no_root_squash\) > /etc/exports" + img_run_cmd "systemctl enable nfs-server" + + img_run_cmd "touch /etc/systemd/resolved.conf" + img_run_cmd "echo DNSStubListener=no >> /etc/systemd/resolved.conf" + + img_run_cmd "echo interface=eth0 > /etc/dnsmasq.conf" + img_run_cmd "echo dhcp-authoritative >> /etc/dnsmasq.conf" + img_run_cmd "echo dhcp-range=192.168.77.50,192.168.77.100,255.255.255.0,12h >> /etc/dnsmasq.conf" + img_run_cmd "systemctl enable dnsmasq" + + img_run_cmd 'echo DEVICE="eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo BOOTPROTO="none" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo ONBOOT="yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo PREFIX="24" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo IPADDR="192.168.77.1" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + img_run_cmd 'echo TYPE="Ethernet" >> /etc/sysconfig/network-scripts/ifcfg-eth0' + + img_add_qemu_cmd "-nic socket,listen=:8010,mac=52:54:00:12:34:56" +} + +# Executed when VM boots +on_test() { + while true; do + if has_valid_vmcore_dir /srv/nfs/var/crash; then + # Wait a few seconds so client finish it's work to generate a full log + sleep 5 + + test_passed + fi + + sleep 1 + done +} diff --git a/tests/scripts/testcases/nfs-kdump-bridge_over_bonding/1-client.sh b/tests/scripts/testcases/nfs-kdump-bridge_over_bonding/1-client.sh new file mode 100755 index 00000000..9463093f --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump-bridge_over_bonding/1-client.sh @@ -0,0 +1,32 @@ +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils" + img_add_qemu_cmd "-nic socket,connect=127.0.0.1:8010,mac=52:54:00:12:34:57" +} + +on_test() { + local boot_count=$(get_test_boot_count) + local nfs_server=192.168.77.1 + + if [ "$boot_count" -eq 1 ]; then + setup_bridige_over_bond_connection || test_failed "Failed to bring up bonding network connection" + cat << EOF > /etc/kdump.conf +nfs $nfs_server:/srv/nfs +core_collector makedumpfile -l --message-level 7 -d 31 +EOF + + ip addr show + while ! ping -c 1 $nfs_server -W 1; do + sleep 1 + done + + kdumpctl start || test_failed "Failed to start kdump" + + sync + + echo 1 > /proc/sys/kernel/sysrq + echo c > /proc/sysrq-trigger + else + shutdown -h 0 + fi +} diff --git a/tests/scripts/testcases/nfs-kdump-vlan_over_bonding/0-server.sh b/tests/scripts/testcases/nfs-kdump-vlan_over_bonding/0-server.sh new file mode 100755 index 00000000..96bf3f55 --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump-vlan_over_bonding/0-server.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils dnsmasq" + + img_run_cmd "mkdir -p /srv/nfs/var/crash" + img_run_cmd "echo /srv/nfs 192.168.200.10/24\(rw,async,insecure,no_root_squash\) > /etc/exports" + img_run_cmd "systemctl enable nfs-server" + + img_add_qemu_cmd "-device e1000,netdev=network0,mac=52:54:00:12:34:56 -netdev tap,id=network0,ifname=tap1,script=no,downscript=no" +} + +# Executed when VM boots +on_test() { + nmcli c add type vlan con-name vlan9 dev eth0 id 9 + nmcli c modify vlan9 ipv4.addresses 192.168.200.10/24 + nmcli c modify vlan9 ipv4.method manual + nmcli c up vlan9 + ip addr show + + while true; do + if has_valid_vmcore_dir /srv/nfs/var/crash; then + # Wait a few seconds so client finish it's work to generate a full log + sleep 5 + + test_passed + fi + + sleep 1 + done +} diff --git a/tests/scripts/testcases/nfs-kdump-vlan_over_bonding/1-client.sh b/tests/scripts/testcases/nfs-kdump-vlan_over_bonding/1-client.sh new file mode 100755 index 00000000..e7c9aa17 --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump-vlan_over_bonding/1-client.sh @@ -0,0 +1,32 @@ +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils" + img_add_qemu_cmd "-device e1000,netdev=network0,mac=52:54:00:12:34:57 -netdev tap,id=network0,ifname=tap0,script=no,downscript=no" +} + + +on_test() { + local boot_count=$(get_test_boot_count) + local nfs_server=192.168.200.10 + + if [ "$boot_count" -eq 1 ]; then + setup_vlan_over_bond_connection || test_failed "Failed to bring up VLAN network connection over bonding network" + cat << EOF > /etc/kdump.conf +nfs $nfs_server:/srv/nfs +core_collector makedumpfile -l --message-level 7 -d 31 +EOF + + while ! ping -c 1 $nfs_server -W 1; do + sleep 1 + done + + kdumpctl start || test_failed "Failed to start kdump" + + sync + + echo 1 > /proc/sys/kernel/sysrq + echo c > /proc/sysrq-trigger + else + shutdown -h 0 + fi +} diff --git a/tests/scripts/testcases/nfs-kdump-vlan_over_phy/0-server.sh b/tests/scripts/testcases/nfs-kdump-vlan_over_phy/0-server.sh new file mode 100755 index 00000000..96bf3f55 --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump-vlan_over_phy/0-server.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils dnsmasq" + + img_run_cmd "mkdir -p /srv/nfs/var/crash" + img_run_cmd "echo /srv/nfs 192.168.200.10/24\(rw,async,insecure,no_root_squash\) > /etc/exports" + img_run_cmd "systemctl enable nfs-server" + + img_add_qemu_cmd "-device e1000,netdev=network0,mac=52:54:00:12:34:56 -netdev tap,id=network0,ifname=tap1,script=no,downscript=no" +} + +# Executed when VM boots +on_test() { + nmcli c add type vlan con-name vlan9 dev eth0 id 9 + nmcli c modify vlan9 ipv4.addresses 192.168.200.10/24 + nmcli c modify vlan9 ipv4.method manual + nmcli c up vlan9 + ip addr show + + while true; do + if has_valid_vmcore_dir /srv/nfs/var/crash; then + # Wait a few seconds so client finish it's work to generate a full log + sleep 5 + + test_passed + fi + + sleep 1 + done +} diff --git a/tests/scripts/testcases/nfs-kdump-vlan_over_phy/1-client.sh b/tests/scripts/testcases/nfs-kdump-vlan_over_phy/1-client.sh new file mode 100755 index 00000000..ab14372c --- /dev/null +++ b/tests/scripts/testcases/nfs-kdump-vlan_over_phy/1-client.sh @@ -0,0 +1,33 @@ +# Executed before VM starts +on_build() { + img_inst_pkg "nfs-utils" + img_add_qemu_cmd "-device e1000,netdev=network0,mac=52:54:00:12:34:57 -netdev tap,id=network0,ifname=tap0,script=no,downscript=no" +} + + +on_test() { + local boot_count=$(get_test_boot_count) + local nfs_server=192.168.200.10 + + if [ "$boot_count" -eq 1 ]; then + setup_vlan_over_phy_connection || test_failed "Failed to bring up VLAN network connection over teaming network" + cat << EOF > /etc/kdump.conf +nfs $nfs_server:/srv/nfs +core_collector makedumpfile -l --message-level 7 -d 31 +EOF + + ip addr show + while ! ping -c 1 $nfs_server -W 1; do + sleep 1 + done + + kdumpctl start || test_failed "Failed to start kdump" + + sync + + echo 1 > /proc/sys/kernel/sysrq + echo c > /proc/sysrq-trigger + else + shutdown -h 0 + fi +}