Skip to content

Commit

Permalink
thorough tests on network
Browse files Browse the repository at this point in the history
  • Loading branch information
coiby committed Apr 15, 2022
1 parent 57a60a3 commit b07262b
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/scripts/kexec-kdump-test/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions tests/scripts/testcases/nfs-kdump-bonding/0-server.sh
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 32 additions & 0 deletions tests/scripts/testcases/nfs-kdump-bonding/1-client.sh
Original file line number Diff line number Diff line change
@@ -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
}
41 changes: 41 additions & 0 deletions tests/scripts/testcases/nfs-kdump-bridge_over_bonding/0-server.sh
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 32 additions & 0 deletions tests/scripts/testcases/nfs-kdump-bridge_over_bonding/1-client.sh
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 32 additions & 0 deletions tests/scripts/testcases/nfs-kdump-vlan_over_bonding/0-server.sh
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 32 additions & 0 deletions tests/scripts/testcases/nfs-kdump-vlan_over_bonding/1-client.sh
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 32 additions & 0 deletions tests/scripts/testcases/nfs-kdump-vlan_over_phy/0-server.sh
Original file line number Diff line number Diff line change
@@ -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
}
33 changes: 33 additions & 0 deletions tests/scripts/testcases/nfs-kdump-vlan_over_phy/1-client.sh
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit b07262b

Please sign in to comment.