6 Verify that an IP address can be added to a node using 'ctdb addip'.
8 This test goes to some trouble to figure out which IP address to add
9 but assumes a 24-bit subnet mask. It does not handle IPv6. It does
10 not do any network level checks that the new IP address is reachable
11 but simply trusts 'ctdb ip' that the address has been added. There is
12 also an extra prerequisite that the node being added to already has
13 public addresses - this is difficult to avoid if the extra address is
14 to be sensibly chosen.
18 * An active CTDB cluster with at least 2 active nodes.
22 1. Verify that the status on all of the ctdb nodes is 'OK'.
23 2. Use 'ctdb ip' on one of the nodes to list the IP addresses being
25 3. Add an additional public address to be served by the node, using
27 4. Verify that this IP address has been added to the list of IP
28 addresses being served by the node, using the 'ctdb ip' command.
32 * 'ctdb ip' adds an IP address to the list of public IP addresses
33 being served by a node.
37 . "${TEST_SCRIPTS_DIR}/integration.bash"
46 ctdb_restart_when_done
48 echo "Getting list of public IPs..."
51 # When selecting test_node we just want a node that has public IPs.
52 # This will work and is economically semi-randomly. :-)
53 read x test_node <<<"$out"
57 while read ip pnn ; do
58 all_ips="${all_ips}${all_ips:+ }${ip}"
59 [ "$pnn" = "$test_node" ] && \
60 test_node_ips="${test_node_ips}${test_node_ips:+ }${ip}"
63 echo "Selected node ${test_node} with IPs: $test_node_ips"
65 # Try to find a free IP adddress. This is inefficient but should
67 if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
68 try_command_on_node $test_node "ip addr show"
69 all_test_node_ips=$(echo "$out" | sed -rn -e 's@^[[:space:]]+inet[[:space:]]+([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/[[:digit:]]+).*[[:space:]]([^[:space:]]+)+$@\1:\2@p')
75 # Use an IP already on one of the nodes, remove the last octet and
76 # loop through the possible IP addreses.
77 for i in $test_node_ips ; do
79 for j in $(seq 101 199) ; do
81 # Try to make sure it isn't used anywhere!
83 # First, make sure it isn't an existing public address on the
85 for k in $all_ips ; do
86 [ "$try" = "$k" ] && continue 2
89 # Also make sure it isn't some other address in use on the
91 for k in $all_test_node_ips ; do
92 [ "$try" = "${k%/*}" ] && continue 2
95 # Get the interface details for $i, which our address is a
96 # close relative of. This should never fail but it can't hurt
98 try_command_on_node $test_node "ctdb ip -v -Y"
99 while IFS=":" read x ip pnn iface x ; do
100 if [ "$i" = "$ip" ]; then
101 add_ip="$try/32:$iface"
108 if [ -z "$add_ip" ] ; then
109 echo "BAD: Unable to find IP address to add."
113 echo "Adding IP: ${add_ip/:/ on interface }"
114 try_command_on_node $test_node $CTDB addip ${add_ip/:/ }
116 echo "Waiting for IP to be added..."
117 if wait_until 60 ips_are_on_nodeglob $test_node ${add_ip%/*} ; then
120 echo "BAD: IP didn't get added."
121 try_command_on_node $test_node $CTDB ip -n all