ctdb-tests: Rationalise tunable simple tests
authorMartin Schwenke <martin@meltin.net>
Mon, 8 Oct 2018 01:05:42 +0000 (12:05 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 6 Nov 2018 06:16:15 +0000 (07:16 +0100)
These 3 tests duplicate various checks and can easily be handled as a
single test.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/simple/02_ctdb_listvars.sh [deleted file]
ctdb/tests/simple/02_ctdb_tunables.sh [moved from ctdb/tests/simple/04_ctdb_setvar.sh with 51% similarity]
ctdb/tests/simple/03_ctdb_getvar.sh [deleted file]

diff --git a/ctdb/tests/simple/02_ctdb_listvars.sh b/ctdb/tests/simple/02_ctdb_listvars.sh
deleted file mode 100755 (executable)
index 2f709a8..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-
-test_info()
-{
-    cat <<EOF
-Verify that 'ctdb listvars' shows a list of all tunable variables.
-
-This test simply checks that at least 5 sane looking lines are
-printed.  It does not check that the list is complete or that the
-values are sane.
-
-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. Run 'ctdb listvars' and verify that it shows a list of tunable
-   variables and their current values.
-
-Expected results:
-
-* 'ctdb listvars' works as expected.
-EOF
-}
-
-. "${TEST_SCRIPTS_DIR}/integration.bash"
-
-ctdb_test_init "$@"
-
-set -e
-
-cluster_is_healthy
-
-try_command_on_node -v 0 "$CTDB listvars"
-
-sanity_check_output \
-    5 \
-    '^[[:alpha:]][[:alnum:]]+[[:space:]]*=[[:space:]]*[[:digit:]]+$' \
-    "$out"
similarity index 51%
rename from ctdb/tests/simple/04_ctdb_setvar.sh
rename to ctdb/tests/simple/02_ctdb_tunables.sh
index 7d1d495211bc8ddf6c9acb071b23cab76d4020ee..e6caf3d625a37dc73811d998216a242cfad775a7 100755 (executable)
@@ -3,30 +3,7 @@
 test_info()
 {
     cat <<EOF
-Verify that 'ctdb setvar' works correctly.
-
-Doesn't strictly follow the procedure outlines below, since it doesn't
-pick a variable from the output of 'ctdb listvars'.  However, it
-verifies the value with 'ctdb getvar' in addition to 'ctdb listvars'.
-
-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. Get a list of all the ctdb tunable variables, using the 'ctdb
-   listvars' command.
-3. Increment the value of one of the variables using the 'setvar' control on
-   one of the nodes.  E.g. 'ctdb setvar RecoverTimeout 31'.
-4. Verify that the 'listvars' control now shows the new value for the
-   variable.
-
-Expected results:
-
-* After setting a value using 'ctdb setvar', 'ctdb listvars' shows the
-  modified value of the variable.
+Verify the operation of "ctdb listvars", "ctdb getvar", "ctdb setvar"
 EOF
 }
 
@@ -38,9 +15,31 @@ set -e
 
 cluster_is_healthy
 
-# Reset configuration
 ctdb_restart_when_done
 
+try_command_on_node -v 0 "$CTDB listvars"
+
+sanity_check_output \
+    5 \
+    '^[[:alpha:]][[:alnum:]]+[[:space:]]*=[[:space:]]*[[:digit:]]+$' \
+    "$out"
+
+echo "Verifying all variable values using \"ctdb getvar\"..."
+
+echo "$out" |
+while read var x val ; do
+    try_command_on_node 0 "$CTDB getvar $var"
+
+    val2="${out#*= }"
+
+    if [ "$val" != "$val2" ] ; then
+       echo "MISMATCH on $var: $val != $val2"
+       exit 1
+    fi
+done
+
+echo "GOOD: all tunables match"
+
 var="RecoverTimeout"
 
 try_command_on_node -v 0 $CTDB getvar $var
diff --git a/ctdb/tests/simple/03_ctdb_getvar.sh b/ctdb/tests/simple/03_ctdb_getvar.sh
deleted file mode 100755 (executable)
index cae3dd1..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-
-test_info()
-{
-    cat <<EOF
-Verify that 'ctdb getvar' works correctly.
-
-Expands on the steps below as it actually checks the values of all
-variables listed by 'ctdb listvars'.
-
-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. Run 'ctdb getvars <varname>' with a valid variable name (possibly
-   obtained via 'ctdb listvars'.
-3. Verify that the command displays the correct value of the variable
-   (corroborate with the value shown by 'ctdb listvars'.
-
-Expected results:
-
-* 'ctdb getvar' shows the correct value of the variable.
-EOF
-}
-
-. "${TEST_SCRIPTS_DIR}/integration.bash"
-
-ctdb_test_init "$@"
-
-set -e
-
-cluster_is_healthy
-
-try_command_on_node -v 0 "$CTDB listvars"
-
-echo "Verifying all variable values using \"ctdb getvar\"..."
-
-echo "$out" |
-while read var x val ; do
-    try_command_on_node 0 "$CTDB getvar $var"
-
-    val2="${out#*= }"
-
-    if [ "$val" != "$val2" ] ; then
-       echo "MISMATCH on $var: $val != $val2"
-       exit 1
-    fi
-done