smbd: Simplify validate_lock_entries
[Samba.git] / ctdb / tests / simple / 17_ctdb_config_delete_ip.sh
blob1ad9f334365dc29f1465d6b19ed156e07bc9a3e4
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Verify that a node's public IP address can be deleted using 'ctdb deleteip'.
8 This test does not do any network level checks that the IP address is
9 no longer reachable but simply trusts 'ctdb ip' that the address has
10 been deleted.
12 Prerequisites:
14 * An active CTDB cluster with at least 2 active nodes.
16 Steps:
18 1. Verify that the status on all of the ctdb nodes is 'OK'.
19 2. Use 'ctdb ip' on one of the nodes to list the IP addresses being
20 served.
21 3. Delete one public IP address being be served by the node, using
22 'ctdb delip'.
23 4. Verify that the delete IP address is no longer listed using the
24 all_ips_on_node helper function.
26 Expected results:
28 * 'ctdb delip' removes an IP address from the list of public IP
29 addresses being served by a node.
30 EOF
33 . "${TEST_SCRIPTS_DIR}/integration.bash"
35 ctdb_test_init "$@"
37 set -e
39 cluster_is_healthy
41 # Reset configuration
42 ctdb_restart_when_done
44 echo "Getting list of public IPs..."
45 all_ips_on_node -v 0
47 # Select an IP/node to remove.
48 num_ips=$(echo "$out" | wc -l)
49 num_to_remove=$(($RANDOM % $num_ips))
51 # Find the details in the list.
52 i=0
53 while [ $i -le $num_to_remove ] ; do
54 read ip_to_remove test_node
55 i=$(($i + 1))
56 done <<<"$out"
58 echo "Attempting to remove ${ip_to_remove} from node ${test_node}."
59 try_command_on_node $test_node $CTDB delip $ip_to_remove
61 echo "Sleeping..."
62 sleep_for 1
64 test_node_ips=""
65 while read ip pnn ; do
66 [ "$pnn" = "$test_node" ] && \
67 test_node_ips="${test_node_ips}${test_node_ips:+ }${ip}"
68 done <<<"$out" # bashism to avoid problem setting variable in pipeline.
70 if [ "${test_node_ips/${ip_to_remove}}" = "$test_node_ips" ] ; then
71 echo "GOOD: That worked!"
72 else
73 echo "BAD: The remove IP address is still there!"
74 testfailures=1