qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r1530301 [1/8] - in /qpid/trunk/qpid: cpp/src/tests/legacystore/ cpp/src/tests/legacystore/federation/ cpp/src/tests/legacystore/jrnl/ cpp/src/tests/legacystore/jrnl/jtt/ cpp/src/tests/legacystore/python_tests/ tools/src/py/ tools/src/py/qp...
Date Tue, 08 Oct 2013 15:09:01 GMT
Author: astitcher
Date: Tue Oct  8 15:09:00 2013
New Revision: 1530301

URL: http://svn.apache.org/r1530301
Log:
QPID-5215: Import rest of legacy store tests and utilities from original code

Added:
    qpid/trunk/qpid/cpp/src/tests/legacystore/federation/
    qpid/trunk/qpid/cpp/src/tests/legacystore/federation/Makefile.am
    qpid/trunk/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_federation_sys_tests   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_long_federation_sys_tests   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_auto_expand.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic_txn.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_helper_fns.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_read.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_read_txn.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_enq_map.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_jdir.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_jerrno.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_jexception.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_jinf.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_lpmgr.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_rec_hdr.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_time_ns.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_ut_txn_map.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/chk_jdata   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/cp_rtest_jrnl   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jhexdump   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_data_src.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_jrnl_init_params.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_jrnl_instance.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_read_arg.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_test_case.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_test_case_result.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_test_case_result_agregation.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_test_case_set.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/_ut_test_case_set.csv
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/args.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/args.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/data_src.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/data_src.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/jfile_chk.py   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/jrnl_init_params.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/jrnl_init_params.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/jrnl_instance.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/jrnl_instance.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/jtt.csv
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/main.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/read_arg.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/read_arg.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_case.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_case.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_case_result.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_case_result.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_case_result_agregation.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_case_result_agregation.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_case_set.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_case_set.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_mgr.cpp
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/jtt/test_mgr.h
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/prof   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/run-journal-tests   (with props)
    qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/tests.ods
    qpid/trunk/qpid/cpp/src/tests/legacystore/python_tests/
    qpid/trunk/qpid/cpp/src/tests/legacystore/python_tests/__init__.py
    qpid/trunk/qpid/cpp/src/tests/legacystore/python_tests/client_persistence.py
    qpid/trunk/qpid/cpp/src/tests/legacystore/python_tests/resize.py
    qpid/trunk/qpid/cpp/src/tests/legacystore/python_tests/store_test.py
    qpid/trunk/qpid/tools/src/py/qpid-store-chk   (with props)
    qpid/trunk/qpid/tools/src/py/qpid-store-resize   (with props)
    qpid/trunk/qpid/tools/src/py/qpidstore/
    qpid/trunk/qpid/tools/src/py/qpidstore/__init__.py
    qpid/trunk/qpid/tools/src/py/qpidstore/janal.py
    qpid/trunk/qpid/tools/src/py/qpidstore/jerr.py
    qpid/trunk/qpid/tools/src/py/qpidstore/jrnl.py
Modified:
    qpid/trunk/qpid/cpp/src/tests/legacystore/CMakeLists.txt
    qpid/trunk/qpid/cpp/src/tests/legacystore/run_python_tests   (contents, props changed)

Modified: qpid/trunk/qpid/cpp/src/tests/legacystore/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/legacystore/CMakeLists.txt?rev=1530301&r1=1530300&r2=1530301&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/legacystore/CMakeLists.txt (original)
+++ qpid/trunk/qpid/cpp/src/tests/legacystore/CMakeLists.txt Tue Oct  8 15:09:00 2013
@@ -93,17 +93,96 @@ define_legacystore_test (OrderingTest)
 define_legacystore_test (TransactionalTest)
 define_legacystore_test (TwoPhaseCommitTest)
 
+# Journal tests
+MACRO (define_journal_test mainSourceFile)
+if ("${ARGV1}" STREQUAL "LONG")
+  set (testname "journal_long_${mainSourceFile}")
+else ()
+  set (testname "journal_${mainSourceFile}")
+endif ()
+add_executable (${testname}
+                jrnl/${mainSourceFile}
+                unit_test
+                ${platform_test_additions})
+target_link_libraries (${testname}
+                       ${qpid_test_boost_libs}
+                       legacystore_shared)
+if ("${ARGV1}" STREQUAL "LONG")
+  set_target_properties(${testname} PROPERTIES COMPILE_DEFINITIONS LONG_TEST)
+endif ()
+remember_location(${testname})
+add_test (${testname} ${test_wrap} ${${testname}_LOCATION})
+unset (testname)
+ENDMACRO (define_journal_test)
+
+define_journal_test (_ut_time_ns)
+define_journal_test (_ut_jexception)
+define_journal_test (_ut_jerrno)
+define_journal_test (_ut_rec_hdr)
+define_journal_test (_ut_jinf)
+define_journal_test (_ut_jdir)
+define_journal_test (_ut_enq_map)
+define_journal_test (_ut_txn_map)
+define_journal_test (_ut_lpmgr)
+define_journal_test (_st_basic)
+define_journal_test (_st_basic_txn)
+define_journal_test (_st_read)
+define_journal_test (_st_read_txn)
+define_journal_test (_st_auto_expand)
+define_journal_test (_ut_lpmgr LONG)
+define_journal_test (_st_basic LONG)
+define_journal_test (_st_read LONG)
+
+add_executable(jtt
+    jrnl/jtt/args.cpp
+    jrnl/jtt/data_src.cpp
+    jrnl/jtt/jrnl_init_params.cpp
+    jrnl/jtt/jrnl_instance.cpp
+    jrnl/jtt/main.cpp
+    jrnl/jtt/read_arg.cpp
+    jrnl/jtt/test_case.cpp
+    jrnl/jtt/test_case_result.cpp
+    jrnl/jtt/test_case_result_agregation.cpp
+    jrnl/jtt/test_case_set.cpp
+    jrnl/jtt/test_mgr.cpp)
+
+target_link_libraries (jtt
+                       ${Boost_PROGRAM_OPTIONS_LIBRARY}
+                       legacystore_shared)
+
+add_test(journal_jtt ${CMAKE_CURRENT_BINARY_DIR}/jtt -c ${CMAKE_CURRENT_SOURCE_DIR}/jrnl/jtt/jtt.csv)
+
+add_executable (jtt__ut
+    jrnl/jtt/_ut_data_src.cpp
+    jrnl/jtt/_ut_jrnl_init_params.cpp
+    jrnl/jtt/_ut_read_arg.cpp
+    jrnl/jtt/_ut_jrnl_instance.cpp
+    jrnl/jtt/_ut_test_case.cpp
+    jrnl/jtt/_ut_test_case_result.cpp
+    jrnl/jtt/_ut_test_case_result_agregation.cpp
+    jrnl/jtt/_ut_test_case_set.cpp
+    jrnl/jtt/args.cpp
+    jrnl/jtt/data_src.cpp
+    jrnl/jtt/jrnl_init_params.cpp
+    jrnl/jtt/jrnl_instance.cpp
+    jrnl/jtt/read_arg.cpp
+    jrnl/jtt/test_case.cpp
+    jrnl/jtt/test_case_set.cpp
+    jrnl/jtt/test_case_result.cpp
+    jrnl/jtt/test_case_result_agregation.cpp
+    unit_test.cpp)
+
+target_link_libraries (jtt__ut
+                       ${qpid_test_boost_libs}
+                       ${Boost_PROGRAM_OPTIONS_LIBRARY}
+                       legacystore_shared)
+
+add_test(NAME journal_jtt_ut WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/jrnl/jtt COMMAND ${CMAKE_CURRENT_BINARY_DIR}/jtt__ut)
+
 #
 # Other test programs
 #
 
