Author: kpvdr
Date: 2008-06-04 19:54:07 -0400 (Wed, 04 Jun 2008)
New Revision: 2131
Added:
store/trunk/cpp/tests/failing_python_tests.txt
store/trunk/cpp/tests/python_tests/
store/trunk/cpp/tests/python_tests/__init__.py
store/trunk/cpp/tests/python_tests/flow_to_disk.py
store/trunk/cpp/tests/run_python_tests
Modified:
store/trunk/cpp/lib/JournalImpl.cpp
store/trunk/cpp/lib/jrnl/jexception.hpp
store/trunk/cpp/tests/Makefile.am
store/trunk/cpp/tests/clean.sh
store/trunk/cpp/tests/run_test
store/trunk/cpp/tests/start_broker
store/trunk/cpp/tests/stop_broker
Log:
Added python tests and scripts to the store
Modified: store/trunk/cpp/lib/JournalImpl.cpp
===================================================================
--- store/trunk/cpp/lib/JournalImpl.cpp 2008-06-04 23:18:47 UTC (rev 2130)
+++ store/trunk/cpp/lib/JournalImpl.cpp 2008-06-04 23:54:07 UTC (rev 2131)
@@ -370,7 +370,7 @@
void
JournalImpl::txn_abort(data_tok* const dtokp, const std::string& xid)
{
- handleIoResult(jcntl::txn_abort(dtokp, xid));
+ handleIoResult(jcntl::txn_abort(dtokp, xid));
}
void
Modified: store/trunk/cpp/lib/jrnl/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp 2008-06-04 23:18:47 UTC (rev 2130)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp 2008-06-04 23:54:07 UTC (rev 2131)
@@ -41,6 +41,7 @@
}
}
+#include <cstring>
#include <exception>
#include <string>
#include <sys/types.h>
Modified: store/trunk/cpp/tests/Makefile.am
===================================================================
--- store/trunk/cpp/tests/Makefile.am 2008-06-04 23:18:47 UTC (rev 2130)
+++ store/trunk/cpp/tests/Makefile.am 2008-06-04 23:54:07 UTC (rev 2131)
@@ -14,6 +14,7 @@
OrderingTest \
TransactionalTest \
TwoPhaseCommitTest \
+ run_python_tests \
system_test.sh \
clean.sh
@@ -41,12 +42,15 @@
EXTRA_DIST = \
clean.sh \
+ failing_python_tests.txt \
+ persistence.py \
+ python_tests \
+ run_python_tests \
+ run_test \
start_broker \
stop_broker \
system_test.sh \
- persistence.py \
MessageUtils.h \
- run_test \
vg_check \
.valgrindrc \
.valgrind.supp
@@ -58,4 +62,3 @@
LIBBDBSTORE=$(abs_builddir)/../lib/.libs/libbdbstore.so \
TMPDIR=$(TMPDIR) \
$(srcdir)/run_test
-
Modified: store/trunk/cpp/tests/clean.sh
===================================================================
--- store/trunk/cpp/tests/clean.sh 2008-06-04 23:18:47 UTC (rev 2130)
+++ store/trunk/cpp/tests/clean.sh 2008-06-04 23:54:07 UTC (rev 2131)
@@ -28,3 +28,4 @@
if [ -d ${TMPDIR} ]; then
rm -rf ${TMPDIR}
fi
+rm -f ${abs_srcdir}/*.vglog*
Added: store/trunk/cpp/tests/failing_python_tests.txt
===================================================================
--- store/trunk/cpp/tests/failing_python_tests.txt (rev 0)
+++ store/trunk/cpp/tests/failing_python_tests.txt 2008-06-04 23:54:07 UTC (rev 2131)
@@ -0,0 +1,4 @@
+python_tests.flow_to_disk.AsyncFlowToDiskTests.test_simple_max_count_transient
+python_tests.flow_to_disk.AsyncFlowToDiskTests.test_simple_max_count_persistent
+python_tests.flow_to_disk.AsyncFlowToDiskTests.test_simple_max_size_transient
+python_tests.flow_to_disk.AsyncFlowToDiskTests.test_simple_max_size_persistent
Added: store/trunk/cpp/tests/python_tests/__init__.py
===================================================================
--- store/trunk/cpp/tests/python_tests/__init__.py (rev 0)
+++ store/trunk/cpp/tests/python_tests/__init__.py 2008-06-04 23:54:07 UTC (rev 2131)
@@ -0,0 +1,22 @@
+# Do not delete - marks this directory as a python package.
+
+#
+# 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.
+#
+
+from flow_to_disk import *
Added: store/trunk/cpp/tests/python_tests/flow_to_disk.py
===================================================================
--- store/trunk/cpp/tests/python_tests/flow_to_disk.py (rev 0)
+++ store/trunk/cpp/tests/python_tests/flow_to_disk.py 2008-06-04 23:54:07 UTC (rev 2131)
@@ -0,0 +1,73 @@
+#
+# 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.
+#
+from qpid.client import Client, Closed
+from qpid.queue import Empty
+from qpid.testlib import TestBase010
+from qpid.datatypes import Message
+from qpid.session import SessionException
+
+class AsyncFlowToDiskTests(TestBase010):
+ """Tests for async store flow-to-disk"""
+
+ def test_simple_max_count_transient(self):
+ queue_args = {'qpid.max_count': 10}
+ self.simple_limit("test_simple_max_count_transient", queue_args,
self.session.delivery_mode.non_persistent)
+
+ def test_simple_max_count_persistent(self):
+ queue_args = {'qpid.max_count': 10}
+ self.simple_limit("test_simple_max_count_persistent", queue_args,
self.session.delivery_mode.persistent)
+
+ def test_simple_max_size_transient(self):
+ queue_args = {'qpid.max_size': 100}
+ self.simple_limit("test_simple_max_size_transient", queue_args,
self.session.delivery_mode.non_persistent)
+
+ def test_simple_max_size_persistent(self):
+ queue_args = {'qpid.max_size': 100}
+ self.simple_limit("test_simple_max_size_persistent", queue_args,
self.session.delivery_mode.persistent)
+
+ def simple_limit(self, queue_name, queue_args, delivery_mode):
+ """
+ Test a simple case of max message count.
+ * queue_args sets a limit - either max_count 10 or max_size 100
+ * 15 messages are added. The last five will flow to disk.
+ * Consume 15 messages.
+ """
+
+ session = self.session
+ session.queue_declare(queue=queue_name, durable=True, arguments=queue_args)
+
+ # Add 15 messages
+ for msg_num in range(0, 15):
+ msg_str = "Message %02d" % msg_num
+
session.message_transfer(message=Message(session.delivery_properties(routing_key=queue_name,
delivery_mode=delivery_mode), msg_str))
+
+ # Consume 15 messages
+ session.message_subscribe(queue=queue_name, destination="tag")
+ session.message_flow(destination="tag",
unit=session.credit_unit.message, value=0xFFFFFFFF)
+ session.message_flow(destination="tag", unit=session.credit_unit.byte,
value=0xFFFFFFFF)
+ queue = session.incoming("tag")
+ for msg_num in range(0, 15):
+ expected_str = "Message %02d" % msg_num
+ msg = queue.get(timeout=5)
+ self.assertEqual(expected_str, msg.body)
+
+ # Check queue is empty
+ session.queue_declare(queue=queue_name)
+ reply = session.queue_query(queue=queue_name)
+ self.assertEqual(0, reply.message_count)
Added: store/trunk/cpp/tests/run_python_tests
===================================================================
--- store/trunk/cpp/tests/run_python_tests (rev 0)
+++ store/trunk/cpp/tests/run_python_tests 2008-06-04 23:54:07 UTC (rev 2131)
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# Copyright (C) 2007 Red Hat Software
+#
+# This file is part of Red Hat Messaging.
+#
+# Red Hat Messaging is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+# USA
+#
+# The GNU Lesser General Public License is available in the file COPYING.
+
+QPID_PYTHON_DIR=$QPID_DIR/python
+export PYTHONPATH=${QPID_PYTHON_DIR}:${abs_srcdir}
+BROKER_OPTS="--load-module=${LIBBDBSTORE} --data-dir=${TMPDIR} --auth=no"
+PYTHON_TESTS=python_tests
+AMQP_SPEC=0-10-errata
+FAILING_PYTHON_TESTS=${abs_srcdir}/failing_python_tests.txt
+
+# Make sure ${QPID_DIR} contains what we need.
+if ! test -d "${QPID_DIR}" ; then
+ echo "WARNING: QPID_DIR is not set - skipping python tests."
+ exit
+fi
+
+#Make sure temp dir exists if this is the first to use it
+if ! test -d ${TMPDIR} ; then
+ mkdir -p ${TMPDIR}
+fi
+
+#Split PYTHONPATH at ':' and check each path exists
+old_ifs=${IFS}
+IFS=':'
+missing=0
+for path in ${PYTHONPATH} ; do
+ if ! test -d ${path} ; then
+ echo "WARNING: ${path} not found."
+ missing=1
+ fi
+done
+IFS=${old_ifs}
+
+fail=0
+if test ${missing} != 0 ; then
+ echo "WARNING: Path(s) in ${PYTHONPATH} not found - skipping python
tests."
+ exit 1
+else
+ # 1. Start broker
+ echo -n "Starting broker... "
+ ${abs_srcdir}/start_broker "$@" ${BROKER_OPTS} || { echo "FAIL broker
start"; exit 1; }
+ if ! test -f qpidd.port; then
+ echo "FAIL no qpidd.port file found - broker may have failed to start"
+ exit 1
+ fi
+ port=`cat qpidd.port`
+ echo "port=${port} ok"
+
+ # 2. Run all python tests
+ pwdir=$(pwd)
+ cd ${QPID_PYTHON_DIR}
+ ./run-tests --skip-self-test -v -s ${AMQP_SPEC} -I ${FAILING_PYTHON_TESTS} -b
localhost:${port} ${PYTHON_TESTS} || { echo "FAIL python tests for ${SPEC}";
fail=1; }
+ cd ${pwdir}
+
+ #3. Stop broker
+ echo -n "Stopping broker on port ${port}... "
+ ${abs_srcdir}/stop_broker || { echo "FAIL broker stop"; fail=1; }
+ echo "ok"
+ exit ${fail}
+fi
Property changes on: store/trunk/cpp/tests/run_python_tests
___________________________________________________________________
Name: svn:executable
+ *
Modified: store/trunk/cpp/tests/run_test
===================================================================
--- store/trunk/cpp/tests/run_test 2008-06-04 23:18:47 UTC (rev 2130)
+++ store/trunk/cpp/tests/run_test 2008-06-04 23:54:07 UTC (rev 2131)
@@ -27,14 +27,14 @@
test -z "$LC_MESSAGES" && export LC_MESSAGES=
VG_LOG="$1.vglog"
-rm -f $VG_LOG
+rm -f $VG_LOG*
if grep -l "^# Generated by .*libtool" "$1" >/dev/null
2>&1; then
# This is a libtool "executable". Valgrind it if VALGRIND specified.
- test -n "$VALGRIND" && VALGRIND="$VALGRIND
--log-file-exactly=$VG_LOG --"
+ test -n "$VALGRIND" && VALGRIND="$VALGRIND --log-file=$VG_LOG
--"
# Hide output unless there's an error.
libtool --mode=execute $VALGRIND "$@" 2>&1 || ERROR=$?
- test -n "$VALGRIND" && vg_check
+ test -n "$VALGRIND" && vg_check $VG_LOG*
else
# This is a non-libtool shell script, just execute it.
export VALGRIND srcdir
@@ -43,7 +43,7 @@
if test -z "$ERROR"; then
# Clean up logs if there was no error.
- rm -f $VG_LOG
+ rm -f $VG_LOG*
exit 0
else
exit $ERROR
Modified: store/trunk/cpp/tests/start_broker
===================================================================
--- store/trunk/cpp/tests/start_broker 2008-06-04 23:18:47 UTC (rev 2130)
+++ store/trunk/cpp/tests/start_broker 2008-06-04 23:54:07 UTC (rev 2131)
@@ -1,5 +1,5 @@
#!/bin/sh
QPIDD=$QPID_DIR/cpp/src/qpidd
-rm -f qpidd.vglog qpidd.log
-test -n "$VALGRIND" && VALGRIND="$VALGRIND
--log-file-exactly=qpidd.vglog --"
+rm -f qpidd.vglog* qpidd.log
+test -n "$VALGRIND" && VALGRIND="$VALGRIND --log-file=qpidd.vglog
--"
exec libtool --mode=execute $VALGRIND $QPIDD --daemon --port=0 --log-output qpidd.log
"$@" > qpidd.port
Modified: store/trunk/cpp/tests/stop_broker
===================================================================
--- store/trunk/cpp/tests/stop_broker 2008-06-04 23:18:47 UTC (rev 2130)
+++ store/trunk/cpp/tests/stop_broker 2008-06-04 23:54:07 UTC (rev 2131)
@@ -1,21 +1,26 @@
#!/bin/sh
# Stop the broker, check for errors.
#
-export QPID_PORT=`cat qpidd.port`
-QPIDD=$QPID_DIR/cpp/src/qpidd
-rm -f qpidd.port
+if test -f qpidd.port; then
+ export QPID_PORT=`cat qpidd.port`
+ QPIDD=$QPID_DIR/cpp/src/qpidd
+ rm -f qpidd.port
-$QPIDD --quit || ERROR=$?
+ $QPIDD --quit || ERROR=$?
-# Check qpidd.log.
-grep -a 'warning\|error\|critical' qpidd.log && {
- echo "WARNING: Suspicious broker log entries in qpidd.log, above."
-}
+ # Check qpidd.log.
+ grep -a 'warning\|error\|critical' qpidd.log && {
+ echo "WARNING: Suspicious broker log entries in qpidd.log, above."
+ }
-# Check valgrind log.
-if test -n "$VALGRIND"; then
- source `dirname $0`/vg_check
- vg_check qpidd.vglog
+ # Check valgrind log.
+ if test -n "$VALGRIND"; then
+ source `dirname $0`/vg_check $VG_LOG*
+ vg_check qpidd.vglog*
+ fi
+
+ exit $ERROR
+else
+ echo "No qpidd.port file found - cannot stop broker."
+ exit 1;
fi
-
-exit $ERROR