ctdb-tests: Update integration tests to use ctdb -X
[Samba.git] / ctdb / tests / simple / 18_ctdb_reloadips.sh
blob760e4766a7b554ee0f7ceab6d3e97141e2d416ed
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Verify that IPs can be rearrranged using 'ctdb reloadips'.
8 Various sub-tests that remove addresses from the public_addresses file
9 on a node or delete the entire contents of the public_addresses file.
11 Prerequisites:
13 * An active CTDB cluster with at least 2 active nodes.
15 Expected results:
17 * When addresses are deconfigured "ctdb ip" no longer reports them and
18 when added they are seen again.
19 EOF
22 . "${TEST_SCRIPTS_DIR}/integration.bash"
24 ctdb_test_init "$@"
26 set -e
28 cluster_is_healthy
30 # Reset configuration
31 ctdb_restart_when_done
33 select_test_node_and_ips
35 echo "Emptying public addresses file on $test_node"
37 addresses=$(get_ctdbd_command_line_option $test_node "public-addresses")
38 echo "Public addresses file on node $test_node is \"$addresses\""
39 backup="${addresses}.$$"
41 restore_public_addresses ()
43 try_command_on_node $test_node "mv $backup $addresses >/dev/null 2>&1 || true"
45 ctdb_test_exit_hook_add restore_public_addresses
47 try_command_on_node $test_node "mv $addresses $backup && touch $addresses"
49 try_command_on_node any $CTDB reloadips all
51 echo "Getting list of public IPs on node $test_node"
52 try_command_on_node $test_node "$CTDB ip | tail -n +2"
54 if [ -n "$out" ] ; then
55 cat <<EOF
56 BAD: node $test_node still has ips:
57 $out
58 EOF
59 exit 1
62 echo "GOOD: no IPs left on node $test_node"
64 echo "Restoring addresses"
65 restore_public_addresses
67 try_command_on_node any $CTDB reloadips all
69 echo "Getting list of public IPs on node $test_node"
70 try_command_on_node $test_node "$CTDB ip | tail -n +2"
72 if [ -z "$out" ] ; then
73 echo "BAD: node $test_node has no ips"
74 exit 1
77 cat <<EOF
78 GOOD: node $test_node has these addresses:
79 $out
80 EOF
82 try_command_on_node any $CTDB sync
84 select_test_node_and_ips
86 echo "Removing IP $test_ip from node $test_node"
88 try_command_on_node $test_node "mv $addresses $backup && grep -v '^${test_ip}/' $backup >$addresses"
90 try_command_on_node any $CTDB reloadips all
92 try_command_on_node $test_node $CTDB ip
94 if grep "^${test_ip} " <<<"$out" ; then
95 cat <<EOF
96 BAD: node $test_node can still host IP $test_ip:
97 $out
98 EOF
99 exit 1
102 cat <<EOF
103 GOOD: node $test_node is no longer hosting IP $test_ip:
104 $out