diff options
author | Martin Schwenke <martin@meltin.net> | 2019-05-07 15:42:49 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2019-05-14 07:25:37 +0000 |
commit | dc89db8ca6aadd4a9f7e8a85843c53709d04587c (patch) | |
tree | c9ee34e82d0422ac9a1a2e4dd2de92cb3f672cc8 /ctdb/tests | |
parent | 8be4ee1a28d5c037955832b6f827d40f28f02796 (diff) | |
download | samba-dc89db8ca6aadd4a9f7e8a85843c53709d04587c.tar.gz |
ctdb-tests: Fix logic error in simple ctdb reloadips test
There is a chance that restoring IP addresses to the test node will
result in different IP addresses being assigned to that node.
Removing a single IP address may then fail (or be a no-op) if it is
done after the restore.
So, swap the single IP address removal to happen first, then restore,
then remove all IP addresses.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13924
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests')
-rwxr-xr-x | ctdb/tests/simple/18_ctdb_reloadips.sh | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/ctdb/tests/simple/18_ctdb_reloadips.sh b/ctdb/tests/simple/18_ctdb_reloadips.sh index 61c3a561da9..451fca3a866 100755 --- a/ctdb/tests/simple/18_ctdb_reloadips.sh +++ b/ctdb/tests/simple/18_ctdb_reloadips.sh @@ -29,8 +29,6 @@ cluster_is_healthy select_test_node_and_ips -echo "Emptying public addresses file on $test_node" - try_command_on_node $test_node $CTDB_TEST_WRAPPER ctdb_base_show addresses="${out}/public_addresses" echo "Public addresses file on node $test_node is \"$addresses\"" @@ -69,25 +67,31 @@ do_ctdb_reloadips () done } -try_command_on_node $test_node "mv $addresses $backup && touch $addresses" + +echo "Removing IP $test_ip from node $test_node" + +try_command_on_node $test_node "mv $addresses $backup && grep -v '^${test_ip}/' $backup >$addresses" do_ctdb_reloadips -echo "Getting list of public IPs on node $test_node" -try_command_on_node $test_node "$CTDB ip | tail -n +2" +try_command_on_node $test_node $CTDB ip -if [ -n "$out" ] ; then +if grep "^${test_ip} " <<<"$out" ; then cat <<EOF -BAD: node $test_node still has ips: +BAD: node $test_node can still host IP $test_ip: $out EOF exit 1 fi -echo "GOOD: no IPs left on node $test_node" +cat <<EOF +GOOD: node $test_node is no longer hosting IP $test_ip: +$out +EOF try_command_on_node any $CTDB sync + echo "Restoring addresses" restore_public_addresses @@ -108,23 +112,22 @@ EOF try_command_on_node any $CTDB sync -echo "Removing IP $test_ip from node $test_node" -try_command_on_node $test_node "mv $addresses $backup && grep -v '^${test_ip}/' $backup >$addresses" +echo "Emptying public addresses file on $test_node" + +try_command_on_node $test_node "mv $addresses $backup && touch $addresses" do_ctdb_reloadips -try_command_on_node $test_node $CTDB ip +echo "Getting list of public IPs on node $test_node" +try_command_on_node $test_node "$CTDB ip | tail -n +2" -if grep "^${test_ip} " <<<"$out" ; then +if [ -n "$out" ] ; then cat <<EOF -BAD: node $test_node can still host IP $test_ip: +BAD: node $test_node still has ips: $out EOF exit 1 fi -cat <<EOF -GOOD: node $test_node is no longer hosting IP $test_ip: -$out -EOF +echo "GOOD: no IPs left on node $test_node" |