From: Martin Schwenke Date: Wed, 8 Jul 2009 03:37:52 +0000 (+1000) Subject: Test suite: new tests and code factoring. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=de0b58e18fcc0f90075fca74077ab62ae8dab5da;p=metze%2Fctdb%2Fwip.git Test suite: new tests and code factoring. * 2 new tests for NFS failover. * Factor repeated code from tests into new functions select_test_node_and_ips(), gratarp_sniff_start() and gratarp_sniff_wait_show(). Use these new functions in existing and new tests. Signed-off-by: Martin Schwenke --- diff --git a/tests/complex/31_nfs_tickle.sh b/tests/complex/31_nfs_tickle.sh index bbea663a..45734cc7 100755 --- a/tests/complex/31_nfs_tickle.sh +++ b/tests/complex/31_nfs_tickle.sh @@ -57,23 +57,8 @@ try_command_on_node 0 $CTDB getvar MonitorInterval monitor_interval="${out#*= }" #echo "Monitor interval on node $test_node is $monitor_interval seconds." -echo "Getting list of public IPs..." -try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'" +select_test_node_and_ips -# When selecting test_node we just want a node that has public IPs. -# This will work and is economically semi-randomly. :-) -read x test_node <<<"$out" - -ips="" -while read ip pnn ; do - if [ "$pnn" = "$test_node" ] ; then - ips="${ips}${ips:+ }${ip}" - fi -done <<<"$out" # bashism to avoid problem setting variable in pipeline. - -echo "Selected node ${test_node} with IPs: $ips" - -test_ip="${ips%% *}" test_port=2049 echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with netcat..." diff --git a/tests/complex/32_cifs_tickle.sh b/tests/complex/32_cifs_tickle.sh index d024e7fc..94b28617 100755 --- a/tests/complex/32_cifs_tickle.sh +++ b/tests/complex/32_cifs_tickle.sh @@ -56,23 +56,8 @@ try_command_on_node 0 $CTDB getvar MonitorInterval monitor_interval="${out#*= }" #echo "Monitor interval on node $test_node is $monitor_interval seconds." -echo "Getting list of public IPs..." -try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'" +select_test_node_and_ips -# When selecting test_node we just want a node that has public IPs. -# This will work and is economically semi-randomly. :-) -read x test_node <<<"$out" - -ips="" -while read ip pnn ; do - if [ "$pnn" = "$test_node" ] ; then - ips="${ips}${ips:+ }${ip}" - fi -done <<<"$out" # bashism to avoid problem setting variable in pipeline. - -echo "Selected node ${test_node} with IPs: $ips" - -test_ip="${ips%% *}" test_port=445 echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with netcat..." diff --git a/tests/complex/33_gratuitous_arp.sh b/tests/complex/33_gratuitous_arp.sh index c5e8b81f..e94a9146 100755 --- a/tests/complex/33_gratuitous_arp.sh +++ b/tests/complex/33_gratuitous_arp.sh @@ -51,23 +51,7 @@ cluster_is_healthy # Reset configuration ctdb_restart_when_done -echo "Getting list of public IPs..." -try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'" - -# When selecting test_node we just want a node that has public IPs. -# This will work and is economically semi-randomly. :-) -read x test_node <<<"$out" - -ips="" -while read ip pnn ; do - if [ "$pnn" = "$test_node" ] ; then - ips="${ips}${ips:+ }${ip}" - fi -done <<<"$out" # bashism to avoid problem setting variable in pipeline. - -echo "Selected node ${test_node} with IPs: $ips" - -test_ip="${ips%% *}" +select_test_node_and_ips echo "Removing ${test_ip} from the local ARP table..." arp -d $test_ip >/dev/null 2>&1 || true @@ -81,17 +65,13 @@ original_mac=$(arp -n $test_ip | awk '$2 == "ether" {print $3}') echo "MAC address is: ${original_mac}" -filter="arp net ${test_ip}" -tcpdump_start "$filter" +gratarp_sniff_start echo "Disabling node $test_node" try_command_on_node 1 $CTDB disable -n $test_node onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node disabled -tcpdump_wait 2 - -echo "GOOD: this should be the gratuitous ARP and the reply:" -tcpdump_show +gratarp_sniff_wait_show echo "Getting MAC address associated with ${test_ip} again..." new_mac=$(arp -n $test_ip | awk '$2 == "ether" {print $3}') diff --git a/tests/complex/41_failover_ping_discrete.sh b/tests/complex/41_failover_ping_discrete.sh index f9351e4b..32841c53 100755 --- a/tests/complex/41_failover_ping_discrete.sh +++ b/tests/complex/41_failover_ping_discrete.sh @@ -45,23 +45,7 @@ cluster_is_healthy # Reset configuration ctdb_restart_when_done -echo "Getting list of public IPs..." -try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'" - -# When selecting test_node we just want a node that has public IPs. -# This will work and is economically semi-randomly. :-) -read x test_node <<<"$out" - -ips="" -while read ip pnn ; do - if [ "$pnn" = "$test_node" ] ; then - ips="${ips}${ips:+ }${ip}" - fi -done <<<"$out" # bashism to avoid problem setting variable in pipeline. - -echo "Selected node ${test_node} with IPs: $ips" - -test_ip="${ips%% *}" +select_test_node_and_ips echo "Removing ${test_ip} from the local ARP table..." arp -d $test_ip >/dev/null 2>&1 || true @@ -69,17 +53,13 @@ arp -d $test_ip >/dev/null 2>&1 || true echo "Pinging ${test_ip}..." ping -q -n -c 1 $test_ip -filter="arp net ${test_ip}" -tcpdump_start "$filter" +gratarp_sniff_start echo "Disabling node $test_node" try_command_on_node 1 $CTDB disable -n $test_node onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node disabled -tcpdump_wait 2 - -echo "GOOD: this should be the gratuitous ARP and the reply:" -tcpdump_show +gratarp_sniff_wait_show echo "Removing ${test_ip} from the local ARP table again..." arp -d $test_ip >/dev/null 2>&1 || true diff --git a/tests/complex/42_failover_ssh_hostname.sh b/tests/complex/42_failover_ssh_hostname.sh index 7aa9cd87..19652487 100755 --- a/tests/complex/42_failover_ssh_hostname.sh +++ b/tests/complex/42_failover_ssh_hostname.sh @@ -45,23 +45,7 @@ cluster_is_healthy # Reset configuration ctdb_restart_when_done -echo "Getting list of public IPs..." -try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'" - -# When selecting test_node we just want a node that has public IPs. -# This will work and is economically semi-randomly. :-) -read x test_node <<<"$out" - -ips="" -while read ip pnn ; do - if [ "$pnn" = "$test_node" ] ; then - ips="${ips}${ips:+ }${ip}" - fi -done <<<"$out" # bashism to avoid problem setting variable in pipeline. - -echo "Selected node ${test_node} with IPs: $ips" - -test_ip="${ips%% *}" +select_test_node_and_ips echo "Removing ${test_ip} from the local ARP table..." arp -d $test_ip >/dev/null 2>&1 || true @@ -72,17 +56,13 @@ original_hostname=$(ssh $test_ip hostname) echo "Hostname is: ${original_hostname}" -filter="arp net ${test_ip}" -tcpdump_start "$filter" +gratarp_sniff_start echo "Disabling node $test_node" try_command_on_node 1 $CTDB disable -n $test_node onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node disabled -tcpdump_wait 2 - -echo "GOOD: this should be the gratuitous ARP and the reply:" -tcpdump_show +gratarp_sniff_wait_show echo "SSHing to ${test_ip} and running hostname (again)..." new_hostname=$(ssh $test_ip hostname) diff --git a/tests/complex/43_failover_nfs_basic.sh b/tests/complex/43_failover_nfs_basic.sh new file mode 100755 index 00000000..aa3a65ca --- /dev/null +++ b/tests/complex/43_failover_nfs_basic.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +test_info() +{ + cat <