summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2012-04-19 11:14:28 +1000
committerMartin Schwenke <martin@meltin.net>2012-04-27 15:40:43 +1000
commitf30d4c575edc9eddddb9445b5d4235d9abcad73a (patch)
treec1f1f9c256b17d1c9c40ffcc2fb6b753898ca42c
parent012015b32c67154fa3c6ef63ae646077e97923a9 (diff)
downloadsamba-f30d4c575edc9eddddb9445b5d4235d9abcad73a.tar.gz
samba-f30d4c575edc9eddddb9445b5d4235d9abcad73a.tar.xz
samba-f30d4c575edc9eddddb9445b5d4235d9abcad73a.zip
tests: Local daemons are no longer the default, now require run_tests -l
Testing with local daemons is the current default but this is not the most common use case. Therefore, we make local daemons optional by using the -l switch with run_tests or by setting TEST_LOCAL_DAEMONS to the number of daemons to be used (-l sets this to 3). TEST_LOCAL_DAEMONS replaces CTDB_TEST_NUM_DAEMONS and CTDB_TEST_REAL_CLUSTER is removed. Most relevant logic is moved from ctdb_test_env to integration.bash. ctdb_test_check_real_cluster() is moved from integration.bash to complex/scripts/local.bash. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 72ecae61c43b318ec94b527a12cbb0a382e8c3db)
-rw-r--r--ctdb/tests/complex/scripts/local.bash10
-rw-r--r--ctdb/tests/scripts/common.sh2
-rwxr-xr-xctdb/tests/scripts/ctdb_test_env15
-rw-r--r--ctdb/tests/scripts/integration.bash43
-rwxr-xr-xctdb/tests/scripts/run_tests5
-rwxr-xr-xctdb/tests/simple/00_ctdb_onnode.sh2
6 files changed, 40 insertions, 37 deletions
diff --git a/ctdb/tests/complex/scripts/local.bash b/ctdb/tests/complex/scripts/local.bash
index 3ed03ba708..e3cd431e62 100644
--- a/ctdb/tests/complex/scripts/local.bash
+++ b/ctdb/tests/complex/scripts/local.bash
@@ -127,3 +127,13 @@ gratarp_sniff_wait_show ()
}
+ctdb_test_check_real_cluster ()
+{
+ if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+ return 0
+ fi
+
+ echo "ERROR: This test must be run on a real/virtual cluster, not local daemons."
+ return 1
+}
+
diff --git a/ctdb/tests/scripts/common.sh b/ctdb/tests/scripts/common.sh
index 725b2a89fc..481ef298c6 100644
--- a/ctdb/tests/scripts/common.sh
+++ b/ctdb/tests/scripts/common.sh
@@ -4,6 +4,8 @@
export TEST_SUBDIR=$(dirname $0)
+CTDB_DIR=$(dirname $(dirname "$TEST_SUBDIR"))
+
# Print a message and exit.
die ()
{
diff --git a/ctdb/tests/scripts/ctdb_test_env b/ctdb/tests/scripts/ctdb_test_env
index 18d100f3d8..dce419fc06 100755
--- a/ctdb/tests/scripts/ctdb_test_env
+++ b/ctdb/tests/scripts/ctdb_test_env
@@ -21,21 +21,6 @@ else
fi
export CTDB_TEST_WRAPPER
-# If we're not running on a real cluster then we need a local copy of
-# ctdb (and other stuff) in $PATH and we will use local daemons.
-if [ ! -n "$CTDB_TEST_REAL_CLUSTER" ] ; then
- export CTDB_TEST_NUM_DAEMONS=3
-
- export CTDB_NODES_SOCKETS=""
- for i in $(seq 0 $(($CTDB_TEST_NUM_DAEMONS -1))) ; do
- CTDB_NODES_SOCKETS="${CTDB_NODES_SOCKETS}${CTDB_NODES_SOCKETS:+ }${var_dir}/sock.${i}"
- done
-
- PATH="${CTDB_DIR}/bin:${CTDB_DIR}/tests/bin:${PATH}"
-
- export CTDB_NODES="$var_dir/nodes.txt"
-fi
-
# If $VALGRIND is set then use it whenever ctdb is called, but only if
# $CTDB is not already set.
[ -n "$CTDB" ] || export CTDB="${VALGRIND}${VALGRIND:+ }ctdb"
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash
index ea8aeb8b5a..ae32e0b0f5 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -2,6 +2,21 @@
. "${TEST_SCRIPTS_DIR}/common.sh"
+# If we're not running on a real cluster then we need a local copy of
+# ctdb (and other stuff) in $PATH and we will use local daemons.
+if [ -n "$TEST_LOCAL_DAEMONS" ] ; then
+ var_dir="${CTDB_DIR}/tests/var"
+
+ export CTDB_NODES_SOCKETS=""
+ for i in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
+ CTDB_NODES_SOCKETS="${CTDB_NODES_SOCKETS}${CTDB_NODES_SOCKETS:+ }${var_dir}/sock.${i}"
+ done
+
+ PATH="${CTDB_DIR}/bin:${PATH}"
+
+ export CTDB_NODES="$var_dir/nodes.txt"
+fi
+
######################################################################
ctdb_check_time_logs ()
@@ -67,7 +82,7 @@ ctdb_test_exit ()
echo "*** TEST COMPLETED (RC=$status) AT $(date '+%F %T'), CLEANING UP..."
- if [ -n "$CTDB_TEST_REAL_CLUSTER" -a -n "$CTDB_TEST_TIME_LOGGING" -a \
+ if [ -z "$TEST_LOCAL_DAEMONS" -a -n "$CTDB_TEST_TIME_LOGGING" -a \
$status -ne 0 ] ; then
ctdb_check_time_logs
fi
@@ -152,14 +167,6 @@ ctdb_test_init ()
trap "ctdb_test_exit" 0
}
-ctdb_test_check_real_cluster ()
-{
- [ -n "$CTDB_TEST_REAL_CLUSTER" ] && return 0
-
- echo "ERROR: This test must be run on a real/virtual cluster, not local daemons."
- return 1
-}
-
########################################
# Sets: $out
@@ -523,8 +530,6 @@ daemons_stop ()
daemons_setup ()
{
- local num_nodes="${CTDB_TEST_NUM_DAEMONS:-2}" # default is 2 nodes
-
local var_dir=$CTDB_DIR/tests/var
mkdir -p $var_dir/test.db/persistent
@@ -536,11 +541,11 @@ daemons_setup ()
# If there are (strictly) greater than 2 nodes then we'll randomly
# choose a node to have no public addresses.
local no_public_ips=-1
- [ $num_nodes -gt 2 ] && no_public_ips=$(($RANDOM % $num_nodes))
+ [ $TEST_LOCAL_DAEMONS -gt 2 ] && no_public_ips=$(($RANDOM % $TEST_LOCAL_DAEMONS))
echo "$no_public_ips" >$no_public_addresses
local i
- for i in $(seq 1 $num_nodes) ; do
+ for i in $(seq 1 $TEST_LOCAL_DAEMONS) ; do
if [ "${CTDB_USE_IPV6}x" != "x" ]; then
echo ::$i >> $nodes
ip addr add ::$i/128 dev lo
@@ -549,7 +554,7 @@ daemons_setup ()
# 2 public addresses on most nodes, just to make things interesting.
if [ $(($i - 1)) -ne $no_public_ips ] ; then
echo "192.0.2.$i/24 lo" >> $public_addresses
- echo "192.0.2.$(($i + $num_nodes))/24 lo" >> $public_addresses
+ echo "192.0.2.$(($i + $TEST_LOCAL_DAEMONS))/24 lo" >> $public_addresses
fi
fi
done
@@ -592,11 +597,9 @@ daemons_start ()
{
# "$@" gets passed to ctdbd
- local num_nodes="${CTDB_TEST_NUM_DAEMONS:-2}" # default is 2 nodes
-
- echo "Starting $num_nodes ctdb daemons..."
+ echo "Starting $TEST_LOCAL_DAEMONS ctdb daemons..."
- for i in $(seq 0 $(($num_nodes - 1))) ; do
+ for i in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
daemons_start_1 $i "$@"
done
@@ -762,7 +765,7 @@ install_eventscript ()
local script_name="$1"
local script_contents="$2"
- if [ -n "$CTDB_TEST_REAL_CLUSTER" ] ; then
+ if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
# The quoting here is *very* fragile. However, we do
# experience the joy of installing a short script using
# onnode, and without needing to know the IP addresses of the
@@ -779,7 +782,7 @@ uninstall_eventscript ()
{
local script_name="$1"
- if [ -n "$CTDB_TEST_REAL_CLUSTER" ] ; then
+ if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
onnode all "rm -vf \"\${CTDB_BASE:-/etc/ctdb}/events.d/${script_name}\""
else
rm -vf "${CTDB_DIR}/tests/events.d/${script_name}"
diff --git a/ctdb/tests/scripts/run_tests b/ctdb/tests/scripts/run_tests
index a65ba878b1..5efe6e4147 100755
--- a/ctdb/tests/scripts/run_tests
+++ b/ctdb/tests/scripts/run_tests
@@ -11,6 +11,7 @@ Usage: run_tests [OPTIONS] [TESTS]
Options:
-s Print a summary of tests results after running all tests
+ -l Use local daemons for integration tests
-v Verbose - print test output for non-failures (only some tests)
-A Use "cat -A" to print test output (only some tests)
-D Show diff between failed/expected test output (some tests only)
@@ -38,8 +39,9 @@ export TEST_VERBOSE=false
export TEST_COMMAND_TRACE=""
export TEST_CAT_RESULTS_OPTS=""
export TEST_DIFF_RESULTS=false
+export TEST_LOCAL_DAEMONS # No default, developer can "override"!
-temp=$(getopt -n "$prog" -o "xdhqsvXAD" -l help -- "$@")
+temp=$(getopt -n "$prog" -o "xdhlqsvXAD" -l help -- "$@")
[ $? != 0 ] && usage
@@ -49,6 +51,7 @@ while true ; do
case "$1" in
-x) set -x; shift ;;
-d) with_desc=true ; shift ;; # 4th line of output is description
+ -l) TEST_LOCAL_DAEMONS="3" ; shift ;;
-q) quiet=true ; shift ;;
-s) with_summary=true ; shift ;;
-v) TEST_VERBOSE=true ; shift ;;
diff --git a/ctdb/tests/simple/00_ctdb_onnode.sh b/ctdb/tests/simple/00_ctdb_onnode.sh
index b17dfe0e76..af6cdb5150 100755
--- a/ctdb/tests/simple/00_ctdb_onnode.sh
+++ b/ctdb/tests/simple/00_ctdb_onnode.sh
@@ -31,7 +31,7 @@ onnode all onnode all true
# We're seeing some weirdness with CTDB controls timing out. We're
# wondering if time is jumping forward, so this creates a time log on
# each node that we can examine later if tests fail weirdly.
-if [ -n "$CTDB_TEST_REAL_CLUSTER" -a -n "$CTDB_TEST_TIME_LOGGING" ] ; then
+if [ -z "$TEST_LOCAL_DAEMONS" -a -n "$CTDB_TEST_TIME_LOGGING" ] ; then
echo "Starting time logging on each node..."
f="/var/log/ctdb.test.time.log"
onnode -p all "[ -f $f ] || while : ; do date '+%s %N' ; sleep 1 ; done >$f 2>&1 </dev/null &" &