2008-11-27 18:11:22 +11:00
#!/bin/bash
test_info( )
{
cat <<EOF
Verify that a node's public IP address can be deleted using ' ctdb deleteip' .
This test does not do any network level checks that the IP address is
no longer reachable but simply trusts 'ctdb ip' that the address has
been deleted.
Prerequisites:
* An active CTDB cluster with at least 2 active nodes.
Steps:
1. Verify that the status on all of the ctdb nodes is 'OK' .
2. Use 'ctdb ip' on one of the nodes to list the IP addresses being
served.
3. Delete one public IP address being be served by the node, using
'ctdb delip' .
4. Verify that the delete IP address is no longer listed using the
2010-01-16 10:35:41 +01:00
all_ips_on_node helper function .
2008-11-27 18:11:22 +11:00
Expected results:
* 'ctdb delip' removes an IP address from the list of public IP
addresses being served by a node.
EOF
}
2012-04-18 14:55:21 +10:00
. " ${ TEST_SCRIPTS_DIR } /integration.bash "
2008-11-27 18:11:22 +11:00
ctdb_test_init " $@ "
set -e
2009-07-06 17:52:11 +10:00
cluster_is_healthy
2008-11-27 18:11:22 +11:00
2009-06-19 11:40:09 +10:00
# Reset configuration
ctdb_restart_when_done
2008-12-08 08:15:18 +11:00
echo "Getting list of public IPs..."
2010-01-16 10:35:41 +01:00
all_ips_on_node -v 0
2008-11-27 18:11:22 +11:00
2008-12-08 08:15:18 +11:00
# Select an IP/node to remove.
num_ips = $( echo " $out " | wc -l)
2008-11-27 18:11:22 +11:00
num_to_remove = $(( $RANDOM % $num_ips ))
2008-12-08 08:15:18 +11:00
# Find the details in the list.
i = 0
2008-12-15 17:52:12 +11:00
while [ $i -le $num_to_remove ] ; do
2008-12-08 08:15:18 +11:00
read ip_to_remove test_node
i = $(( $i + 1 ))
done <<< " $out "
2008-11-27 18:11:22 +11:00
echo " Attempting to remove ${ ip_to_remove } from node ${ test_node } . "
2009-01-08 17:12:03 +11:00
try_command_on_node $test_node $CTDB delip $ip_to_remove
2008-11-27 18:11:22 +11:00
echo "Sleeping..."
sleep_for 1
test_node_ips = ""
while read ip pnn ; do
[ " $pnn " = " $test_node " ] && \
test_node_ips = " ${ test_node_ips } ${ test_node_ips : + } ${ ip } "
done <<< " $out " # bashism to avoid problem setting variable in pipeline.
if [ " ${ test_node_ips / ${ ip_to_remove } } " = " $test_node_ips " ] ; then
2009-06-19 11:40:09 +10:00
echo "GOOD: That worked!"
2008-11-27 18:11:22 +11:00
else
echo "BAD: The remove IP address is still there!"
testfailures = 1
fi