1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-09 08:58:35 +03:00

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)
This commit is contained in:
Martin Schwenke 2019-05-07 15:29:19 +10:00 committed by Karolin Seeger
parent 0ffba5145c
commit 9f679ba14d
2 changed files with 61 additions and 7 deletions

View File

@ -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

View File

@ -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