smbd: brl_lock_cancel does not need "blr" anymore
[Samba.git] / ctdb / tests / complex / 32_cifs_tickle.sh
blob70ce93ff4b91e8351cd2bf8b5f1e56dc4a050f0d
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Verify that CIFS connections are monitored and that CIFS tickles are sent.
8 We create a connection to the CIFS server on a node and confirm that
9 this connection is registered by CTDB. Then disable the relevant CIFS
10 server node and ensure that it send an appropriate reset packet.
12 Prerequisites:
14 * An active CTDB cluster with at least 2 nodes with public addresses.
16 * Test must be run on a real or virtual cluster rather than against
17 local daemons.
19 * Test must not be run from a cluster node.
21 * Clustered Samba must be listening on TCP port 445.
23 Steps:
25 1. Verify that the cluster is healthy.
26 2. Connect from the current host (test client) to TCP port 445 using
27 the public address of a cluster node.
28 3. Determine the source socket used for the connection.
29 4. Using the "ctdb gettickle" command, ensure that CTDB records the
30 connection details.
31 5. Disable the node that the connection has been made to.
32 6. Verify that a TCP tickle (a reset packet) is sent to the test client.
34 Expected results:
36 * CTDB should correctly record the connection and should send a reset
37 packet when the node is disabled.
38 EOF
41 . "${TEST_SCRIPTS_DIR}/integration.bash"
43 set -e
45 ctdb_test_init "$@"
47 ctdb_test_check_real_cluster
49 cluster_is_healthy
51 # Reset configuration
52 ctdb_restart_when_done
54 # We need this for later, so we know how long to sleep.
55 try_command_on_node 0 $CTDB getvar MonitorInterval
56 monitor_interval="${out#*= }"
57 #echo "Monitor interval on node $test_node is $monitor_interval seconds."
59 select_test_node_and_ips
61 test_port=445
63 echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with netcat..."
65 nc -d -w $(($monitor_interval * 4)) $test_ip $test_port &
66 nc_pid=$!
67 ctdb_test_exit_hook_add "kill $nc_pid >/dev/null 2>&1"
69 wait_until_get_src_socket "tcp" "${test_ip}:${test_port}" $nc_pid "nc"
70 src_socket="$out"
71 echo "Source socket is $src_socket"
73 # This should happen as soon as connection is up... but unless we wait
74 # we sometimes beat the registration.
75 echo "Checking if CIFS connection is tracked by CTDB..."
76 wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket
77 echo "$out"
79 if [ "${out/SRC: ${src_socket} /}" != "$out" ] ; then
80 echo "GOOD: CIFS connection tracked OK by CTDB."
81 else
82 echo "BAD: Socket not tracked by CTDB."
83 testfailures=1
86 tcptickle_sniff_start $src_socket "${test_ip}:${test_port}"
88 # The test node is only being disabled so the tickling is done from
89 # the test node. We don't need to wait until the tickles are
90 # transferred to another node.
91 echo "Disabling node $test_node"
92 try_command_on_node 1 $CTDB disable -n $test_node
93 wait_until_node_has_status $test_node disabled
95 tcptickle_sniff_wait_show