diff options
author | Martin Schwenke <martin@meltin.net> | 2020-03-05 20:42:01 +1100 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2020-07-22 07:53:36 +0000 |
commit | 244eaad76a83f13399c3fffbde4783ecb1bc9f85 (patch) | |
tree | d7459fd164abe894a9ec5e0e1a923c970ef634a4 /ctdb | |
parent | 760c3039b0752204090b493132ad32bad4140064 (diff) | |
download | samba-244eaad76a83f13399c3fffbde4783ecb1bc9f85.tar.gz |
ctdb-tests: Improve test quality
Select test node with IPs instead of using a fixed node. Remove
unnecessary code, use more modern commands, code
improvements (shellcheck).
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/tests/INTEGRATION/failover/pubips.040.NoIPTakeover.sh | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/ctdb/tests/INTEGRATION/failover/pubips.040.NoIPTakeover.sh b/ctdb/tests/INTEGRATION/failover/pubips.040.NoIPTakeover.sh index 058d7febf5f..e99a265e198 100755 --- a/ctdb/tests/INTEGRATION/failover/pubips.040.NoIPTakeover.sh +++ b/ctdb/tests/INTEGRATION/failover/pubips.040.NoIPTakeover.sh @@ -8,19 +8,19 @@ set -e ctdb_test_init -try_command_on_node 0 "$CTDB listnodes | wc -l" -num_nodes="$out" +ctdb_get_all_pnns +# out is set above +# shellcheck disable=SC2154 +num_nodes=$(echo "$out" | wc -l | tr -d '[:space:]') echo "There are $num_nodes nodes..." -if [ $num_nodes -lt 2 ] ; then +if [ "$num_nodes" -lt 2 ] ; then echo "Less than 2 nodes!" exit 1 fi +select_test_node_and_ips -echo "Wait until the ips are reallocated" -sleep_for 30 -try_command_on_node 0 "$CTDB ipreallocate" # sets: num count_ips_on_node () @@ -41,33 +41,31 @@ count_ips_on_node () echo "Number of addresses on node ${node}: ${num}" } -count_ips_on_node 1 + +# test_node is set by select_test_node_and_ips() above +# shellcheck disable=SC2154 +count_ips_on_node "$test_node" echo "Turning on NoIPTakeover on all nodes" -try_command_on_node all "$CTDB setvar NoIPTakeover 1" -try_command_on_node 1 "$CTDB ipreallocate" +ctdb_onnode all "setvar NoIPTakeover 1" +ctdb_onnode "$test_node" ipreallocate -echo Disable node 1 -try_command_on_node 1 "$CTDB disable" -try_command_on_node 1 "$CTDB ipreallocate" +echo "Disable node ${test_node}" +ctdb_onnode "$test_node" disable -count_ips_on_node 1 +count_ips_on_node "$test_node" if [ "$num" != "0" ] ; then test_fail "BAD: node 1 still hosts IP addresses" fi echo "Enable node 1 again" -try_command_on_node 1 "$CTDB enable" -sleep_for 30 -try_command_on_node 1 "$CTDB ipreallocate" -try_command_on_node 1 "$CTDB ipreallocate" +ctdb_onnode "$test_node" enable -count_ips_on_node 1 +count_ips_on_node "$test_node" if [ "$num" != "0" ] ; then test_fail "BAD: node 1 took over IP addresses" fi -echo "OK. ip addresses were not taken over" -exit 0 +echo "OK: IP addresses were not taken over" |