replmd: Use replmd_set_la_val() when adding new links
[Samba.git] / ctdb / tests / complex / 36_smb_reset_server.sh
blob5723ac7e0252657d6698c1f4139a165c8ae74774
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Verify that the server end of an SMB connection is correctly reset
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.
19 Expected results:
21 * CTDB should correctly record the connection and the releasing node
22 should reset the server end of the connection.
23 EOF
26 . "${TEST_SCRIPTS_DIR}/integration.bash"
28 set -e
30 ctdb_test_init "$@"
32 ctdb_test_check_real_cluster
34 cluster_is_healthy
36 # Reset configuration
37 ctdb_restart_when_done
39 # We need this for later, so we know how long to sleep.
40 try_command_on_node 0 $CTDB getvar MonitorInterval
41 monitor_interval="${out#*= }"
43 select_test_node_and_ips
45 test_port=445
47 echo "Set NoIPTakeover=1 on all nodes"
48 try_command_on_node all $CTDB setvar NoIPTakeover 1
50 echo "Give the recovery daemon some time to reload tunables"
51 sleep_for 5
53 echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with nc..."
55 nc -d -w $(($monitor_interval * 4)) $test_ip $test_port &
56 nc_pid=$!
57 ctdb_test_exit_hook_add "kill $nc_pid >/dev/null 2>&1"
59 wait_until_get_src_socket "tcp" "${test_ip}:${test_port}" $nc_pid "nc"
60 src_socket="$out"
61 echo "Source socket is $src_socket"
63 # This should happen as soon as connection is up... but unless we wait
64 # we sometimes beat the registration.
65 echo "Checking if CIFS connection is tracked by CTDB on test node..."
66 wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket
67 echo "$out"
69 if [ "${out/SRC: ${src_socket} /}" != "$out" ] ; then
70 echo "GOOD: CIFS connection tracked OK by CTDB."
71 else
72 echo "BAD: Socket not tracked by CTDB."
73 exit 1
76 # It would be nice if ss consistently used local/peer instead of src/dst
77 ss_filter="src ${test_ip}:${test_port} dst ${src_socket}"
79 try_command_on_node $test_node \
80 "ss -tn state established '${ss_filter}' | tail -n +2"
81 if [ -z "$out" ] ; then
82 echo "BAD: ss did not list the socket"
83 exit 1
85 echo "GOOD: ss lists the socket:"
86 echo "$out"
88 echo "Disabling node $test_node"
89 try_command_on_node 1 $CTDB disable -n $test_node
90 wait_until_node_has_status $test_node disabled
92 try_command_on_node $test_node \
93 "ss -tn state established '${ss_filter}' | tail -n +2"
94 if [ -n "$out" ] ; then
95 echo "BAD: ss listed the socket after failover"
96 exit 1
98 echo "GOOD: ss no longer lists the socket"