[rhmessaging-commits] rhmessaging commits: r3809 - in store/trunk/cpp/tests: cluster and 1 other directories.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Tue Jan 19 16:25:36 EST 2010
Author: kpvdr
Date: 2010-01-19 16:25:35 -0500 (Tue, 19 Jan 2010)
New Revision: 3809
Modified:
store/trunk/cpp/tests/cluster/cluster_tests_env.sh
store/trunk/cpp/tests/cluster/run_cluster_test
store/trunk/cpp/tests/cluster/run_cluster_tests
store/trunk/cpp/tests/new_python_tests/client_persistence.py
store/trunk/cpp/tests/run_new_python_tests
Log:
Perform checks for both corosync and openais when testing; some additional python tests using the new Python API.
Modified: store/trunk/cpp/tests/cluster/cluster_tests_env.sh
===================================================================
--- store/trunk/cpp/tests/cluster/cluster_tests_env.sh 2010-01-19 12:51:22 UTC (rev 3808)
+++ store/trunk/cpp/tests/cluster/cluster_tests_env.sh 2010-01-19 21:25:35 UTC (rev 3809)
@@ -49,25 +49,38 @@
}
-func_check_ais ()
+func_check_clustering ()
#----------------
-# Check openAIS/corosync is running and user has correct privilages
+# 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
{
- 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"
+ # 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
- 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:
+ Cluster tests will not be run because:
- $NOGROUP
- $NOAISEXEC
+ $NODAEMON
+ $NOAUTH
==========================================================
@@ -280,7 +293,7 @@
#--- Start of script ---
func_check_required_env || exit 1 # Cannot run, exit with error
-func_check_ais || exit 0 # A warning, not a failure.
+func_check_clustering || exit 0 # A warning, not a failure.
srcdir=`dirname $0`
if test -z ${abs_srcdir}; then
Modified: store/trunk/cpp/tests/cluster/run_cluster_test
===================================================================
--- store/trunk/cpp/tests/cluster/run_cluster_test 2010-01-19 12:51:22 UTC (rev 3808)
+++ store/trunk/cpp/tests/cluster/run_cluster_test 2010-01-19 21:25:35 UTC (rev 3809)
@@ -22,4 +22,13 @@
# The GNU Lesser General Public License is available in the file COPYING.
. `dirname $0`/cluster_tests_env.sh
-sg ais -c "${CPP_CLUSTER_EXEC}"
+
+if test $COROSYNC; then
+ ${CPP_CLUSTER_EXEC}
+ RETCODE=$?
+else
+ sg ais -c "${CPP_CLUSTER_EXEC}"
+ RETCODE=$?
+fi
+
+exit $RETCODE
\ No newline at end of file
Modified: store/trunk/cpp/tests/cluster/run_cluster_tests
===================================================================
--- store/trunk/cpp/tests/cluster/run_cluster_tests 2010-01-19 12:51:22 UTC (rev 3808)
+++ store/trunk/cpp/tests/cluster/run_cluster_tests 2010-01-19 21:25:35 UTC (rev 3809)
@@ -32,8 +32,16 @@
CLUSTER_TESTS_IGNORE=${CLUSTER_TESTS_IGNORE:-"-I ${CLUSTER_TESTS_FAIL}"}
CLUSTER_TESTS=${CLUSTER_TESTS:-$*}
-sg ais -c "${PYTHON_DIR}/qpid-python-test -m cluster_tests ${CLUSTER_TESTS_IGNORE} ${CLUSTER_TESTS} -DOUTDIR=$OUTDIR"
-RETCODE=$?
+TEST_CMD="${PYTHON_DIR}/qpid-python-test -m cluster_tests ${CLUSTER_TESTS_IGNORE} ${CLUSTER_TESTS} -DOUTDIR=$OUTDIR"
+if test $COROSYNC; then
+ $TEST_CMD
+ RETCODE=$?
+else
+ sg ais -c "$TEST_CMD"
+ RETCODE=$?
+fi
+#sg ais -c "${PYTHON_DIR}/qpid-python-test -m cluster_tests ${CLUSTER_TESTS_IGNORE} ${CLUSTER_TESTS} -DOUTDIR=$OUTDIR"
+#RETCODE=$?
if test x${RETCODE} != x0; then
exit 1;
Modified: store/trunk/cpp/tests/new_python_tests/client_persistence.py
===================================================================
--- store/trunk/cpp/tests/new_python_tests/client_persistence.py 2010-01-19 12:51:22 UTC (rev 3808)
+++ store/trunk/cpp/tests/new_python_tests/client_persistence.py 2010-01-19 21:25:35 UTC (rev 3809)
@@ -20,8 +20,12 @@
# The GNU Lesser General Public License is available in the file COPYING.
from qpid.brokertest import *
-from qpid.messaging import Message
+from qpid.messaging import Empty, Message
from qmf.console import Session
+
+def storeArgs():
+ assert BrokerTest.store_lib
+ return ["--load-module", BrokerTest.store_lib]
class Qmf:
"""
@@ -69,26 +73,129 @@
def queryQueue(self, queueName, altExchangeName=None):
"""Test for the presence of an exchange, and optionally whether it has an alternate exchange set to a known value."""
return self.__query(queueName, "queue", "org.apache.qpid.broker", altExchangeName)
+
+ def queueMsgCount(self, queueName):
+ queueList = self.__session.getObjects(_class="queue", _name=queueName)
+ if len(queueList):
+ return queueList[0].msgDepth
+
+ def queueEmpty(self, queueName):
+ return self.queueMsgCount(queueName) == 0
-class AlternateExchagePropertyTests(BrokerTest):
+class StoreTest(BrokerTest):
"""
- Test the persistence of the Alternate Exchange property for exchanges and queues.
+ This subclass of BrokerTest adds some convenience test/check functions
"""
- def __args(self):
- assert BrokerTest.store_lib
- return ["--load-module", BrokerTest.store_lib]
+ def __chkEmpty(self, queue, receiver):
+ try:
+ msg = receiver.fetch(timeout=0)
+ self.assert_(False, "Queue \"%s\" not empty: found message: %s" % (queue, msg))
+ except Empty: pass
+
+ def chkMsg(self, broker, queue, msgChk, empty=False, ack=True):
+ return self.chkMsgs(broker, queue, [msgChk], empty, ack)
+
+ def chkMsgs(self, broker, queue, msgChkList, empty=False, ack=True):
+ s = broker.connect().session()
+ rcvr = s.receiver(queue + "; {create:always}", capacity=len(msgChkList))
+ try: rmList = [rcvr.fetch(timeout=0) for i in range(len(msgChkList))]
+ except Empty: self.assert_(False, "Queue \"%s\" is empty, unable to retrieve expected message %d." % (queue, i))
+ for i in range(0, len(rmList)):
+ self.assertEqual(rmList[i].content, msgChkList[i].content)
+ self.assertEqual(rmList[i].correlation_id, msgChkList[i].correlation_id)
+ if empty: self.__chkEmpty(queue, rcvr)
+ if ack:
+ s.acknowledge()
+ s.connection.close()
+ else:
+ return s
+
+class ExchangeQueueTests(StoreTest):
+ """
+ Simple tests of the broker exchange and queue types
+ """
+
+ def testDirectExchange(self):
+ """Test Direct exchange."""
+ broker = self.broker(storeArgs(), name="testDirectExchange", expect=EXPECT_EXIT_OK)
+ m1 = Message("A_Message1", durable=True, correlation_id="Msg0001")
+ m2 = Message("B_Message1", durable=True, correlation_id="Msg0002")
+ broker.send_message("a", m1)
+ broker.send_message("b", m2)
+ broker.terminate()
+
+ broker = self.broker(storeArgs(), name="testDirectExchange")
+ self.chkMsg(broker, "a", m1, True)
+ self.chkMsg(broker, "b", m2, True)
+
+ def testTopicExchange(self):
+ """Test Topic exchange."""
+ broker = self.broker(storeArgs(), name="testTopicExchange", expect=EXPECT_EXIT_OK)
+ s = broker.connect().session()
+ snd1 = s.sender("abc/key1; {create:always, node-properties:{durable:True, type:topic}}")
+ snd2 = s.sender("abc/key2; {create:always, node-properties:{durable:True, type:topic}}")
+ s.receiver("a; {create:always, node-properties:{durable:True, x-properties:{bindings:['abc/key1']}}}")
+ s.receiver("b; {create:always, node-properties:{durable:True, x-properties:{bindings:['abc/key1']}}}")
+ s.receiver("c; {create:always, node-properties:{durable:True, x-properties:{bindings:['abc/key1']}}}")
+ m1 = Message("Message1", durable=True, correlation_id="Msg0003")
+ snd1.send(m1)
+ m2 = Message("Message2", durable=True, correlation_id="Msg0004")
+ snd2.send(m2)
+ s.connection.close()
+ broker.terminate()
+
+ broker = self.broker(storeArgs(), name="testTopicExchange")
+ self.chkMsg(broker, "a", m1, True)
+ self.chkMsg(broker, "b", m1, True)
+ self.chkMsg(broker, "c", m1, True)
+
+
+ def testLVQ(self):
+ """Test LVQ."""
+ broker = self.broker(storeArgs(), name="testLVQ", expect=EXPECT_EXIT_OK)
+ ma1 = Message("A1", durable=True, correlation_id="Msg0005", properties={"qpid.LVQ_key":"A"})
+ ma2 = Message("A2", durable=True, correlation_id="Msg0006", properties={"qpid.LVQ_key":"A"})
+ mb1 = Message("B1", durable=True, correlation_id="Msg0007", properties={"qpid.LVQ_key":"B"})
+ mb2 = Message("B2", durable=True, correlation_id="Msg0008", properties={"qpid.LVQ_key":"B"})
+ mb3 = Message("B3", durable=True, correlation_id="Msg0009", properties={"qpid.LVQ_key":"B"})
+ mc1 = Message("C1", durable=True, correlation_id="Msg0010", properties={"qpid.LVQ_key":"C"})
+ broker.send_messages("lvq-test", [mb1, ma1, ma2, mb2, mb3, mc1], xprops="\"qpid.last_value_queue\":True")
+ broker.terminate()
+
+ broker = self.broker(storeArgs(), name="testLVQ", expect=EXPECT_EXIT_OK)
+ s = self.chkMsgs(broker, "lvq-test", [ma2, mb3, mc1], empty=True, ack=False)
+ # Add more messages while subscriber is active (no replacement):
+ ma3 = Message("A3", durable=True, correlation_id="Msg0011", properties={"qpid.LVQ_key":"A"})
+ ma4 = Message("A4", durable=True, correlation_id="Msg0012", properties={"qpid.LVQ_key":"A"})
+ mc2 = Message("C2", durable=True, correlation_id="Msg0013", properties={"qpid.LVQ_key":"C"})
+ mc3 = Message("C3", durable=True, correlation_id="Msg0014", properties={"qpid.LVQ_key":"C"})
+ mc4 = Message("C4", durable=True, correlation_id="Msg0015", properties={"qpid.LVQ_key":"C"})
+ broker.send_messages("lvq-test", [mc2, mc3, ma3, ma4, mc4], xprops="\"qpid.last_value_queue\":True", session=s)
+ s.acknowledge()
+ s.connection.close()
+ broker.terminate()
+
+ broker = self.broker(storeArgs(), name="testLVQ")
+ self.chkMsgs(broker, "lvq-test", [mc4, ma4], True)
+
+
+class AlternateExchagePropertyTests(StoreTest):
+ """
+ Test the persistence of the Alternate Exchange property for exchanges and queues.
+ """
+
def testExchange(self):
"""Exchange alternate exchange property persistence test"""
- broker = self.broker(self.__args(), name="testBroker", expect=EXPECT_EXIT_FAIL)
+ broker = self.broker(storeArgs(), name="testBroker", expect=EXPECT_EXIT_OK)
qmf = Qmf(broker)
qmf.addExchange("altExch", "direct", durable=True) # Serves as alternate exchange instance
qmf.addExchange("testExch", "direct", durable=True, altExchangeName="altExch")
- broker.kill()
+ broker.terminate()
- broker = self.broker(self.__args(), name="testBroker")
+ broker = self.broker(storeArgs(), name="testBroker")
qmf = Qmf(broker)
try: qmf.addExchange("altExch", "direct", passive=True)
except Exception, e: self.fail("Alternate exchange (\"altExch\") instance not recovered: %s" % e)
@@ -98,13 +205,13 @@
def testQueue(self):
"""Queue alternate exchange property persistexchangeNamece test"""
- broker = self.broker(self.__args(), name="testBroker", expect=EXPECT_EXIT_FAIL)
+ broker = self.broker(storeArgs(), name="testBroker", expect=EXPECT_EXIT_OK)
qmf = Qmf(broker)
qmf.addExchange("altExch", "direct", durable=True) # Serves as alternate exchange instance
qmf.addQueue("testQueue", durable=True, altExchangeName="altExch")
- broker.kill()
+ broker.terminate()
- broker = self.broker(self.__args(), name="testBroker")
+ broker = self.broker(storeArgs(), name="testBroker")
qmf = Qmf(broker)
try: qmf.addExchange("altExch", "direct", passive=True)
except Exception, e: self.fail("Alternate exchange (\"altExch\") instance not recovered: %s" % e)
@@ -113,24 +220,22 @@
self.assertTrue(qmf.queryQueue("testQueue", altExchangeName = "altExch"), "Alternate exchange property not found or is incorrect on queue \"testQueue\".")
-class RedeliveredTests(BrokerTest):
+class RedeliveredTests(StoreTest):
"""
Test the behavior of the redelivered flag in the context of persistence
"""
-
- def __args(self):
- assert BrokerTest.store_lib
- return ["--load-module", BrokerTest.store_lib]
def testBrokerRecovery(self):
"""Test that the redelivered flag is set on messages after recovery of broker"""
- broker = self.broker(self.__args(), name="testAfterRecover", expect=EXPECT_EXIT_FAIL)
+ broker = self.broker(storeArgs(), name="testAfterRecover", expect=EXPECT_EXIT_OK)
mc = "xyz"*100
m = Message(mc, durable=True)
broker.send_message("testQueue", m)
- broker.kill()
- broker = self.broker(self.__args(), name="testAfterRecover")
+ broker.terminate()
+
+ broker = self.broker(storeArgs(), name="testAfterRecover")
rm = broker.get_message("testQueue")
self.assertEqual(mc, rm.content)
self.assertTrue(rm.redelivered)
-
\ No newline at end of file
+
+
\ No newline at end of file
Modified: store/trunk/cpp/tests/run_new_python_tests
===================================================================
--- store/trunk/cpp/tests/run_new_python_tests 2010-01-19 12:51:22 UTC (rev 3808)
+++ store/trunk/cpp/tests/run_new_python_tests 2010-01-19 21:25:35 UTC (rev 3809)
@@ -43,6 +43,8 @@
OUTDIR=new_python_tests.tmp
rm -rf $OUTDIR
+# To debug a test, add the following options to the end of the following line:
+# -v DEBUG -c qpid.messaging.io.ops [*.testName]
${PYTHON_DIR}/qpid-python-test -m new_python_tests -I ${FAILING_PYTHON_TESTS} ${PYTHON_TESTS} -DOUTDIR=$OUTDIR
RETCODE=$?
More information about the rhmessaging-commits
mailing list