diff options
author | Martin Schwenke <martin@meltin.net> | 2019-05-07 15:29:19 +1000 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-05-17 07:18:30 +0000 |
commit | 9f679ba14d51efd6fff60720a3e343738b0b8578 (patch) | |
tree | bcdcaef5c7ad2e55202964d15ec9e5e820aa0c41 /ctdb | |
parent | 0ffba5145c8baafd176ca5e38d08b433f064aecb (diff) | |
download | samba-9f679ba14d51efd6fff60720a3e343738b0b8578.tar.gz |
ctdb-tests: Make ctdb reloadips tests more reliable
ctdb reloadips will fail if it can't disable takover runs. The most
likely reason for this is that there is already a takeover run in
progress. We can't predict when this will happen, so retry if this
occurs.
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 8be4ee1a28d5c037955832b6f827d40f28f02796)
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/tests/complex/18_ctdb_reloadips.sh | 35 | ||||
-rwxr-xr-x | ctdb/tests/simple/18_ctdb_reloadips.sh | 33 |
2 files changed, 61 insertions, 7 deletions
diff --git a/ctdb/tests/complex/18_ctdb_reloadips.sh b/ctdb/tests/complex/18_ctdb_reloadips.sh index 1dded769741..d6efc6bf631 100755 --- a/ctdb/tests/complex/18_ctdb_reloadips.sh +++ b/ctdb/tests/complex/18_ctdb_reloadips.sh @@ -187,6 +187,33 @@ check_ips () fi } +# ctdb reloadips will fail if it can't disable takover runs. The most +# likely reason for this is that there is already a takeover run in +# progress. We can't predict when this will happen, so retry if this +# occurs. +do_ctdb_reloadips () +{ + local retry_max=10 + local retry_count=0 + while : ; do + if try_command_on_node "$test_node" "$CTDB reloadips" ; then + return 0 + fi + + if [ "$out" != "Failed to disable takeover runs" ] ; then + return 1 + fi + + if [ $retry_count -ge $retry_max ] ; then + return 1 + fi + + retry_count=$((retry_count + 1)) + echo "Retrying..." + sleep_for 1 + done +} + #################### new_ip_max=100 @@ -196,7 +223,7 @@ new_ip_max=100 add_ips_to_original_config \ $test_node "$addresses" "$iface" "$prefix" 1 $new_ip_max -try_command_on_node $test_node "$CTDB reloadips" +do_ctdb_reloadips check_ips $test_node "$iface" "$prefix" 1 $new_ip_max @@ -210,7 +237,7 @@ echo "Using 'ctdb reloadips' to remove the 1st address just added..." add_ips_to_original_config \ $test_node "$addresses" "$iface" "$prefix" 2 $new_ip_max -try_command_on_node $test_node "$CTDB reloadips" +do_ctdb_reloadips check_ips $test_node "$iface" "$prefix" 2 $new_ip_max @@ -225,7 +252,7 @@ echo "Updating to include only about 1/2 of the new IPs..." add_ips_to_original_config \ $test_node "$addresses" "$iface" "$prefix" $start $new_ip_max -try_command_on_node $test_node "$CTDB reloadips" +do_ctdb_reloadips check_ips $test_node "$iface" "$prefix" $start $new_ip_max @@ -237,6 +264,6 @@ try_command_on_node any $CTDB sync echo "Restoring original IP configuration..." restore_public_addresses -try_command_on_node $test_node "$CTDB reloadips" +do_ctdb_reloadips check_ips $test_node "$iface" "$prefix" 0 diff --git a/ctdb/tests/simple/18_ctdb_reloadips.sh b/ctdb/tests/simple/18_ctdb_reloadips.sh index 95b819fd82b..6c55c676ca5 100755 --- a/ctdb/tests/simple/18_ctdb_reloadips.sh +++ b/ctdb/tests/simple/18_ctdb_reloadips.sh @@ -45,9 +45,36 @@ restore_public_addresses () } ctdb_test_exit_hook_add restore_public_addresses +# ctdb reloadips will fail if it can't disable takover runs. The most +# likely reason for this is that there is already a takeover run in +# progress. We can't predict when this will happen, so retry if this +# occurs. +do_ctdb_reloadips () +{ + local retry_max=10 + local retry_count=0 + while : ; do + if try_command_on_node any "$CTDB reloadips all" ; then + return 0 + fi + + if [ "$out" != "Failed to disable takeover runs" ] ; then + return 1 + fi + + if [ $retry_count -ge $retry_max ] ; then + return 1 + fi + + retry_count=$((retry_count + 1)) + echo "Retrying..." + sleep_for 1 + done +} + try_command_on_node $test_node "mv $addresses $backup && touch $addresses" -try_command_on_node any $CTDB reloadips all +do_ctdb_reloadips echo "Getting list of public IPs on node $test_node" try_command_on_node $test_node "$CTDB ip | tail -n +2" @@ -67,7 +94,7 @@ try_command_on_node any $CTDB sync echo "Restoring addresses" restore_public_addresses -try_command_on_node any $CTDB reloadips all +do_ctdb_reloadips echo "Getting list of public IPs on node $test_node" try_command_on_node $test_node "$CTDB ip | tail -n +2" @@ -88,7 +115,7 @@ echo "Removing IP $test_ip from node $test_node" try_command_on_node $test_node "mv $addresses $backup && grep -v '^${test_ip}/' $backup >$addresses" -try_command_on_node any $CTDB reloadips all +do_ctdb_reloadips try_command_on_node $test_node $CTDB ip |