| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # Verify that NFS connections are monitored and that NFS tickles are sent. |
| 4 | |
| 5 | # We create a connection to the NFS server on a node and confirm that |
| 6 | # this connection is registered in the nfs-tickles/ subdirectory in |
| 7 | # shared storage. Then kill ctdbd on the relevant NFS server node and |
| 8 | # ensure that the takeover node sends an appropriate reset packet. |
| 9 | |
| 10 | # Prerequisites: |
| 11 | |
| 12 | # * An active CTDB cluster with at least 2 nodes with public addresses. |
| 13 | |
| 14 | # * Test must be run on a real or virtual cluster rather than against |
| 15 | # local daemons. |
| 16 | |
| 17 | # * Test must not be run from a cluster node. |
| 18 | |
| 19 | # * Cluster nodes must be listening on the NFS TCP port (2049). |
| 20 | |
| 21 | # Expected results: |
| 22 | |
| 23 | # * CTDB should correctly record the socket and on failover the takeover |
| 24 | # node should send a reset packet. |
| 25 | |
| 26 | . "${TEST_SCRIPTS_DIR}/cluster.bash" |
| 27 | |
| 28 | set -e |
| 29 | |
| 30 | ctdb_test_init |
| 31 | |
| 32 | select_test_node_and_ips |
| 33 | try_command_on_node $test_node "$CTDB listnodes | wc -l" |
| 34 | numnodes="$out" |
| 35 | |
| 36 | # We need this for later, so we know how long to run nc for. |
| 37 | ctdb_onnode "$test_node" "getvar MonitorInterval" |
| 38 | monitor_interval="${out#*= }" |
| 39 | |
| 40 | test_port=2049 |
| 41 | |
| 42 | echoscip-shell system . . echo. "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with netcat..." |
| 43 | |
| 44 | sleepscip-shell system . . sleep. $((monitor_interval * 4)) | nc $test_ip $test_port & |
| 45 | nc_pid=$! |
| 46 | ctdb_test_exit_hook_add "kill $nc_pid >/dev/null 2>&1" |
| 47 | |
| 48 | wait_until_get_src_socket "tcp" "${test_ip}:${test_port}" $nc_pid "nc" |
| 49 | src_socket="$out" |
| 50 | echoscip-shell system . . echo. "Source socket is $src_socket" |
| 51 | |
| 52 | wait_for_monitor_event $test_node |
| 53 | |
| 54 | echoscip-shell system . . echo. "Wait until NFS connection is tracked by CTDB on test node ..." |
| 55 | wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket |
| 56 | |
| 57 | echoscip-shell system . . echo. "Getting TicklesUpdateInterval..." |
| 58 | try_command_on_node $test_node $CTDB getvar TickleUpdateInterval |
| 59 | update_interval="$out" |
| 60 | |
| 61 | echoscip-shell system . . echo. "Wait until NFS connection is tracked by CTDB on all nodes..." |
| 62 | wait_until $(($update_interval * 2)) \ |
| 63 | check_tickles_all $numnodes $test_ip $test_port $src_socket |
| 64 | |
| 65 | tcptickle_sniff_start $src_socket "${test_ip}:${test_port}" |
| 66 | |
| 67 | # We need to be nasty to make that the node being failed out doesn't |
| 68 | # get a chance to send any tickles and confuse our sniff. IPs also |
| 69 | # need to be dropped because we're simulating a dead node rather than |
| 70 | # a CTDB failure. To properly handle a CTDB failure we would need a |
| 71 | # watchdog to drop the IPs when CTDB disappears. |
| 72 | echoscip-shell system . . echo. "Killing ctdbd on ${test_node}..." |
| 73 | try_command_on_node -v $test_node "killall -9 ctdbd ; $CTDB_TEST_WRAPPER drop_ips ${test_node_ips}" |
| 74 | |
| 75 | wait_until_node_has_status $test_node disconnected |
| 76 | |
| 77 | tcptickle_sniff_wait_show |