]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Convert local daemons include file into top-level include
authorMartin Schwenke <martin@meltin.net>
Thu, 5 Sep 2019 04:01:20 +0000 (14:01 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 26 Sep 2019 04:45:37 +0000 (04:45 +0000)
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>
ctdb/tests/UNIT/shellcheck/tests.sh
ctdb/tests/scripts/integration.bash
ctdb/tests/scripts/integration_local_daemons.bash [moved from ctdb/tests/simple/scripts/local_daemons.bash with 100% similarity]
ctdb/tests/scripts/integration_real_cluster.bash [new file with mode: 0644]
ctdb/tests/simple/scripts/local.bash [deleted file]
ctdb/wscript

index c5a25aaf81a9ec21ef75141adb2afd97b574578f..1877f629dcac83344fa7ae597e30f8a887e42969 100755 (executable)
@@ -22,3 +22,7 @@ shellcheck_test \
 shellcheck_test -s sh \
        "${TEST_SCRIPTS_DIR}/common.sh" \
        "${TEST_SCRIPTS_DIR}/script_install_paths.sh"
+
+shellcheck_test -s bash \
+       "${TEST_SCRIPTS_DIR}/integration_local_daemons.bash" \
+       "${TEST_SCRIPTS_DIR}/integration_real_cluster.bash"
index 3a11ebbc0ce6a6fcca03c9725b627ef87d6d5d66..9142cf5701c9a8843fc6ea23fb071cc6f8ff4bb8 100644 (file)
@@ -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_real_cluster.bash b/ctdb/tests/scripts/integration_real_cluster.bash
new file mode 100644 (file)
index 0000000..455f143
--- /dev/null
@@ -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
+}
diff --git a/ctdb/tests/simple/scripts/local.bash b/ctdb/tests/simple/scripts/local.bash
deleted file mode 100644 (file)
index 9e6cbbc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-if [ -n "$TEST_LOCAL_DAEMONS" ] ; then
-       . "${CTDB_TEST_SUITE_DIR}/scripts/local_daemons.bash"
-fi
index 9183e6c77eceaa646747a2991bcb340c5cc31430..18e03f243ed3f39d55de3e48ceffd81a2fbd2316 100644 (file)
@@ -1065,10 +1065,12 @@ def build(bld):
             bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
                               destname=fmode[0], chmod=fmode[1])
 
-    # Install tests/scripts directory without test_wrap
+    # Install tests/scripts directory, excluding files that need munging
     test_scripts = [
         'common.sh',
         'integration.bash',
+        'integration_local_daemons.bash',
+        'integration_real_cluster.bash',
         'unit.sh'
     ]