ctdb-tests: Drop use of confusing testfailures variable
[samba.git] / ctdb / tests / complex / 33_gratuitous_arp.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that a gratuitous ARP is sent when a node is failed out.
7
8 We ping a public IP and lookup the MAC address in the ARP table.  We
9 then disable the node and check the ARP table again - the MAC address
10 should have changed.  This test does NOT test connectivity after the
11 failover.
12
13 Prerequisites:
14
15 * An active CTDB cluster with at least 2 nodes with public addresses.
16
17 * Test must be run on a real or virtual cluster rather than against
18   local daemons.
19
20 * Test must not be run from a cluster node.
21
22 Steps:
23
24 1. Verify that the cluster is healthy.
25 2. Select a public address and its corresponding node.
26 3. Remove any entries for the chosen address from the ARP table.
27 4. Send a single ping request packet to the selected public address.
28 5. Determine the MAC address corresponding to the public address by
29    checking the ARP table.
30 6. Disable the selected node.
31 7. Check the ARP table and check the MAC associated with the public
32    address.
33
34 Expected results:
35
36 * When a node is disabled the MAC address associated with public
37   addresses on that node should change.
38 EOF
39 }
40
41 . "${TEST_SCRIPTS_DIR}/integration.bash"
42
43 set -e
44
45 ctdb_test_init "$@"
46
47 ctdb_test_check_real_cluster
48
49 cluster_is_healthy
50
51 # Reset configuration
52 ctdb_restart_when_done
53
54 select_test_node_and_ips
55
56 echo "Removing ${test_ip} from the local ARP table..."
57 ip neigh flush "$test_prefix" >/dev/null 2>&1 || true
58
59 echo "Pinging ${test_ip}..."
60 ping_wrapper -q -n -c 1 $test_ip
61
62 echo "Getting MAC address associated with ${test_ip}..."
63 original_mac=$(ip neigh show $test_prefix | awk '$4 == "lladdr" {print $5}')
64 [ -n "$original_mac" ] || die "Couldn't get MAC address for ${test_prefix}"
65
66 echo "MAC address is: ${original_mac}"
67
68 gratarp_sniff_start
69
70 echo "Disabling node $test_node"
71 try_command_on_node 1 $CTDB disable -n $test_node
72 wait_until_node_has_status $test_node disabled
73
74 gratarp_sniff_wait_show
75
76 echo "Getting MAC address associated with ${test_ip} again..."
77 new_mac=$(ip neigh show $test_prefix | awk '$4 == "lladdr" {print $5}')
78 [ -n "$new_mac" ] || die "Couldn't get MAC address for ${test_prefix}"
79
80 echo "MAC address is: ${new_mac}"
81
82 if [ "$original_mac" != "$new_mac" ] ; then
83     echo "GOOD: MAC address changed"
84 else
85     die "BAD: MAC address did not change"
86 fi