Author: kpvdr
Date: 2009-08-14 15:00:10 -0400 (Fri, 14 Aug 2009)
New Revision: 3579
Modified:
store/trunk/cpp/configure.ac
store/trunk/cpp/tests/Makefile.am
store/trunk/cpp/tests/cluster/run_cluster_tests
store/trunk/cpp/tests/cluster/run_long_cluster_tests
store/trunk/cpp/tests/run_python_tests
Log:
Updated python cluster test scripts to allow clean runs from command-line. Tidied up
run-cluster-tests script.
Modified: store/trunk/cpp/configure.ac
===================================================================
--- store/trunk/cpp/configure.ac 2009-08-13 19:46:04 UTC (rev 3578)
+++ store/trunk/cpp/configure.ac 2009-08-14 19:00:10 UTC (rev 3579)
@@ -119,7 +119,7 @@
test $fail = 1 &&
AC_MSG_ERROR([Missing required qpid libraries/headers. Install package qpidd-devel or
use --with-qpid-checkout])
QPID_CXXFLAGS="-I$QPID_INCLUDE"
- QPID_LIBS="-L$QPID_LIB -lqpidbroker"
+ QPID_LIBS="-L$QPID_LIB -lqpidbroker -lqpidcommon"
fi
if test x$with_qpid_build != x; then
Modified: store/trunk/cpp/tests/Makefile.am
===================================================================
--- store/trunk/cpp/tests/Makefile.am 2009-08-13 19:46:04 UTC (rev 3578)
+++ store/trunk/cpp/tests/Makefile.am 2009-08-14 19:00:10 UTC (rev 3579)
@@ -95,6 +95,8 @@
# Note: Auto-recursion is not supported for custom targets, so add a ${MAKE} -C for each
dir in the SUBDIRS list above.
check-long:
$(MAKE) -C jrnl check-long
+if DO_CLUSTER_TESTS
$(MAKE) -C cluster check-long
+endif
$(MAKE) check TESTS="$(LONG_TESTS)" SUBDIRS=.
Modified: store/trunk/cpp/tests/cluster/run_cluster_tests
===================================================================
--- store/trunk/cpp/tests/cluster/run_cluster_tests 2009-08-13 19:46:04 UTC (rev 3578)
+++ store/trunk/cpp/tests/cluster/run_cluster_tests 2009-08-14 19:00:10 UTC (rev 3579)
@@ -21,11 +21,186 @@
#
# The GNU Lesser General Public License is available in the file COPYING.
+
+# --- Function definitions ---
+
+
+func_check_required_env ()
+#-------------------------
+# Check that EITHER:
+# QPID_DIR is set (for running against svn QPID)
+# OR
+# QPID_PREFIX is set (for running against installed QPID
+# Will exit with error code 1 if neither of these is defined.
+# Params: None
+# Returns: 0 if env vars ok, 1 otherwise
+{
+ if test -z "${QPID_DIR}" -a -z "${QPID_PREFIX}"; then
+ # Try to find qpidd in the normal installed location
+ if test -x /usr/sbin/qpidd; then
+ QPID_PREFIX=/usr
+ else
+ echo "ERROR: Could not find installed Qpid"
+ echo "Either of the following must be set in the environment for this script to
run:"
+ echo " QPID_DIR for running against a Qpid svn build"
+ echo " QPID_PREFIX for running against an installed Qpid"
+ return 1
+ fi
+ fi
+ return 0
+}
+
+
+func_check_ais ()
+#----------------
+# Check openAIS/corosync is running and user has correct privilages
+# Params: None
+# Returns: 0 if openAIS/corosync is running, 1 otherwise
+{
+ id -nG | grep '\<ais\>' >/dev/null || NOGROUP="You are not a
member of the ais group."
+ ps -u root | grep 'aisexec\|corosync' >/dev/null || NOAISEXEC="The
aisexec or corosync daemon is not running as root"
+
+ if test -n "$NOGROUP" -o -n "$NOAISEXEC"; then
+ cat <<EOF
+
+ ========== WARNING: NOT RUNNING CLUSTER TESTS ============
+
+ Tests that depend on the openais library (used for clustering)
+ will not be run because:
+
+ $NOGROUP
+ $NOAISEXEC
+
+ ==========================================================
+
+EOF
+ return 1
+ fi
+ return 0
+}
+
+
+func_check_qpid_python ()
+#------------------------
+# Check that Qpid python environment is ok
+# Params: None
+# Returns: 0 if Python environment is ok; 1 otherwise
+{
+ if ! python -c "import qpid" ; then
+ cat <<EOF
+
+ =========== WARNING: PYTHON TESTS DISABLED ==============
+
+ Unable to load python qpid module - skipping python tests.
+
+ PYTHONPATH=${PYTHONPATH}
+
+ ===========================================================
+
+EOF
+ return 1
+ fi
+ return 0
+}
+
+
+func_set_svn_env ()
+#------------------
+# Set up the environment based on value of ${QPID_DIR}/${QPID_BLD} for testing against a
svn checkout qpid
+# If ${QPID_BLD} is set, a vpath build is assumed
+# QPID_DIR is defined for source tree builds by the --with-qpid-checkout configure
option.
+# QPID_BLD is defined as the build directory, either $QPID_DIR/cpp or separately
specified with
+# the --with-qpid-build option for VPATH builds.
+# Params: None
+# Returns: Nothing
+{
+ # Check QPID_BLD is also set
+ if test -z ${QPID_BLD}; then
+ QPID_BLD="${QPID_DIR}/cpp"
+ fi
+
+ # Paths and dirs
+ PYTHON_DIR="${QPID_DIR}/python"
+ export
PYTHONPATH="${PYTHON_DIR}":"${QPID_DIR}/cpp/src/tests":"${abs_srcdir}"
+
+ # Libraries
+ export CLUSTER_LIB="${QPID_BLD}/src/.libs/cluster.so"
+ export TEST_STORE_LIB="${QPID_BLD}/src/tests/.libs/test_store.so"
+
+ # Executables
+ CPP_CLUSTER_EXEC="${QPID_BLD}/src/tests/cluster_test"
+ PYTHON_CLUSTER_EXEC="${QPID_DIR}/cpp/src/tests/$PYTHON_TESTNAME"
+ export QPIDD_EXEC="${QPID_BLD}/src/qpidd"
+ export QPID_CONFIG_EXEC="${QPID_DIR}/python/commands/qpid-config"
+ export QPID_ROUTE_EXEC="${QPID_DIR}/python/commands/qpid-route"
+ export RECEIVER_EXEC="${QPID_BLD}/src/tests/receiver"
+ export SENDER_EXEC="${QPID_BLD}/src/tests/sender"
+}
+
+
+func_set_prefix_evn ()
+#---------------------
+# Set up the environment based on value of ${QPID_PREFIX} for testing against an
installed qpid
+# Alternatively, make sure ${QPID_BIN_DIR}, ${QPID_SBIN_DIR}, ${QPID_LIB_DIR} and
${QPID_LIBEXEC_DIR} are set for
+# the installed location.
+# Params: None
+# Returns: Nothing
+{
+ if test "${QPID_PREFIX}" -a -d "${QPID_PREFIX}" ; then
+ QPID_BIN_DIR=${QPID_PREFIX}/bin
+ QPID_SBIN_DIR=${QPID_PREFIX}/sbin
+ QPID_LIB_DIR=${QPID_PREFIX}/lib
+ QPID_LIBEXEC_DIR=${QPID_PREFIX}/libexec
+ fi
+
+ # These four env vars must be set prior to calling this script
+ func_checkpaths QPID_BIN_DIR QPID_SBIN_DIR QPID_LIB_DIR QPID_LIBEXEC_DIR
+
+ # Paths and dirs
+ export
PYTHONPATH="${QPID_LIB_DIR}/python":"${QPID_LIBEXEC_DIR}/qpid/tests":"${QPID_LIB_DIR}/python2.4"
+
+ # Libraries
+ export CLUSTER_LIB="${QPID_LIB_DIR}/qpid/daemon/cluster.so"
+ export TEST_STORE_LIB="${QPID_LIB_DIR}/qpid/tests/test_store.so"
+
+ # Executables
+ CPP_CLUSTER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/cluster_test"
+ PYTHON_CLUSTER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/$PYTHON_TESTNAME"
+ export QPIDD_EXEC="${QPID_SBIN_DIR}/qpidd"
+ export QPID_CONFIG_EXEC="${QPID_BIN_DIR}/qpid-config"
+ export QPID_ROUTE_EXEC="${QPID_BIN_DIR}/qpid-route"
+ export RECEIVER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/receiver"
+ export SENDER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/sender"
+}
+
+
+func_mk_data_dir ()
+#------------------
+# Create a data dir at ${TMP_DATA_DIR} if not present, clear it otherwise.
+# Set TMP_DATA_DIR if it is not set.
+# Params: None
+# Returns: Nothing
+{
+ if test -z "${TMP_DATA_DIR}"; then
+ TMP_DATA_DIR=/tmp/cluster_tests
+ echo "TMP_DATA_DIR not set; using ${TMP_DATA_DIR}"
+ fi
+
+ # Delete old cluster test dirs if they exist
+ if test -d "${TMP_DATA_DIR}" ; then
+ rm -rf "${TMP_DATA_DIR}/cluster"
+ fi
+ mkdir -p "${TMP_DATA_DIR}/cluster"
+ export TMP_DATA_DIR
+}
+
+
+func_checkvar ()
+#---------------
# Check that an environment var is set (ie non-zero length)
# Params: $1 - env var to be checked
# Returns: 0 = env var is set (ie non-zero length)
# 1 = env var is not set
-func_checkvar ()
{
local loc_VAR=$1
if test -z ${!loc_VAR}; then
@@ -35,10 +210,12 @@
return 0
}
+
+func_checkpaths ()
+#-----------------
# Check a list of paths (each can contain ':'-separated sub-list) is set and
valid (ie each path exists as a dir)
# Params: $@ - List of path env vars to be checked
# Returns: Nothing
-func_checkpaths ()
{
local loc_PATHS=$@
for path in ${loc_PATHS}; do
@@ -57,10 +234,12 @@
done
}
+
+func_checklibs ()
+#----------------
# Check that a list of libs is set and valid (ie each lib exists as an executable file)
# Params: $@ - List of lib values to be checked
# Returns: Nothing
-func_checklibs ()
{
local loc_LIBS=$@
for lib in ${loc_LIBS[@]}; do
@@ -73,10 +252,12 @@
done
}
+
+func_checkexecs ()
+#-----------------
# Check that a list of executable is set and valid (ie each exec exists as an executable
file)
# Params: $@ - List of exec values to be checked
# Returns: Nothing
-func_checkexecs ()
{
local loc_EXECS=$@
for exec in ${loc_EXECS[@]}; do
@@ -89,137 +270,55 @@
done
}
-#-----------------
-srcdir=`dirname $0`
+#--- Start of script ---
-# If this script is run using parameter $1 = "LONG_TEST", then run the long
test scripts
-if test x$1 == x"LONG_TEST"; then
- echo "Running long tests..."
- PYTHON_TESTNAME="long_cluster_tests.py"
-else
- PYTHON_TESTNAME="cluster_tests.py"
-fi
+func_check_required_env || exit 1 # Cannot run, exit with error
+func_check_ais || exit 0 # A warning, not a failure.
-# Check AIS requirements and run tests if found.
-id -nG | grep '\<ais\>' >/dev/null || \
- NOGROUP="You are not a member of the ais group."
-ps -u root | grep 'aisexec\|corosync' >/dev/null || \
- NOAISEXEC="The aisexec or corosync daemon is not running as root"
-
-if test -n "$NOGROUP" -o -n "$NOAISEXEC"; then
- cat <<EOF
-
- ========== WARNING: NOT RUNNING CLUSTER TESTS ============
-
- Tests that depend on the openais library (used for clustering)
- will not be run because:
-
- $NOGROUP
- $NOAISEXEC
-
- ==========================================================
-
-EOF
- exit 0; # A warning, not a failure.
+srcdir=`dirname $0`
+if test -z ${abs_srcdir}; then
+ abs_srcdir=${srcdir}
fi
+export STORE_LIB="${abs_srcdir}/../../lib/.libs/msgstore.so"
-# QPID_DIR is defined for source tree builds by the --with-qpid-checkout configure
option.
-# QPID_BLD is defined as the build directory, either $QPID_DIR/cpp or separately
-# specified with the --with-qpid-build option for VPATH builds.
-# If set, then set all the env vars from the correct places in the svn source tree.
-if test "${QPID_DIR}" -a -d "${QPID_DIR}" ; then
- # Paths and dirs
- export PYTHONPATH="${QPID_DIR}/python":"${abs_srcdir}"
-
- # Libraries
- export CLUSTER_LIB="${QPID_BLD}/src/.libs/cluster.so"
- export TEST_STORE_LIB="${QPID_BLD}/src/tests/.libs/test_store.so"
-
- # Executables
- CPP_CLUSTER_EXEC="${QPID_BLD}/src/tests/cluster_test"
- PYTHON_CLUSTER_EXEC="${QPID_DIR}/cpp/src/tests/$PYTHON_TESTNAME"
- export QPIDD_EXEC="${QPID_BLD}/src/qpidd"
- export QPID_CONFIG_EXEC="${QPID_DIR}/python/commands/qpid-config"
- export QPID_ROUTE_EXEC="${QPID_DIR}/python/commands/qpid-route"
- export RECEIVER_EXEC="${QPID_BLD}/src/tests/receiver"
- export SENDER_EXEC="${QPID_BLD}/src/tests/sender"
+PYTHON_TESTNAME=cluster_tests.py
+if test "${QPID_DIR}" -a -d "${QPID_DIR}" ; then
+ func_set_svn_env
else
- if test "${QPID_PREFIX}" -a -d "${QPID_PREFIX}" ; then
- QPID_BIN_DIR=$QPID_PREFIX/bin
- QPID_SBIN_DIR=$QPID_PREFIX/sbin
- QPID_LIB_DIR=$QPID_PREFIX/lib
- QPID_LIBEXEC_DIR=$QPID_PREFIX/libexec
- fi
- # These four env vars must be set prior to calling this script
- func_checkpaths QPID_BIN_DIR QPID_SBIN_DIR QPID_LIB_DIR QPID_LIBEXEC_DIR
-
- # Paths and dirs
- export
PYTHONPATH="${QPID_LIB_DIR}/python":"${QPID_LIB_DIR}/python2.4"
-
- # Libraries
- export CLUSTER_LIB="${QPID_LIB_DIR}/qpid/daemon/cluster.so"
- export TEST_STORE_LIB="${QPID_LIB_DIR}/qpid/tests/test_store.so"
-
- # Executables
- CPP_CLUSTER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/cluster_test"
- PYTHON_CLUSTER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/$PYTHON_TESTNAME"
- export QPIDD_EXEC="${QPID_SBIN_DIR}/qpidd"
- export QPID_CONFIG_EXEC="${QPID_BIN_DIR}/qpid-config"
- export QPID_ROUTE_EXEC="${QPID_BIN_DIR}/qpid-route"
- export RECEIVER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/receiver"
- export SENDER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/sender"
+ func_set_prefix_evn
fi
-export STORE_LIB="${abs_srcdir}/../../lib/.libs/msgstore.so"
+func_mk_data_dir
# Check expected environment vars are set
-func_checkpaths PYTHONPATH TMP_DATA_DIR
-func_checklibs CLUSTER_LIB TEST_STORE_LIB STORE_LIB
+func_checkpaths PYTHON_DIR PYTHONPATH TMP_DATA_DIR
+func_checklibs CLUSTER_LIB TEST_STORE_LIB STORE_LIB STORE_LIB
func_checkexecs CPP_CLUSTER_EXEC PYTHON_CLUSTER_EXEC QPIDD_EXEC QPID_CONFIG_EXEC
QPID_ROUTE_EXEC RECEIVER_EXEC SENDER_EXEC
-# Run the C++ cluster tests
+FAILING_PYTHON_TESTS="${abs_srcdir}/../failing_python_tests.txt"
+if test -z $1; then
+ CLUSTER_TEST="${PYTHON_DIR}/qpid-python-test -m cluster_tests -I
${FAILING_PYTHON_TESTS} cluster_tests.ShortTests.*"
+else
+ CLUSTER_TEST="${PYTHON_DIR}/qpid-python-test -m cluster_tests -I
${FAILING_PYTHON_TESTS} cluster_tests.LongTests.*"
+ LONG_TEST=1
+fi
+
+# Run the C++ cluster tests (which are by definition short tests)
if test ! ${LONG_TEST}; then
echo "Running C++ cluster tests..."
sg ais -c "${CPP_CLUSTER_EXEC}"
RETCODE=$?
if test x${RETCODE} != x0; then
- exit 1;
+ exit 1;
fi
fi
-# --- Check for Python, then run python cluster tests ---
+func_check_qpid_python || exit 0 # A warning, not a failure.
-if python -c "import qpid" ; then
- PYTHON_TESTS=python_tests
- FAILING_PYTHON_TESTS="${abs_srcdir}/failing_python_tests.txt"
-else
- cat <<EOF
-
- =========== WARNING: PYTHON TESTS DISABLED ==============
-
- Unable to load python qpid module - skipping python tests.
-
- PYTHONPATH=${PYTHONPATH}
-
- ===========================================================
-
-EOF
- exit
-fi
-
-#Make sure temp dir exists if this is the first to use it
-if ! test -d "${TMP_DATA_DIR}" ; then
- mkdir -p "${TMP_DATA_DIR}/cluster"
-else
- # Delete old cluster test dirs
- rm -rf "${TMP_DATA_DIR}/cluster"
- mkdir -p "${TMP_DATA_DIR}/cluster"
-fi
-export TMP_DATA_DIR
-
echo "Running Python cluster tests..."
-sg ais -c "${PYTHON_CLUSTER_EXEC} -v"
+sg ais -c "${CLUSTER_TEST}"
RETCODE=$?
+
if test x${RETCODE} != x0; then
exit 1;
fi
Modified: store/trunk/cpp/tests/cluster/run_long_cluster_tests
===================================================================
--- store/trunk/cpp/tests/cluster/run_long_cluster_tests 2009-08-13 19:46:04 UTC (rev
3578)
+++ store/trunk/cpp/tests/cluster/run_long_cluster_tests 2009-08-14 19:00:10 UTC (rev
3579)
@@ -21,4 +21,4 @@
#
# The GNU Lesser General Public License is available in the file COPYING.
-./run_cluster_tests LONG_TEST
+./run_cluster_tests long_cluster_tests
Modified: store/trunk/cpp/tests/run_python_tests
===================================================================
--- store/trunk/cpp/tests/run_python_tests 2009-08-13 19:46:04 UTC (rev 3578)
+++ store/trunk/cpp/tests/run_python_tests 2009-08-14 19:00:10 UTC (rev 3579)
@@ -43,7 +43,7 @@
export PYTHONPATH=${QPID_PYTHON_DIR}:${abs_srcdir}
if python -c "import qpid" ; then
- PYTHON_TESTS=python_tests
+ PYTHON_TESTS=
FAILING_PYTHON_TESTS=${abs_srcdir}/failing_python_tests.txt
else
cat <<EOF
Show replies by date