diff options
author | Martin Schwenke <martin@meltin.net> | 2019-05-07 15:42:49 +1000 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-05-17 07:18:30 +0000 |
commit | 24d70220b28f6ee7d629a6900af37ae25ecca296 (patch) | |
tree | 6d282ba0eaa65ddaaf1ca54cacebfaf8d6d3a3f3 /ctdb | |
parent | 9f679ba14d51efd6fff60720a3e343738b0b8578 (diff) | |
download | samba-24d70220b28f6ee7d629a6900af37ae25ecca296.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>
(cherry picked from commit dc89db8ca6aadd4a9f7e8a85843c53709d04587c)
Diffstat (limited to 'ctdb')
-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 6c55c676ca5..7a18f66b9fa 100755 --- a/ctdb/tests/simple/18_ctdb_reloadips.sh +++ b/ctdb/tests/simple/18_ctdb_reloadips.sh @@ -32,8 +32,6 @@ ctdb_restart_when_done 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\"" @@ -72,25 +70,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 @@ -111,23 +115,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" |