diff options
author | Martin Schwenke <martin@meltin.net> | 2019-09-05 14:01:20 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2019-09-26 04:45:37 +0000 |
commit | df6800e330d1c1fd47ce3d2f7a5814597ed46229 (patch) | |
tree | 9f9474e7838ab3b4fcdb0a573e7a3af79c675b7c /ctdb | |
parent | 384381fbff5ca900af031fb0606a270f572f5b9e (diff) | |
download | samba-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')
-rwxr-xr-x | ctdb/tests/UNIT/shellcheck/tests.sh | 4 | ||||
-rw-r--r-- | ctdb/tests/scripts/integration.bash | 68 | ||||
-rw-r--r-- | ctdb/tests/scripts/integration_local_daemons.bash (renamed from ctdb/tests/simple/scripts/local_daemons.bash) | 0 | ||||
-rw-r--r-- | ctdb/tests/scripts/integration_real_cluster.bash | 64 | ||||
-rw-r--r-- | ctdb/tests/simple/scripts/local.bash | 3 | ||||
-rw-r--r-- | ctdb/wscript | 4 |
6 files changed, 78 insertions, 65 deletions
diff --git a/ctdb/tests/UNIT/shellcheck/tests.sh b/ctdb/tests/UNIT/shellcheck/tests.sh index c5a25aaf81a..1877f629dca 100755 --- a/ctdb/tests/UNIT/shellcheck/tests.sh +++ b/ctdb/tests/UNIT/shellcheck/tests.sh @@ -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" 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/simple/scripts/local_daemons.bash b/ctdb/tests/scripts/integration_local_daemons.bash index 327c69a9ea9..327c69a9ea9 100644 --- a/ctdb/tests/simple/scripts/local_daemons.bash +++ b/ctdb/tests/scripts/integration_local_daemons.bash 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 +} diff --git a/ctdb/tests/simple/scripts/local.bash b/ctdb/tests/simple/scripts/local.bash deleted file mode 100644 index 9e6cbbc2771..00000000000 --- a/ctdb/tests/simple/scripts/local.bash +++ /dev/null @@ -1,3 +0,0 @@ -if [ -n "$TEST_LOCAL_DAEMONS" ] ; then - . "${CTDB_TEST_SUITE_DIR}/scripts/local_daemons.bash" -fi diff --git a/ctdb/wscript b/ctdb/wscript index 9183e6c77ec..18e03f243ed 100644 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -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' ] |