ctdb-tests: Add tickle test for external public address handling
[Samba.git] / ctdb / tests / complex / 35_cifs_external_tickle.sh
blobfabe81b5c0a0b807b9fdac66c1c029d65f48d16b
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 For external IP address management, verify that CIFS tickles are sent.
8 Prerequisites:
10 * An active CTDB cluster with at least 2 nodes with public addresses.
12 * Test must be run on a real or virtual cluster rather than against
13 local daemons.
15 * Test must not be run from a cluster node.
17 * Clustered Samba must be listening on TCP port 445.
18 EOF
21 . "${TEST_SCRIPTS_DIR}/integration.bash"
23 set -e
25 ctdb_test_init "$@"
27 ctdb_test_check_real_cluster
29 cluster_is_healthy
31 # Reset configuration
32 ctdb_restart_when_done
34 select_test_node_and_ips
36 # Select a different node to move the IP address to
37 to_node=""
38 while read x to_node ; do
39 if [ "$to_node" != "$test_node" ] ; then
40 break
42 done <<<"$out"
43 if [ -z "$to_node" ] ; then
44 die "BAD: Unable to find a target node different to ${to_node}"
47 echo "Get mask and interface for ${test_ip}"
48 get_test_ip_mask_and_iface
50 echo "Set DisableIPFailover=1 on all nodes"
51 try_command_on_node all $CTDB setvar DisableIPFailover 1
53 echo "Give the recovery daemon some time to reload tunables"
54 sleep_for 5
56 my_exit_hook ()
58 onnode -q all $CTDB enablescript "10.interface"
59 onnode -q all $CTDB disablescript "10.external"
61 ctdb_test_exit_hook_add my_exit_hook
63 echo "Disable 10.interface on all nodes"
64 try_command_on_node all $CTDB disablescript 10.interface
65 echo "Enable 10.external on all nodes"
66 try_command_on_node all $CTDB enablescript 10.external
68 test_port=445
70 echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with netcat..."
72 nc -d -w 60 $test_ip $test_port &
73 nc_pid=$!
74 ctdb_test_exit_hook_add "kill $nc_pid >/dev/null 2>&1"
76 wait_until_get_src_socket "tcp" "${test_ip}:${test_port}" $nc_pid "nc"
77 src_socket="$out"
78 echo "Source socket is $src_socket"
80 # This should happen as soon as connection is up... but unless we wait
81 # we sometimes beat the registration.
82 echo "Checking if CIFS connection is tracked by CTDB..."
83 wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket
84 echo "$out"
86 if [ "${out/SRC: ${src_socket} /}" != "$out" ] ; then
87 echo "GOOD: CIFS connection tracked OK by CTDB."
88 else
89 echo "BAD: Socket not tracked by CTDB."
90 testfailures=1
93 tcptickle_sniff_start $src_socket "${test_ip}:${test_port}"
95 echo "Moving $test_ip from $test_node to $to_node"
96 try_command_on_node $test_node ip addr del "${test_ip}/${mask}" dev "$iface"
97 try_command_on_node $to_node ip addr add "${test_ip}/${mask}" dev "$iface"
98 try_command_on_node $to_node ctdb moveip "$test_ip" "$to_node"
100 wait_until_ips_are_on_node "$to_node" "$test_ip"
102 tcptickle_sniff_wait_show