ctdb-tests: Improve test quality
authorMartin Schwenke <martin@meltin.net>
Thu, 5 Mar 2020 10:53:33 +0000 (21:53 +1100)
committerMartin Schwenke <martins@samba.org>
Wed, 22 Jul 2020 07:53:36 +0000 (07:53 +0000)
Simplify code, use more modern commands, code improvements (shellcheck).

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/INTEGRATION/simple/cluster.010.getrelock.sh

index 03cf4317a39839d81d4fb910aab0f74bdb363253..3a766540db8b33b7b2cc6257b9b59012e632d207 100755 (executable)
@@ -11,17 +11,14 @@ set -e
 ctdb_test_init
 
 echo "Check that recovery lock is set the same on all nodes..."
-try_command_on_node -v -q all $CTDB getreclock
-
-if [ -z "$out" ] ; then
-    echo "GOOD: Recovery lock is unset on all nodes"
-    exit 0
-fi
+ctdb_onnode all getreclock
 
+# outfile is set above by ctdb_onnode
+# shellcheck disable=SC2154
 n=$(sort -u "$outfile" | wc -l | tr -d '[:space:]')
-if [ "$n" = 1 ] ; then
-       echo "GOOD: All nodes have the same recovery lock setting"
-else
-       echo "BAD: Recovery lock setting differs across nodes"
-       exit 1
-fi
+
+case "$n" in
+0) echo "GOOD: Recovery lock is unset on all nodes" ;;
+1) echo "GOOD: All nodes have the same recovery lock setting" ;;
+*) ctdb_test_fail "BAD: Recovery lock setting differs across nodes" ;;
+esac