-# This should ideally be done as part of the test run, but I don't know a way
-# to get these arguments and the working directory set like Makefile.am does,
-# and have that run during the test pass.
-if (PYTHON_EXECUTABLE)
-  set (python_bld ${CMAKE_CURRENT_BINARY_DIR}/python)
-  execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py install --prefix=${pythoon_bld} --install-lib=${python_bld} --install-scripts=${python_bld}/commands
-                  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/../python)
-endif (PYTHON_EXECUTABLE)
+add_test (legacystore_python_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_python_tests${test_script_suffix})
 
 endif (BUILD_LEGACYSTORE)

Added: qpid/trunk/qpid/cpp/src/tests/legacystore/federation/Makefile.am
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/legacystore/federation/Makefile.am?rev=1530301&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/legacystore/federation/Makefile.am (added)
+++ qpid/trunk/qpid/cpp/src/tests/legacystore/federation/Makefile.am Tue Oct  8 15:09:00 2013
@@ -0,0 +1,46 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+abs_srcdir=@abs_srcdir@
+
+TMP_DATA_DIR=$(abs_srcdir)/../tmp_data_dir
+
+TESTS = \
+  run_federation_sys_tests
+
+LONG_TESTS = \
+  run_long_federation_sys_tests
+
+EXTRA_DIST = \
+  federation_tests_env.sh \
+  run_federation_sys_tests \
+  run_long_federation_sys_tests
+
+TESTS_ENVIRONMENT = \
+  QPID_DIR=$(QPID_DIR) \
+  QPID_BLD=$(QPID_BLD) \
+  TMP_DATA_DIR=$(TMP_DATA_DIR) \
+  abs_srcdir=$(abs_srcdir)
+  
+check-long: all
+	$(MAKE) check TESTS="$(LONG_TESTS)" SUBDIRS=.
+
+# END
+    

