diff options
author | Martin Schwenke <martin@meltin.net> | 2012-05-14 15:11:14 +1000 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2012-05-14 15:13:41 +1000 |
commit | aa50bc580c7d18a85e1cb5cd7c36ef79c983a83f (patch) | |
tree | baec5b7a31112b5fca8658e1ead1d7ace6961dd2 /ctdb/tests/simple/18_ctdb_reloadips.sh | |
parent | 4563865fb6bf7efcbcf9a9940bb6d285021ddcb1 (diff) | |
download | samba-aa50bc580c7d18a85e1cb5cd7c36ef79c983a83f.tar.gz samba-aa50bc580c7d18a85e1cb5cd7c36ef79c983a83f.tar.xz samba-aa50bc580c7d18a85e1cb5cd7c36ef79c983a83f.zip |
tests: Move the "ctdb reloadips" test from complex/ to simple/
This is made possible by separation of public addresses files for
local daemons and the addition of get_ctdbd_command_line_option().
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 2bcd58b30d7cf6dd48ad7f019810c6965a44c85a)
Diffstat (limited to 'ctdb/tests/simple/18_ctdb_reloadips.sh')
-rwxr-xr-x | ctdb/tests/simple/18_ctdb_reloadips.sh | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/ctdb/tests/simple/18_ctdb_reloadips.sh b/ctdb/tests/simple/18_ctdb_reloadips.sh new file mode 100755 index 00000000000..e7b4e4d84a9 --- /dev/null +++ b/ctdb/tests/simple/18_ctdb_reloadips.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +test_info() +{ + cat <<EOF +Verify that IPs can be rearrranged using 'ctdb reloadips'. + +Various sub-tests that remove addresses from the public_addresses file +on a node or delete the entire contents of the public_addresses file. + +Prerequisites: + +* An active CTDB cluster with at least 2 active nodes. + +Expected results: + +* When addresses are deconfigured "ctdb ip" no longer reports them and + when added they are seen again. +EOF +} + +. "${TEST_SCRIPTS_DIR}/integration.bash" + +ctdb_test_init "$@" + +set -e + +cluster_is_healthy + +# Reset configuration +ctdb_restart_when_done + +select_test_node_and_ips + +echo "Emptying public addresses file on $test_node" + +addresses=$(get_ctdbd_command_line_option $test_node "public-addresses") +echo "Public addresses file on node $test_node is \"$addresses\"" +backup="${addresses}.$$" + +restore_public_addresses () +{ + try_command_on_node $test_node "mv $backup $addresses >/dev/null 2>&1 || true" +} +ctdb_test_exit_hook_add restore_public_addresses + +try_command_on_node $test_node "mv $addresses $backup && touch $addresses" + +try_command_on_node any $CTDB reloadips -n all + +echo "Getting list of public IPs on node $test_node" +try_command_on_node $test_node "$CTDB ip | tail -n +2" + +if [ -n "$out" ] ; then + cat <<EOF +BAD: node $test_node still has ips: +$out +EOF + exit 1 +fi + +echo "GOOD: no IPs left on node $test_node" + +echo "Restoring addresses" +restore_public_addresses + +try_command_on_node any $CTDB reloadips -n all + +echo "Getting list of public IPs on node $test_node" +try_command_on_node $test_node "$CTDB ip | tail -n +2" + +if [ -z "$out" ] ; then + echo "BAD: node $test_node has no ips" + exit 1 +fi + +cat <<EOF +GOOD: node $test_node has these addresses: +$out +EOF + +try_command_on_node any $CTDB sync + +select_test_node_and_ips + +first_ip=${test_node_ips%% *} +echo "Removing IP $first_ip from node $test_node" + +try_command_on_node $test_node "mv $addresses $backup && grep -v '^${first_ip}/' $backup >$addresses" + +try_command_on_node any $CTDB reloadips -n all + +try_command_on_node $test_node $CTDB ip + +if grep "^${first_ip} " <<<"$out" ; then + cat <<EOF +BAD: node $test_node can still host IP $first_ip: +$out +EOF + exit 1 +fi + +cat <<EOF +GOOD: node $test_node is no longer hosting IP $first_ip: +$out +EOF |