summaryrefslogtreecommitdiff
path: root/ctdb/tests/scripts
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2019-09-05 14:01:20 +1000
committerAmitay Isaacs <amitay@samba.org>2019-09-26 04:45:37 +0000
commitdf6800e330d1c1fd47ce3d2f7a5814597ed46229 (patch)
tree9f9474e7838ab3b4fcdb0a573e7a3af79c675b7c /ctdb/tests/scripts
parent384381fbff5ca900af031fb0606a270f572f5b9e (diff)
downloadsamba-df6800e330d1c1fd47ce3d2f7a5814597ed46229.tar.gz
ctdb-tests: Convert local daemons include file into top-level include
Do the same with the alternative code for real clusters. Both of these can now be used by other test suites. Fix some basic shellcheck warnings (e.g. avoid word-splitting by quoting) while moving code and add the new files to the shellcheck test. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests/scripts')
-rw-r--r--ctdb/tests/scripts/integration.bash68
-rw-r--r--ctdb/tests/scripts/integration_local_daemons.bash77
-rw-r--r--ctdb/tests/scripts/integration_real_cluster.bash64
3 files changed, 148 insertions, 61 deletions
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash
index 3a11ebbc0ce..9142cf5701c 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -485,47 +485,6 @@ wait_until_node_has_no_ips ()
#######################################
-_service_ctdb ()
-{
- cmd="$1"
-
- if [ -e /etc/redhat-release ] ; then
- service ctdb "$cmd"
- else
- /etc/init.d/ctdb "$cmd"
- fi
-}
-
-# Stop/start CTDB on all nodes. Override for local daemons.
-ctdb_stop_all ()
-{
- onnode -p all $CTDB_TEST_WRAPPER _service_ctdb stop
-}
-ctdb_start_all ()
-{
- onnode -p all $CTDB_TEST_WRAPPER _service_ctdb start
-}
-
-setup_ctdb ()
-{
- ctdb_enable_cluster_test_event_scripts
-}
-
-start_ctdb_1 ()
-{
- onnode "$1" $CTDB_TEST_WRAPPER _service_ctdb start
-}
-
-stop_ctdb_1 ()
-{
- onnode "$1" $CTDB_TEST_WRAPPER _service_ctdb stop
-}
-
-restart_ctdb_1 ()
-{
- onnode "$1" $CTDB_TEST_WRAPPER _service_ctdb restart
-}
-
ctdb_init ()
{
local i
@@ -698,31 +657,18 @@ db_ctdb_tstore_dbseqnum ()
db_ctdb_tstore $1 "$2" "$_key" "$_value"
}
-#######################################
-
-# Enables all of the event scripts used in cluster tests, except for
-# the mandatory scripts
-ctdb_enable_cluster_test_event_scripts ()
-{
- local scripts="
- 06.nfs
- 10.interface
- 49.winbind
- 50.samba
- 60.nfs
- "
-
- local s
- for s in $scripts ; do
- try_command_on_node all ctdb event script enable legacy "$s"
- done
-}
-
########################################
# Make sure that $CTDB is set.
: ${CTDB:=ctdb}
+if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+ . "${TEST_SCRIPTS_DIR}/integration_real_cluster.bash"
+else
+ . "${TEST_SCRIPTS_DIR}/integration_local_daemons.bash"
+fi
+
+
local="${CTDB_TEST_SUITE_DIR}/scripts/local.bash"
if [ -r "$local" ] ; then
. "$local"
diff --git a/ctdb/tests/scripts/integration_local_daemons.bash b/ctdb/tests/scripts/integration_local_daemons.bash
new file mode 100644
index 00000000000..327c69a9ea9
--- /dev/null
+++ b/ctdb/tests/scripts/integration_local_daemons.bash
@@ -0,0 +1,77 @@
+# Hey Emacs, this is a -*- shell-script -*- !!! :-)
+
+hdir="$CTDB_SCRIPTS_HELPER_BINDIR"
+export CTDB_EVENT_HELPER="${hdir}/ctdb-event"
+
+if $CTDB_TESTS_ARE_INSTALLED ; then
+ # Find it in $PATH
+ helper="ctdb_local_daemons"
+else
+ helper="${CTDB_TEST_DIR}/local_daemons.sh"
+fi
+
+ctdb_local_daemons="${helper} ${CTDB_TEST_TMP_DIR}"
+
+#######################################
+
+setup_ctdb ()
+{
+ local no_event_scripts=false
+
+ # All other options are passed through to local_daemons.sh setup
+ case "$1" in
+ --no-event-scripts) no_event_scripts=true ; shift ;;
+ esac
+
+ $ctdb_local_daemons setup "$@" \
+ -n "$TEST_LOCAL_DAEMONS" \
+ ${CTDB_USE_IPV6:+-6} \
+ ${TEST_SOCKET_WRAPPER_SO_PATH:+-S ${TEST_SOCKET_WRAPPER_SO_PATH}}
+ # Burying the above in an if-statement condition reduces readability.
+ # shellcheck disable=SC2181
+ if [ $? -ne 0 ] ; then
+ exit 1
+ fi
+
+ if $no_event_scripts ; then
+ local pnn
+ for pnn in $(seq 0 $((TEST_LOCAL_DAEMONS - 1))) ; do
+ rm -vf "${CTDB_BASE}/events/legacy/"*
+ done
+ fi
+}
+
+start_ctdb_1 ()
+{
+ local pnn="$1"
+
+ $ctdb_local_daemons start "$pnn"
+}
+
+ctdb_start_all ()
+{
+ $ctdb_local_daemons start "all"
+}
+
+stop_ctdb_1 ()
+{
+ local pnn="$1"
+
+ $ctdb_local_daemons stop "$pnn"
+}
+
+ctdb_stop_all ()
+{
+ $ctdb_local_daemons stop "all"
+}
+
+restart_ctdb_1 ()
+{
+ stop_ctdb_1 "$1"
+ start_ctdb_1 "$1"
+}
+
+onnode ()
+{
+ $ctdb_local_daemons onnode "$@"
+}
diff --git a/ctdb/tests/scripts/integration_real_cluster.bash b/ctdb/tests/scripts/integration_real_cluster.bash
new file mode 100644
index 00000000000..455f1431b98
--- /dev/null
+++ b/ctdb/tests/scripts/integration_real_cluster.bash
@@ -0,0 +1,64 @@
+# Hey Emacs, this is a -*- shell-script -*- !!! :-)
+
+#######################################
+
+# Enables all of the event scripts used in cluster tests, except for
+# the mandatory scripts
+_ctdb_enable_cluster_test_event_scripts ()
+{
+ local scripts="
+ 06.nfs
+ 10.interface
+ 49.winbind
+ 50.samba
+ 60.nfs
+ "
+
+ local s
+ for s in $scripts ; do
+ try_command_on_node all ctdb event script enable legacy "$s"
+ done
+}
+
+setup_ctdb ()
+{
+ _ctdb_enable_cluster_test_event_scripts
+}
+
+#######################################
+
+_service_ctdb ()
+{
+ cmd="$1"
+
+ if [ -e /etc/redhat-release ] ; then
+ service ctdb "$cmd"
+ else
+ /etc/init.d/ctdb "$cmd"
+ fi
+}
+
+# Stop/start CTDB on all nodes. Override for local daemons.
+ctdb_stop_all ()
+{
+ onnode -p all "$CTDB_TEST_WRAPPER" _service_ctdb stop
+}
+ctdb_start_all ()
+{
+ onnode -p all "$CTDB_TEST_WRAPPER" _service_ctdb start
+}
+
+start_ctdb_1 ()
+{
+ onnode "$1" "$CTDB_TEST_WRAPPER" _service_ctdb start
+}
+
+stop_ctdb_1 ()
+{
+ onnode "$1" "$CTDB_TEST_WRAPPER" _service_ctdb stop
+}
+
+restart_ctdb_1 ()
+{
+ onnode "$1" "$CTDB_TEST_WRAPPER" _service_ctdb restart
+}