Added: qpid/trunk/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh?rev=1530301&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh (added)
+++ qpid/trunk/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh Tue Oct  8 15:09:00 2013
@@ -0,0 +1,313 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# --- 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_clustering ()
+#-----------------------
+# Check openAIS/corosync is running and user has correct privileges
+# Params: None
+# Returns: 0 if openAIS/corosync is running, 1 otherwise
+# Sets env var COROSYNC to 1 if corosync is running, not set otherwise
+{
+    # Check either aisexec or corosync is running as root
+    cluster_prog=`ps -u root | grep 'aisexec\|corosync'`
+    test -n "$cluster_prog" || NODAEMON="Neither aisexec nor corosync is running as root"
+    if test -z "$NODAEMON"; then
+        # Test for corosync running
+        echo $cluster_prog | grep "aisexec" > /dev/null || COROSYNC=1
+        if test -n "$COROSYNC"; then
+            # Corosync auth test
+            user=`whoami`
+            ls /etc/corosync/uidgid.d | grep $user > /dev/null || NOAUTH="You are not authorized to use corosync."
+        else
+            # OpenAis auth test
+            id -nG | grep '\<ais\>' >/dev/null || NOAUTH="You are not a member of the ais group."
+        fi
+    fi
+    
+    if test -n "$NODAEMON" -o -n "$NOAUTH"; then
+        cat <<EOF
+
+    ========== WARNING: NOT RUNNING CLUSTER TESTS ============
+	
+    Cluster tests will not be run because:
+	
+    $NODAEMON
+    $NOAUTH
+	
+    ==========================================================
+    
+EOF
+    	return 1
+	fi
+    CLUSTERING_ENABLED=1
+	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_python_env()
+#--------------------
+# Set up the python path
+# Params: None
+# Returns: Nothing
+{
+	if test "${QPID_DIR}" -a -d "${QPID_DIR}" ; then
+		QPID_PYTHON=${QPID_DIR}/python
+		QPID_TOOLS=${QPID_DIR}/tools/src/py
+		QMF_LIB=${QPID_DIR}/extras/qmf/src/py
+		export PYTHONPATH=${QPID_PYTHON}:${QMF_LIB}:${QPID_TOOLS}:$PYTHONPATH
+	fi
+}
+
+func_set_env ()
+#--------------
+# Set up the environment based on value of ${QPID_DIR}: if ${QPID_DIR} exists, assume a svn checkout,
+# otherwise set up for an installed or prefix test.
+# Params: None
+# Returns: Nothing
+{
+    if test "${QPID_DIR}" -a -d "${QPID_DIR}" ; then
+        # 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.
+
+	    # Check QPID_BLD is also set
+	    if test -z ${QPID_BLD}; then
+		    QPID_BLD="${QPID_DIR}/cpp"
+	    fi
+	    source $QPID_BLD/src/tests/test_env.sh
+#	    CPP_CLUSTER_EXEC="${QPID_BLD}/src/tests/cluster_test"
+#	    PYTHON_CLUSTER_EXEC="${QPID_DIR}/cpp/src/tests/$PYTHON_TESTNAME"
+	    FEDERATION_SYS_TESTS_FAIL="${QPID_DIR}/cpp/src/tests/federation_sys_tests.fail"
+        if test -z ${STORE_LIB}; then
+            STORE_LIB="../../lib/.libs/msgstore.so"
+        fi
+#        export STORE_ENABLE=1
+    else
+        # 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.
+        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
+	    export PATH="$QPID_BIN_DIR:$QPID_SBIN_DIR:$QPID_LIBEXEC_DIR/qpid/tests:$PATH"
+        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 PYTHON_DIR="${QPID_BIN_DIR}"
+	    export PYTHONPATH="${QPID_LIB_DIR}/python:${QPID_LIBEXEC_DIR}/qpid/tests:${QPID_LIB_DIR}/python2.4:${QPID_LIB_DIR}/python2.4/site-packages:${PYTHONPATH}"
+	    # Libraries
+	    export CLUSTER_LIB="${QPID_LIB_DIR}/qpid/daemon/cluster.so"
+	    export ACL_LIB="${QPID_LIB_DIR}/qpid/daemon/acl.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 QPID_CLUSTER_EXEC="${QPID_BIN_DIR}/qpid-cluster"
+#	    export RECEIVER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/receiver"
+#	    export SENDER_EXEC="${QPID_LIBEXEC_DIR}/qpid/tests/sender"
+	    export QPID_PYTHON_TEST="${QPID_BIN_DIR}/qpid-python-test"
+
+	    # Data
+	    FEDERATION_SYS_TESTS_FAIL="${QPID_LIBEXEC_DIR}/qpid/tests/federation_sys_tests.fail"
+    fi
+}
+
+
+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/federation_sys_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
+{
+	local loc_VAR=$1
+	if test -z ${!loc_VAR}; then
+		echo "WARNING: environment variable ${loc_VAR} not set."
+		return 1
+	fi
+	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
+{
+	local loc_PATHS=$@
+	for path in ${loc_PATHS}; do
+		func_checkvar ${path}
+		if test $? == 0; then
+			local temp_IFS=${IFS}
+			IFS=":"
+			local pl=${!path}
+			for p in ${pl[@]}; do
+				if test ! -d ${p}; then
+					echo "WARNING: Directory ${p} in var ${path} not found."
+				fi
+			done
+			IFS=${temp_IFS}
+		fi
+	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
+{
+	local loc_LIBS=$@
+	for lib in ${loc_LIBS[@]}; do
+		func_checkvar ${lib}
+		if test $? == 0; then
+			if test ! -x ${!lib}; then
+				echo "WARNING: Library ${lib}=${!lib} not found."
+			fi
+		fi
+	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
+{
+	local loc_EXECS=$@
+	for exec in ${loc_EXECS[@]}; do
+		func_checkvar ${exec}
+		if test $? == 0; then
+			if test ! -x ${!exec}; then
+				echo "WARNING: Executable ${exec}=${!exec} not found or is not executable."
+			fi
+		fi
+	done
+}
+
+
+#--- Start of script ---
+
+func_set_python_env
+func_check_required_env || exit 1   # Cannot run, exit with error
+func_check_qpid_python || exit 1    # Cannot run, exit with error
+func_check_clustering               # Warning
+
+PYTHON_TESTNAME=federation_sys.py
+func_set_env
+func_mk_data_dir
+
+# Check expected environment vars are set
+func_checkpaths PYTHON_DIR PYTHONPATH TMP_DATA_DIR
+func_checklibs CLUSTER_LIB STORE_LIB
+func_checkexecs QPIDD_EXEC QPID_CONFIG_EXEC QPID_ROUTE_EXEC QPID_PYTHON_TEST
+
+FAILING_PYTHON_TESTS="${abs_srcdir}/../failing_python_tests.txt"
+if test -z $1; then
+	FEDERATION_SYS_TEST="${QPID_PYTHON_TEST} -m cluster_tests -I ${FEDERATION_SYS_TESTS_FAIL}"
+else
+	FEDERATION_SYS_TEST="${QPID_PYTHON_TEST} -m cluster_tests -I ${FEDERATION_SYS_TESTS_FAIL} cluster_tests.LongTests.*"
+	LONG_TEST=1
+fi
+

Propchange: qpid/trunk/qpid/cpp/src/tests/legacystore/federation/federation_tests_env.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_federation_sys_tests
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_federation_sys_tests?rev=1530301&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_federation_sys_tests (added)
+++ qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_federation_sys_tests Tue Oct  8 15:09:00 2013
@@ -0,0 +1,96 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# Run the federation tests.
+source ${abs_srcdir}/federation_tests_env.sh
+
+MODULENAME=federation_sys
+
+# Test for long test
+if [[ "$1" == "LONG_TEST" ]]; then
+    USE_LONG_TEST=1
+    shift # get rid of this param so it is not treated as a test name
+fi
+
+trap stop_brokers INT TERM QUIT
+
+MODULES="--load-module ${STORE_LIB} --jfile-size 12 --num-jfiles 4"
+CLUSTER_MODULE="--load-module ${CLUSTER_LIB} "
+if [ -z ${USE_LONG_TEST} ]; then
+    SKIPTESTS="-i federation_sys.A_Long* -i federation_sys.B_Long* -i federation_sys.E_Long* -i federation_sys.F_Long*"
+fi
+if [ -z ${CLUSTERING_ENABLED} ]; then
+    SKIPTESTS="${SKIPTESTS} -i federation_sys.C_* -i federation_sys.D_* -i federation_sys.G_* -i federation_sys.H_*"
+elif [ -z ${USE_LONG_TEST} ]; then
+    SKIPTESTS="${SKIPTESTS} -i federation_sys.C_Long* -i federation_sys.D_Long* -i federation_sys.G_Long* -i federation_sys.H_Long*"
+fi
+
+start_brokers() {
+    clean_or_create_dir() {
+        if [ -n "$1" -a -d $1 ]; then
+            rm -rf $1/*
+        else
+            mkdir -p $1
+        fi
+    }
+    start_broker() {
+        clean_or_create_dir $1
+        ${QPIDD_EXEC} --daemon --port 0 --auth no --data-dir $1 $2 > qpidd.port
+        PORT=`cat qpidd.port`
+        eval "$3=${PORT}"
+    }
+    start_broker ${TMP_DATA_DIR}/local "${MODULES} --log-enable info+ --log-to-file ${TMP_DATA_DIR}/qpidd.log.local" LOCAL_PORT
+    start_broker ${TMP_DATA_DIR}/remote "${MODULES} --log-enable info+ --log-to-file ${TMP_DATA_DIR}/qpidd.log.remote" REMOTE_PORT
+    if [ -n "$CLUSTERING_ENABLED" ]; then
+        start_broker ${TMP_DATA_DIR}/cluster/c1.1 "${MODULES} ${CLUSTER_MODULE} --cluster-name test-cluster-1 --log-enable info+ --log-to-file ${TMP_DATA_DIR}/qpidd.log.cluster1.1" CLUSTER_C1_1
+        start_broker ${TMP_DATA_DIR}/cluster/c1.2 "${MODULES} ${CLUSTER_MODULE} --cluster-name test-cluster-1 --log-enable info+ --log-to-file ${TMP_DATA_DIR}/qpidd.log.cluster1.2" CLUSTER_C1_2
+        start_broker ${TMP_DATA_DIR}/cluster/c2.1 "${MODULES} ${CLUSTER_MODULE} --cluster-name test-cluster-2 --log-enable info+ --log-to-file ${TMP_DATA_DIR}/qpidd.log.cluster2.1" CLUSTER_C2_1
+        start_broker ${TMP_DATA_DIR}/cluster/c2.2 "${MODULES} ${CLUSTER_MODULE} --cluster-name test-cluster-2 --log-enable info+ --log-to-file ${TMP_DATA_DIR}/qpidd.log.cluster2.2" CLUSTER_C2_2
+    fi
+    rm qpidd.port
+}
+
+stop_brokers() {
+    ${QPIDD_EXEC} -q --port ${LOCAL_PORT}
+    ${QPIDD_EXEC} -q --port ${REMOTE_PORT}
+    if [ -n "${CLUSTERING_ENABLED}" ]; then
+        ${QPID_CLUSTER_EXEC} --all-stop --force localhost:${CLUSTER_C1_1}
+        ${QPID_CLUSTER_EXEC} --all-stop --force localhost:${CLUSTER_C2_1}
+    fi
+}
+
+if test -d ${PYTHON_DIR} ;  then
+    start_brokers
+    if [ -z ${CLUSTERING_ENABLED} ]; then
+        echo "Running federation tests using brokers on local port ${LOCAL_PORT}, remote port ${REMOTE_PORT} (NOTE: clustering is DISABLED)"
+    else
+        echo "Running federation tests using brokers on local port ${LOCAL_PORT}, remote port ${REMOTE_PORT}, local cluster nodes ${CLUSTER_C1_1} ${CLUSTER_C1_2}, remote cluster nodes ${CLUSTER_C2_1} ${CLUSTER_C2_2}"
+    fi
+    if [ -z ${USE_LONG_TEST} ]; then
+        echo "NOTE: To run a full set of federation system tests, use \"make check-long\"."
+    fi
+    ${QPID_PYTHON_TEST} -m ${MODULENAME} ${SKIPTESTS} -b localhost:$REMOTE_PORT -Dlocal-port=$LOCAL_PORT -Dremote-port=$REMOTE_PORT -Dlocal-cluster-ports="$CLUSTER_C1_1 $CLUSTER_C1_2" -Dremote-cluster-ports="$CLUSTER_C2_1 $CLUSTER_C2_2" $@
+    RETCODE=$?
+    stop_brokers
+    if test x$RETCODE != x0; then
+        echo "FAIL federation tests"; exit 1;
+    fi
+fi

Propchange: qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_federation_sys_tests
------------------------------------------------------------------------------
    svn:executable = *

Added: qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_long_federation_sys_tests
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_long_federation_sys_tests?rev=1530301&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_long_federation_sys_tests (added)
+++ qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_long_federation_sys_tests Tue Oct  8 15:09:00 2013
@@ -0,0 +1,24 @@
+#! /bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# Run the federation system tests (long version).
+
+./run_federation_sys_tests LONG_TEST $@

Propchange: qpid/trunk/qpid/cpp/src/tests/legacystore/federation/run_long_federation_sys_tests
------------------------------------------------------------------------------
    svn:executable = *

Added: qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_auto_expand.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_auto_expand.cpp?rev=1530301&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_auto_expand.cpp (added)
+++ qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_auto_expand.cpp Tue Oct  8 15:09:00 2013
@@ -0,0 +1,140 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "../unit_test.h"
+#include <cmath>
+#include <iostream>
+#include "qpid/legacystore/jrnl/jcntl.h"
+
+using namespace boost::unit_test;
+using namespace mrg::journal;
+using namespace std;
+
+QPID_AUTO_TEST_SUITE(journal_auto_expand)
+
+const string test_filename("_st_auto_expand");
+
+#include "_st_helper_fns.h"
+
+// === Test suite ===
+
+QPID_AUTO_TEST_CASE(no_ae_threshold)
+{
+    string test_name = get_test_name(test_filename, "no_ae_threshold");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS);
+        unsigned m;
+
+        // Fill journal to just below threshold
+        u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES,
+                DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE, LARGE_MSG_REC_SIZE_DBLKS);
+        for (m=0; m<t; m++)
+            enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+        // This enqueue should exceed the threshold
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), t);
+        enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false, RHM_IORES_ENQCAPTHRESH);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), t);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(no_ae_threshold_dequeue_some)
+{
+    string test_name = get_test_name(test_filename, "no_ae_threshold_dequeue_some");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS);
+        unsigned m;
+
+        // Fill journal to just below threshold
+        u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES,
+                DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE, LARGE_MSG_REC_SIZE_DBLKS);
+        for (m=0; m<t; m++)
+            enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+        // This enqueue should exceed the threshold
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), t);
+        enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false, RHM_IORES_ENQCAPTHRESH);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), t);
+
+        // Dequeue 25 msgs
+        #define NUM_MSGS_DEQ 25
+        for (m=0; m<NUM_MSGS_DEQ; m++)
+            deq_msg(jc, m, m+t);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(t-NUM_MSGS_DEQ));
+
+        // Check we can still enqueue and dequeue
+        for (m=t+NUM_MSGS_DEQ; m<t+NUM_MSGS_DEQ+NUM_MSGS; m++)
+            enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+        for (m=t+NUM_MSGS_DEQ; m<t+NUM_MSGS_DEQ+NUM_MSGS; m++)
+            deq_msg(jc, m, m+NUM_MSGS_DEQ+NUM_MSGS);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(no_ae_threshold_dequeue_all)
+{
+    string test_name = get_test_name(test_filename, "no_ae_threshold_dequeue_all");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS);
+        unsigned m;
+
+        // Fill journal to just below threshold
+        u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES,
+                DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE, LARGE_MSG_REC_SIZE_DBLKS);
+        for (m=0; m<t; m++)
+            enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+        // This enqueue should exceed the threshold
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), t);
+        enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false, RHM_IORES_ENQCAPTHRESH);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), t);
+
+        // Dequeue all msgs
+        for (m=0; m<t; m++)
+            deq_msg(jc, m, m+t);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+
+        // Check we can still enqueue and dequeue
+        for (m=2*t; m<2*t + NUM_MSGS; m++)
+            enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+        for (m=2*t; m<2*t + NUM_MSGS; m++)
+            deq_msg(jc, m, m+2*t+NUM_MSGS);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_SUITE_END()

Added: qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic.cpp?rev=1530301&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic.cpp (added)
+++ qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic.cpp Tue Oct  8 15:09:00 2013
@@ -0,0 +1,558 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "../unit_test.h"
+#include <cmath>
+#include <iostream>
+#include "qpid/legacystore/jrnl/jcntl.h"
+
+using namespace boost::unit_test;
+using namespace mrg::journal;
+using namespace std;
+
+QPID_AUTO_TEST_SUITE(journal_basic)
+
+const string test_filename("_st_basic");
+
+#include "_st_helper_fns.h"
+
+// === Test suite ===
+
+#ifndef LONG_TEST
+/*
+ * ==============================================
+ *                  NORMAL TESTS
+ * This section contains normal "make check" tests
+ * for building/packaging. These are built when
+ * LONG_TEST is _not_ defined.
+ * ==============================================
+ */
+
+QPID_AUTO_TEST_CASE(instantiation)
+{
+    string test_name = get_test_name(test_filename, "instantiation");
+    try
+    {
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        BOOST_CHECK_EQUAL(jc.is_ready(), false);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(initialization)
+{
+    string test_name = get_test_name(test_filename, "initialization");
+    try
+    {
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        BOOST_CHECK_EQUAL(jc.is_ready(), false);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        BOOST_CHECK_EQUAL(jc.is_ready(), true);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_dequeue_block)
+{
+    string test_name = get_test_name(test_filename, "enqueue_dequeue_block");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        for (int m=0; m<NUM_MSGS; m++)
+            BOOST_CHECK_EQUAL(enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false), u_int64_t(m));
+        for (int m=0; m<NUM_MSGS; m++)
+            deq_msg(jc, m, m+NUM_MSGS);
+
+        // Again...
+        for (int m=2*NUM_MSGS; m<3*NUM_MSGS; m++)
+            BOOST_CHECK_EQUAL(enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false), u_int64_t(m));
+        for (int m=2*NUM_MSGS; m<3*NUM_MSGS; m++)
+            deq_msg(jc, m, m+3*NUM_MSGS);
+
+        // Disjoint rids
+        for (int m=10*NUM_MSGS; m<11*NUM_MSGS; m++)
+            BOOST_CHECK_EQUAL(enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false), u_int64_t(m));
+        for (int m=10*NUM_MSGS; m<11*NUM_MSGS; m++)
+            deq_msg(jc, m, m+11*NUM_MSGS);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_dequeue_interleaved)
+{
+    string test_name = get_test_name(test_filename, "enqueue_dequeue_interleaved");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        for (int m=0; m<2*NUM_MSGS; m+=2)
+        {
+            BOOST_CHECK_EQUAL(enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false), u_int64_t(m));
+            deq_msg(jc, m, m+1);
+        }
+
+        // Again...
+        for (int m=2*NUM_MSGS; m<4*NUM_MSGS; m+=2)
+        {
+            BOOST_CHECK_EQUAL(enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false), u_int64_t(m));
+            deq_msg(jc, m, m+1);
+        }
+
+        // Disjoint rids
+        for (int m=10*NUM_MSGS; m<12*NUM_MSGS; m+=2)
+        {
+            BOOST_CHECK_EQUAL(enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false), u_int64_t(m));
+            deq_msg(jc, m, m+1);
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_dequeue_interleaved_file_rollover)
+{
+    string test_name = get_test_name(test_filename, "enqueue_dequeue_interleaved_file_rollover");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        unsigned n = num_msgs_to_full(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS * JRNL_SBLK_SIZE,
+                16*MSG_REC_SIZE_DBLKS, true);
+        for (unsigned m=0; m<3*2*n; m+=2) // overwrite files 3 times
+        {
+            enq_msg(jc, m, create_msg(msg, m, 16*MSG_SIZE), false);
+            deq_msg(jc, m, m+1);
+        }
+        jc.stop(true);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(empty_recover)
+{
+    string test_name = get_test_name(test_filename, "empty_recover");
+    try
+    {
+        {
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            BOOST_CHECK_EQUAL(jc.is_ready(), false);
+            BOOST_CHECK_EQUAL(jc.is_read_only(), false);
+            jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+            BOOST_CHECK_EQUAL(jc.is_ready(), true);
+            BOOST_CHECK_EQUAL(jc.is_read_only(), false);
+        }
+        {
+            u_int64_t hrid;
+
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            BOOST_CHECK_EQUAL(jc.is_ready(), false);
+            BOOST_CHECK_EQUAL(jc.is_read_only(), false);
+            jc.recover(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS, 0, hrid);
+            BOOST_CHECK_EQUAL(jc.is_ready(), true);
+            BOOST_CHECK_EQUAL(jc.is_read_only(), true);
+            BOOST_CHECK_EQUAL(hrid, u_int64_t(0));
+        }
+        {
+            u_int64_t hrid;
+
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            BOOST_CHECK_EQUAL(jc.is_ready(), false);
+            BOOST_CHECK_EQUAL(jc.is_read_only(), false);
+            jc.recover(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS, 0, hrid);
+            BOOST_CHECK_EQUAL(jc.is_ready(), true);
+            BOOST_CHECK_EQUAL(jc.is_read_only(), true);
+            BOOST_CHECK_EQUAL(hrid, u_int64_t(0));
+            jc.recover_complete();
+            BOOST_CHECK_EQUAL(jc.is_ready(), true);
+            BOOST_CHECK_EQUAL(jc.is_read_only(), false);
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_recover_dequeue_block)
+{
+    string test_name = get_test_name(test_filename, "enqueue_recover_dequeue_block");
+    try
+    {
+        {
+            string msg;
+
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+            for (int m=0; m<NUM_MSGS; m++)
+                enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
+        }
+        {
+            u_int64_t hrid;
+
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            jc.recover(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS, 0, hrid);
+            BOOST_CHECK_EQUAL(hrid, u_int64_t(NUM_MSGS - 1));
+            jc.recover_complete();
+            for (int m=0; m<NUM_MSGS; m++)
+                deq_msg(jc, m, m+NUM_MSGS);
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_recover_dequeue_interleaved)
+{
+    string test_name = get_test_name(test_filename, "enqueue_recover_dequeue_interleaved");
+    try
+    {
+        string msg;
+        u_int64_t hrid;
+
+        for (int m=0; m<2*NUM_MSGS; m+=2)
+        {
+            {
+                test_jrnl_cb cb;
+                test_jrnl jc(test_name, test_dir, test_name, cb);
+                if (m == 0)
+                    jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS); // First time only
+                else
+                {
+                    jc.recover(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS, 0, hrid);
+                    BOOST_CHECK_EQUAL(hrid, u_int64_t(m - 1));
+                    jc.recover_complete();
+                }
+                enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
+            }
+            {
+                test_jrnl_cb cb;
+                test_jrnl jc(test_name, test_dir, test_name, cb);
+                jc.recover(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS, 0, hrid);
+                BOOST_CHECK_EQUAL(hrid, u_int64_t(m));
+                jc.recover_complete();
+                deq_msg(jc, m, m+1);
+            }
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(header_flags)
+{
+    string test_name = get_test_name(test_filename, "header_flags");
+    try
+    {
+        {
+            string msg;
+
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+            // Transient msgs - should not recover
+            for (int m=0; m<NUM_MSGS; m++)
+                enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), true);
+            // Persistent msgs
+            for (int m=NUM_MSGS; m<NUM_MSGS*2; m++)
+                enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
+            // Transient extern msgs - should not recover
+            for (int m=NUM_MSGS*2; m<NUM_MSGS*3; m++)
+                enq_extern_msg(jc, m, MSG_SIZE, true);
+            // Persistnet extern msgs
+            for (int m=NUM_MSGS*3; m<NUM_MSGS*4; m++)
+                enq_extern_msg(jc, m, MSG_SIZE, false);
+        }
+        {
+            string msg;
+            u_int64_t hrid;
+
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            jc.recover(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS, 0, hrid);
+            // Recover non-transient msgs
+            for (int m=NUM_MSGS; m<NUM_MSGS*2; m++)
+            {
+                string rmsg;
+                string xid;
+                bool transientFlag;
+                bool externalFlag;
+
+                read_msg(jc, rmsg, xid, transientFlag, externalFlag);
+                BOOST_CHECK_MESSAGE(transientFlag == false, "Transient message recovered.");
+                BOOST_CHECK_MESSAGE(externalFlag == false, "External flag incorrect.");
+                BOOST_CHECK_MESSAGE(create_msg(msg, m, MSG_SIZE).compare(rmsg) == 0,
+                        "Non-transient message corrupt during recover.");
+            }
+            // Recover non-transient extern msgs
+            for (int m=NUM_MSGS*3; m<NUM_MSGS*4; m++)
+            {
+                string rmsg;
+                string xid;
+                bool transientFlag;
+                bool externalFlag;
+
+                read_msg(jc, rmsg, xid, transientFlag, externalFlag);
+                BOOST_CHECK_MESSAGE(transientFlag == false, "Transient message recovered.");
+                BOOST_CHECK_MESSAGE(externalFlag == true, "External flag incorrect.");
+                BOOST_CHECK_MESSAGE(rmsg.size() == 0, "External message returned non-zero size.");
+            }
+            jc.recover_complete();
+            // Read recovered non-transient msgs
+            for (int m=NUM_MSGS; m<NUM_MSGS*2; m++)
+            {
+                string rmsg;
+                string xid;
+                bool transientFlag;
+                bool externalFlag;
+
+                read_msg(jc, rmsg, xid, transientFlag, externalFlag);
+                BOOST_CHECK_MESSAGE(transientFlag == false, "Transient message recovered.");
+                BOOST_CHECK_MESSAGE(externalFlag == false, "External flag incorrect.");
+                BOOST_CHECK_MESSAGE(create_msg(msg, m, MSG_SIZE).compare(rmsg) == 0,
+                        "Non-transient message corrupt during recover.");
+            }
+            // Read recovered non-transient extern msgs
+            for (int m=NUM_MSGS*3; m<NUM_MSGS*4; m++)
+            {
+                string rmsg;
+                string xid;
+                bool transientFlag;
+                bool externalFlag;
+
+                read_msg(jc, rmsg, xid, transientFlag, externalFlag);
+                BOOST_CHECK_MESSAGE(transientFlag == false, "Transient message recovered.");
+                BOOST_CHECK_MESSAGE(externalFlag == true, "External flag incorrect.");
+                BOOST_CHECK_MESSAGE(rmsg.size() == 0, "External message returned non-zero size.");
+            }
+            // Dequeue recovered messages
+            for (int m=NUM_MSGS; m<NUM_MSGS*2; m++)
+                deq_msg(jc, m, m+3*NUM_MSGS);
+            for (int m=NUM_MSGS*3; m<NUM_MSGS*4; m++)
+                deq_msg(jc, m, m+2*NUM_MSGS);
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(double_dequeue)
+{
+    string test_name = get_test_name(test_filename, "double_dequeue");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        enq_msg(jc, 0, create_msg(msg, 0, MSG_SIZE), false);
+        deq_msg(jc, 0, 1);
+        try{ deq_msg(jc, 0, 2); BOOST_ERROR("Did not throw exception on second dequeue."); }
+        catch (const jexception& e){ BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_WMGR_DEQRIDNOTENQ); }
+        enq_msg(jc, 2, create_msg(msg, 1, MSG_SIZE), false);
+        deq_msg(jc, 2, 3);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+#else
+/*
+ * ==============================================
+ *                  LONG TESTS
+ * This section contains long tests and soak tests,
+ * and are run using target check-long (ie "make
+ * check-long"). These are built when LONG_TEST is
+ * defined.
+ * ==============================================
+ */
+
+QPID_AUTO_TEST_CASE(journal_overflow)
+{
+    string test_name = get_test_name(test_filename, "journal_overflow");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS);
+        unsigned m;
+
+        // Fill journal to just below threshold
+        u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE,
+                MSG_REC_SIZE_DBLKS);
+        u_int32_t d = num_dequeues_rem(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE);
+        for (m=0; m<t; m++)
+            enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
+        // This enqueue should exceed the threshold
+        enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false, RHM_IORES_ENQCAPTHRESH);
+
+        // Dequeue as many msgs as possible except first
+        for (m=1; m<=d; m++)
+            deq_msg(jc, m, m+t);
+        deq_msg(jc, d+1, d+2, RHM_IORES_FULL);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(file_cycle_block)
+{
+    string test_name = get_test_name(test_filename, "file_cycle_block");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS);
+
+        // 5 cycles of enqueue/dequeue blocks of half threshold exception size
+        u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE,
+                LARGE_MSG_REC_SIZE_DBLKS)/2;
+        for (unsigned i=0; i<5; i++)
+        {
+            for (unsigned m=2*i*t; m<(2*i+1)*t; m++)
+                enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+            for (unsigned m=2*i*t; m<(2*i+1)*t; m++)
+                deq_msg(jc, m, m+t);
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(file_cycle_interleaved)
+{
+    string test_name = get_test_name(test_filename, "file_cycle_interleaved");
+    try
+    {
+        string msg;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS);
+
+        // 5 cycles of enqueue/dequeue blocks of half threshold exception size
+        u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE,
+                LARGE_MSG_REC_SIZE_DBLKS)/2;
+        for (unsigned m=0; m<5*2*t; m+=2)
+        {
+            enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+            deq_msg(jc, m, m+1);
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(recover_file_cycle_block)
+{
+    string test_name = get_test_name(test_filename, "recover_file_cycle_block");
+    try
+    {
+        string msg;
+        u_int64_t hrid;
+
+        // 5 cycles of enqueue/dequeue blocks of half threshold exception size
+        u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE,
+                LARGE_MSG_REC_SIZE_DBLKS)/2;
+        for (unsigned i=0; i<5; i++)
+        {
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            if (i)
+            {
+                jc.recover(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS, 0, hrid);
+                BOOST_CHECK_EQUAL(hrid, u_int64_t(2*i*t - 1));
+                jc.recover_complete();
+            }
+            else
+                jc.initialize(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS);
+
+            for (unsigned m=2*i*t; m<(2*i+1)*t; m++)
+                enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+            for (unsigned m=2*i*t; m<(2*i+1)*t; m++)
+                deq_msg(jc, m, m+t);
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(recover_file_cycle_interleaved)
+{
+    string test_name = get_test_name(test_filename, "recover_file_cycle_interleaved");
+    try
+    {
+        string msg;
+        u_int64_t hrid;
+
+        // 5 cycles of enqueue/dequeue blocks of half threshold exception size
+        u_int32_t t = num_msgs_to_threshold(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS * JRNL_SBLK_SIZE,
+                LARGE_MSG_REC_SIZE_DBLKS)/2;
+        for (unsigned i=0; i<5; i++)
+        {
+            test_jrnl_cb cb;
+            test_jrnl jc(test_name, test_dir, test_name, cb);
+            if (i)
+            {
+                jc.recover(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS, 0, hrid);
+                BOOST_CHECK_EQUAL(hrid, u_int64_t(2*i*t - 1));
+                jc.recover_complete();
+            }
+            else
+                jc.initialize(NUM_DEFAULT_JFILES, false, 0, DEFAULT_JFSIZE_SBLKS);
+
+            for (unsigned m=2*i*t; m<2*(i+1)*t; m+=2)
+            {
+                enq_msg(jc, m, create_msg(msg, m, LARGE_MSG_SIZE), false);
+                deq_msg(jc, m, m+1);
+            }
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+#endif
+
+QPID_AUTO_TEST_SUITE_END()

Added: qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic_txn.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic_txn.cpp?rev=1530301&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic_txn.cpp (added)
+++ qpid/trunk/qpid/cpp/src/tests/legacystore/jrnl/_st_basic_txn.cpp Tue Oct  8 15:09:00 2013
@@ -0,0 +1,239 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "../unit_test.h"
+#include <cmath>
+#include <iostream>
+#include "qpid/legacystore/jrnl/jcntl.h"
+
+using namespace boost::unit_test;
+using namespace mrg::journal;
+using namespace std;
+
+QPID_AUTO_TEST_SUITE(journal_basic_txn)
+
+const string test_filename("_st_basic_txn");
+
+#include "_st_helper_fns.h"
+
+// === Test suite ===
+
+QPID_AUTO_TEST_CASE(enqueue_commit_dequeue_block)
+{
+    string test_name = get_test_name(test_filename, "enqueue_commit_dequeue_block");
+    try
+    {
+        string msg;
+        string xid;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        create_xid(xid, 0, XID_SIZE);
+        for (int m=0; m<NUM_MSGS; m++)
+            BOOST_CHECK_EQUAL(enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false), u_int64_t(m));
+        txn_commit(jc, NUM_MSGS, xid);
+        for (int m=0; m<NUM_MSGS; m++)
+            deq_msg(jc, m, m+NUM_MSGS+1);
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_abort_dequeue_block)
+{
+    string test_name = get_test_name(test_filename, "enqueue_abort_dequeue_block");
+    try
+    {
+        string msg;
+        string xid;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        create_xid(xid, 0, XID_SIZE);
+        for (int m=0; m<NUM_MSGS; m++)
+            BOOST_CHECK_EQUAL(enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false), u_int64_t(m));
+        txn_abort(jc, NUM_MSGS, xid);
+        for (int m=0; m<NUM_MSGS; m++)
+        {
+            try
+            {
+                deq_msg(jc, m, m+NUM_MSGS+1);
+                BOOST_ERROR("Expected dequeue to fail with exception JERR_WMGR_DEQRIDNOTENQ.");
+            }
+            catch (const jexception& e) { if (e.err_code() != jerrno::JERR_WMGR_DEQRIDNOTENQ) throw; }
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_commit_dequeue_interleaved)
+{
+    string test_name = get_test_name(test_filename, "enqueue_commit_dequeue_interleaved");
+    try
+    {
+        string msg;
+        string xid;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        for (int m=0; m<NUM_MSGS; m++)
+        {
+            create_xid(xid, m, XID_SIZE);
+            BOOST_CHECK_EQUAL(enq_txn_msg(jc, 3*m, create_msg(msg, m, MSG_SIZE), xid, false), u_int64_t(3*m));
+            txn_commit(jc, 3*m+1, xid);
+            deq_msg(jc, 3*m, 3*m+2);
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_abort_dequeue_interleaved)
+{
+    string test_name = get_test_name(test_filename, "enqueue_abort_dequeue_interleaved");
+    try
+    {
+        string msg;
+        string xid;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        for (int m=0; m<NUM_MSGS; m++)
+        {
+            create_xid(xid, m, XID_SIZE);
+            BOOST_CHECK_EQUAL(enq_txn_msg(jc, 3*m, create_msg(msg, m, MSG_SIZE), xid, false), u_int64_t(3*m));
+            txn_abort(jc, 3*m+1, xid);
+            try
+            {
+                deq_msg(jc, 2*m, 2*m+2);
+                BOOST_ERROR("Expected dequeue to fail with exception JERR_WMGR_DEQRIDNOTENQ.");
+            }
+            catch (const jexception& e) { if (e.err_code() != jerrno::JERR_WMGR_DEQRIDNOTENQ) throw; }
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_dequeue_commit_block)
+{
+    string test_name = get_test_name(test_filename, "enqueue_dequeue_commit_block");
+    try
+    {
+        string msg;
+        string xid;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        create_xid(xid, 0, XID_SIZE);
+        for (int m=0; m<NUM_MSGS; m++)
+            BOOST_CHECK_EQUAL(enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false), u_int64_t(m));
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+        for (int m=0; m<NUM_MSGS; m++)
+            deq_txn_msg(jc, m, m+NUM_MSGS, xid);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+        txn_commit(jc, 2*NUM_MSGS, xid);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_dequeue_abort_block)
+{
+    string test_name = get_test_name(test_filename, "enqueue_dequeue_abort_block");
+    try
+    {
+        string msg;
+        string xid;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        create_xid(xid, 0, XID_SIZE);
+        for (int m=0; m<NUM_MSGS; m++)
+            BOOST_CHECK_EQUAL(enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false), u_int64_t(m));
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+        for (int m=0; m<NUM_MSGS; m++)
+            deq_txn_msg(jc, m, m+NUM_MSGS, xid);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+        txn_abort(jc, 2*NUM_MSGS, xid);
+        BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_dequeue_commit_interleaved)
+{
+    string test_name = get_test_name(test_filename, "enqueue_dequeue_commit_interleaved");
+    try
+    {
+        string msg;
+        string xid;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        for (int m=0; m<NUM_MSGS; m++)
+        {
+            create_xid(xid, m, XID_SIZE);
+            BOOST_CHECK_EQUAL(enq_txn_msg(jc, 3*m, create_msg(msg, m, MSG_SIZE), xid, false), u_int64_t(3*m));
+            deq_txn_msg(jc, 3*m, 3*m+1, xid);
+            txn_commit(jc, 3*m+2, xid);
+            BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_CASE(enqueue_dequeue_abort_interleaved)
+{
+    string test_name = get_test_name(test_filename, "enqueue_dequeue_abort_interleaved");
+    try
+    {
+        string msg;
+        string xid;
+
+        test_jrnl_cb cb;
+        test_jrnl jc(test_name, test_dir, test_name, cb);
+        jc.initialize(NUM_TEST_JFILES, false, 0, TEST_JFSIZE_SBLKS);
+        for (int m=0; m<NUM_MSGS; m++)
+        {
+            create_xid(xid, m, XID_SIZE);
+            BOOST_CHECK_EQUAL(enq_txn_msg(jc, 3*m, create_msg(msg, m, MSG_SIZE), xid, false), u_int64_t(3*m));
+            deq_txn_msg(jc, 3*m, 3*m+1, xid);
+            txn_abort(jc, 3*m+2, xid);
+            BOOST_CHECK_EQUAL(jc.get_enq_cnt(), u_int32_t(0));
+        }
+    }
+    catch(const exception& e) { BOOST_FAIL(e.what()); }
+    cout << "ok" << endl;
+}
+
+QPID_AUTO_TEST_SUITE_END()



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message