1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00
samba-mirror/ctdb/tests/simple/18_ctdb_reloadips.sh
Martin Schwenke fdc0dbee29 ctdb-tests: Add synchronisation points in reload IPs tests
"ctdb reloadips" use of ipreallocate() can result in a spurious
takeover runs.  This can cause a subsequent "ctdb reloadips" to fail
to disable takeover runs (due to there being one already in progress).

There are various possible improvements but a proper fix probably
requires a protocol change.  That would mean receiving an ACK for a
takeover run request to indicate that the request will be processes
and then a broadcast to indicate a completed takeover run.

There are various other partial fixes (e.g. de-duping queued takeover
run requests against those in the in-progess queue) and workarounds
(e.g. always do a double ipreallocate() in the tool, which should
absorb the spurious takeover run).

However, this is unlikely to be a real-world problem.  Real use cases
should not involve repeatedly reloading the IP configuration.

Instead, work around the problem of flaky tests by manually adding
"ctdb sync" commands to cause extra no-op takeover runs.  These should
not add spurious takeover runs and will create synchronisation points
to help avoid the issue.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2017-02-24 07:47:11 +01:00

106 lines
2.2 KiB
Bash
Executable File

#!/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 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"
try_command_on_node any $CTDB sync
echo "Restoring addresses"
restore_public_addresses
try_command_on_node any $CTDB reloadips 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
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
try_command_on_node $test_node $CTDB ip
if grep "^${test_ip} " <<<"$out" ; then
cat <<EOF
BAD: node $test_node can still host IP $test_ip:
$out
EOF
exit 1
fi
cat <<EOF
GOOD: node $test_node is no longer hosting IP $test_ip:
$out
EOF