ctdb-tests: Avoid bulk output in $out, prefer $outfile
[samba.git] / ctdb / tests / complex / 37_nfs_reset_server.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that the server end of an NFS connection is correctly reset
7
8 Prerequisites:
9
10 * An active CTDB cluster with at least 2 nodes with public addresses.
11
12 * Test must be run on a real or virtual cluster rather than against
13   local daemons.
14
15 * Test must not be run from a cluster node.
16
17 * Cluster nodes must be listening on the NFS TCP port (2049).
18
19 Expected results:
20
21 * CTDB should correctly record the connection and the releasing node
22   should reset the server end of the connection.
23 EOF
24 }
25
26 . "${TEST_SCRIPTS_DIR}/integration.bash"
27
28 set -e
29
30 ctdb_test_init
31
32 ctdb_test_check_real_cluster
33
34 cluster_is_healthy
35
36 # We need this for later, so we know how long to sleep.
37 try_command_on_node 0 $CTDB getvar MonitorInterval
38 monitor_interval="${out#*= }"
39
40 select_test_node_and_ips
41
42 test_port=2049
43
44 echo "Set NoIPTakeover=1 on all nodes"
45 try_command_on_node all $CTDB setvar NoIPTakeover 1
46
47 echo "Give the recovery daemon some time to reload tunables"
48 sleep_for 5
49
50 echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with nc..."
51
52 sleep $((monitor_interval * 4)) | nc $test_ip $test_port &
53 nc_pid=$!
54 ctdb_test_exit_hook_add "kill $nc_pid >/dev/null 2>&1"
55
56 wait_until_get_src_socket "tcp" "${test_ip}:${test_port}" $nc_pid "nc"
57 src_socket="$out"
58 echo "Source socket is $src_socket"
59
60 echo "Wait until NFS connection is tracked by CTDB on test node ..."
61 wait_until $((monitor_interval * 2)) \
62            check_tickles $test_node $test_ip $test_port $src_socket
63 cat "$outfile"
64
65 # It would be nice if ss consistently used local/peer instead of src/dst
66 ss_filter="src ${test_ip}:${test_port} dst ${src_socket}"
67
68 try_command_on_node $test_node \
69                     "ss -tn state established '${ss_filter}' | tail -n +2"
70 if [ -z "$out" ] ; then
71         echo "BAD: ss did not list the socket"
72         exit 1
73 fi
74 echo "GOOD: ss lists the socket:"
75 cat "$outfile"
76
77 echo "Disabling node $test_node"
78 try_command_on_node 1 $CTDB disable -n $test_node
79 wait_until_node_has_status $test_node disabled
80
81 try_command_on_node $test_node \
82                     "ss -tn state established '${ss_filter}' | tail -n +2"
83 if [ -n "$out" ] ; then
84         echo "BAD: ss listed the socket after failover"
85         exit 1
86 fi
87 echo "GOOD: ss no longer lists the socket"