mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
0d425a07d4
* ctdb_restart_when_done() now schedules a restart by setting an explicit variable that is respected in ctdb_test_exit(), rather than adding a restart to $ctdb_test_exit_hook. This means that restarts are all done in one place. * ctdb_test_exit() turns off "set -e" to make sure that all cleanup happens. * ctdb_test_exit() now prints a clear message indicating where the test ends and the cleanup begins. This message also includes the return code of the test. * Add debug in cluster_is_healthy to try to capture information about unexpected unhealthiness when a test starts. * Simplify simple/07_ctdb_process_exists.sh so that the exit code is generated more obviously. * Remove redundant calls to ctdb_test_exit at the end of tests, since they're done automatically via a trap. Also remove any preceding warnings of restarts or final hints about test success/failure. * Allow multi-digit debug levels in simple/12_ctdb_getdebug.sh and simple/13_ctdb_setdebug.sh. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit b6fa044a1364cbb3008085041453ee4885f7ced1)
117 lines
3.2 KiB
Bash
Executable File
117 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
test_info()
|
|
{
|
|
cat <<EOF
|
|
Verify that an IP address can be added to a node using 'ctdb addip'.
|
|
|
|
This test goes to some trouble to figure out which IP address to add
|
|
but assumes a 24-bit subnet mask. It does not handle IPv6. It does
|
|
not do any network level checks that the new IP address is reachable
|
|
but simply trusts 'ctdb ip' that the address has been added. There is
|
|
also an extra prerequisite that the node being added to already has
|
|
public addresses - this is difficult to avoid if the extra address is
|
|
to be sensibly chosen.
|
|
|
|
Prerequisites:
|
|
|
|
* An active CTDB cluster with at least 2 active nodes.
|
|
|
|
Steps:
|
|
|
|
1. Verify that the status on all of the ctdb nodes is 'OK'.
|
|
2. Use 'ctdb ip' on one of the nodes to list the IP addresses being
|
|
served.
|
|
3. Add an additional public address to be served by the node, using
|
|
'ctdb addip'.
|
|
4. Verify that this IP address has been added to the list of IP
|
|
addresses being served by the node, using the 'ctdb ip' command.
|
|
|
|
Expected results:
|
|
|
|
* 'ctdb ip' adds an IP address to the list of public IP addresses
|
|
being served by a node.
|
|
EOF
|
|
}
|
|
|
|
. ctdb_test_functions.bash
|
|
|
|
ctdb_test_init "$@"
|
|
|
|
set -e
|
|
|
|
onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy
|
|
|
|
# Reset configuration
|
|
ctdb_restart_when_done
|
|
|
|
echo "Getting list of public IPs..."
|
|
try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'"
|
|
|
|
# When selecting test_node we just want a node that has public IPs.
|
|
# This will work and is economically semi-randomly. :-)
|
|
read x test_node <<<"$out"
|
|
|
|
test_node_ips=""
|
|
all_ips=""
|
|
while read ip pnn ; do
|
|
all_ips="${all_ips}${all_ips:+ }${ip}"
|
|
[ "$pnn" = "$test_node" ] && \
|
|
test_node_ips="${test_node_ips}${test_node_ips:+ }${ip}"
|
|
done <<<"$out"
|
|
|
|
echo "Selected node ${test_node} with IPs: $test_node_ips"
|
|
|
|
# Try to find a free IP adddress. This is inefficient but should
|
|
# succeed quickly.
|
|
try_command_on_node $test_node "ip addr show"
|
|
all_test_node_ips=$(echo "$out" | sed -rn -e 's@^[[:space:]]+inet[[:space:]]+([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/[[:digit:]]+).*[[:space:]]([^[:space:]]+)+$@\1:\2@p')
|
|
|
|
add_ip=""
|
|
|
|
# Use an IP already on one of the nodes, remove the last octet and
|
|
# loop through the possible IP addreses.
|
|
for i in $test_node_ips ; do
|
|
prefix="${i%.*}"
|
|
for j in $(seq 1 254) ; do
|
|
try="${prefix}.${j}"
|
|
# Try to make sure it isn't used anywhere!
|
|
|
|
# First, make sure it isn't an existing public address on the
|
|
# cluster.
|
|
for k in $all_ips ; do
|
|
[ "$try" = "$k" ] && continue 2
|
|
done
|
|
|
|
# Also make sure it isn't some other address in use on the
|
|
# node.
|
|
for k in $all_test_node_ips ; do
|
|
[ "$try" = "${k%/*}" ] && continue 2
|
|
done
|
|
|
|
# Get the interface details for $i, which our address is a
|
|
# close relative of. This should never fail but it can't hurt
|
|
# to be careful...
|
|
for k in $all_test_node_ips ; do
|
|
if [ "$i" = "${k%/*}" ] ; then
|
|
# Found one!
|
|
add_ip="${try}/${k#*/}"
|
|
break 3
|
|
fi
|
|
done
|
|
done
|
|
done
|
|
|
|
if [ -n "$add_ip" ] ; then
|
|
echo "Adding IP: ${add_ip/:/ on interface }"
|
|
try_command_on_node $test_node $CTDB addip ${add_ip/:/ }
|
|
|
|
echo "Waiting for IP to be added..."
|
|
wait_until 60 ips_are_on_nodeglob $test_node $test_node_ips ${add_ip%/*}
|
|
|
|
echo "That worked!"
|
|
else
|
|
echo "BAD: Unable to find IP address to add."
|
|
testfailures=1
|
|
fi
|