qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r834193 - in /qpid/trunk/qpid/cpp/src/tests: brokertest.py cluster.mk cluster_tests.fail cluster_tests.py run_cluster_tests
Date Mon, 09 Nov 2009 19:50:15 GMT
Author: aconway
Date: Mon Nov  9 19:50:15 2009
New Revision: 834193

URL: http://svn.apache.org/viewvc?rev=834193&view=rev
Log:
Added message store recovery tests to cluster_tests.

Added:
    qpid/trunk/qpid/cpp/src/tests/cluster_tests.fail
Modified:
    qpid/trunk/qpid/cpp/src/tests/brokertest.py
    qpid/trunk/qpid/cpp/src/tests/cluster.mk
    qpid/trunk/qpid/cpp/src/tests/cluster_tests.py
    qpid/trunk/qpid/cpp/src/tests/run_cluster_tests

Modified: qpid/trunk/qpid/cpp/src/tests/brokertest.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/brokertest.py?rev=834193&r1=834192&r2=834193&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/brokertest.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/brokertest.py Mon Nov  9 19:50:15 2009
@@ -23,6 +23,7 @@
 import os, signal, string, tempfile, popen2, socket, threading, time
 import qpid
 from qpid import connection, messaging, util
+from qpid.compat import format_exc
 from qpid.harness import Skipped
 from unittest import TestCase
 from copy import copy
@@ -141,7 +142,7 @@
         Popen.__init__(self, cmd, expect)
         try: self.port = int(self.stdout.readline())
         except Exception:
-            raise Exception("Failed to start broker: "+self.cmd_str())
+            raise Exception("Failed to start broker, log: "+self.log)
         test.cleanup_popen(self)
         self.host = "localhost"         # Placeholder for remote brokers.
 
@@ -162,6 +163,18 @@
         s.queue_declare(queue=queue)
         c.close()
 
+    def send_message(self, queue, message):
+        s = self.connect().session()
+        s.sender(queue+" {create:always}").send(message)
+        s.connection.close()
+
+    def get_message(self, queue):
+        s = self.connect().session()
+        m = s.receiver(queue+" {create:always}", capacity=1).fetch(timeout=1)
+        s.acknowledge()
+        s.connection.close()
+        return m
+
 class Cluster:
     """A cluster of brokers in a test."""
 
@@ -213,9 +226,12 @@
     qpidRoute_exec = os.getenv("QPID_ROUTE_EXEC")
     receiver_exec = os.getenv("RECEIVER_EXEC")
     sender_exec = os.getenv("SENDER_EXEC")
+    store_lib = os.getenv("STORE_LIB")
 
+    def configure(self, config): self.config=config
+    
     def setUp(self):
-        self.dir = os.path.join("brokertest.tmp", self.id())
+        self.dir = os.path.join(self.config.defines["OUTDIR"], self.id())
         os.makedirs(self.dir)
         self.popens = []
 
@@ -282,7 +298,7 @@
                 self.sender.stdin.write(str(self.sent)+"\n")
                 self.sender.stdin.flush()
                 self.sent += 1
-        except Exception, e: self.error = e
+        except Exception, e: self.error = RethrownException(e)
 
 class Receiver(Thread):
     """
@@ -309,7 +325,7 @@
                 finally:
                     self.lock.release()
         except Exception, e:
-            self.error = e
+            self.error = RethrownException(e)
 
     def stop(self, count):
         """Returns when received >= count"""
@@ -319,3 +335,7 @@
         self.join()
         if self.error: raise self.error
 
+class RethrownException(Exception):
+    """Captures the original stack trace to be thrown later""" 
+    def __init__(self, e):
+        Exception.__init__(self, format_exc())

Modified: qpid/trunk/qpid/cpp/src/tests/cluster.mk
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/cluster.mk?rev=834193&r1=834192&r2=834193&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/cluster.mk (original)
+++ qpid/trunk/qpid/cpp/src/tests/cluster.mk Mon Nov  9 19:50:15 2009
@@ -79,6 +79,6 @@
 
 cluster_test_LDADD=$(lib_client) $(lib_broker) -lboost_unit_test_framework
 
-qpidtest_SCRIPTS += run_cluster_tests cluster_tests.py run_long_cluster_tests long_cluster_tests.py
testlib.py brokertest.py
+qpidtest_SCRIPTS += run_cluster_tests cluster_tests.py run_long_cluster_tests long_cluster_tests.py
testlib.py brokertest.py cluster_tests.fail
 
 endif

Added: qpid/trunk/qpid/cpp/src/tests/cluster_tests.fail
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/cluster_tests.fail?rev=834193&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/cluster_tests.fail (added)
+++ qpid/trunk/qpid/cpp/src/tests/cluster_tests.fail Mon Nov  9 19:50:15 2009
@@ -0,0 +1,2 @@
+cluster_tests.ClusterTests.test_failover
+

Modified: qpid/trunk/qpid/cpp/src/tests/cluster_tests.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/cluster_tests.py?rev=834193&r1=834192&r2=834193&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/cluster_tests.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/cluster_tests.py Mon Nov  9 19:50:15 2009
@@ -23,6 +23,7 @@
 from brokertest import *
 from qpid import datatypes, messaging
 from qpid.harness import Skipped
+from qpid.messaging import Message
 
 
 class ClusterTests(BrokerTest):
@@ -47,7 +48,7 @@
         # Start member 2 and verify messages available.
         s2 = cluster.start().connect().session()
         m = s2.receiver("q", capacity=1).fetch(timeout=1)
-        s1.acknowledge()
+        s2.acknowledge()
         self.assertEqual("y", m.content)
         s2.connection.close()
 
@@ -55,7 +56,6 @@
         """Test fail-over during continuous send-receive"""
         # FIXME aconway 2009-11-09: this test is failing, showing lost messages.
         # Enable when fixed
-        return                          # FIXME should be raise Skipped or negative test?
 
         # Original cluster will all be killed so expect exit with failure
         cluster = self.cluster(3, expect=EXPECT_EXIT_FAIL)
@@ -75,3 +75,46 @@
 
         self.sender.stop()
         self.receiver.stop(self.sender.sent)
+
+
+class ClusterStoreTests(BrokerTest):
+    """
+    Cluster tests that can only be run if there is a store available.
+    """
+    args = ["--load-module",BrokerTest.store_lib]
+
+    def test_store_loaded(self):
+        """Ensure we are indeed loading a working store"""
+        broker = self.broker(self.args, name="recoverme", expect=EXPECT_EXIT_FAIL)
+        m = messaging.Message("x", durable=True)
+        broker.send_message("q", m)
+        broker.kill()
+        broker = self.broker(self.args, name="recoverme")
+        self.assertEqual("x", broker.get_message("q").content)
+
+    def test_kill_restart(self):
+        """Verify we can kill/resetart a broker with store in a cluster"""
+        cluster = self.cluster(1, self.args)
+        cluster.start("restartme", expect=EXPECT_EXIT_FAIL).kill()
+
+        # Send a message, retrieve from the restarted broker
+        cluster[0].send_message("q", "x")
+        m = cluster.start("restartme").get_message("q")
+        self.assertEqual("x", m.content)
+
+    def test_total_shutdown(self):
+        """Test we use the correct store to recover after total shutdown"""
+        cluster = self.cluster(2, args=self.args, expect=EXPECT_EXIT_FAIL)
+        cluster[0].send_message("q", Message("a", durable=True))
+        cluster[0].kill()
+        self.assertEqual("a", cluster[1].get_message("q").content)
+        cluster[1].send_message("q", Message("b", durable=True))
+        cluster[1].kill()
+
+        # Start 1 first, we should see its store used.
+        cluster.start(name=cluster.name+"-1")
+        cluster.start(name=cluster.name+"-0")
+        self.assertEqual("b", cluster[2].get_message("q").content)
+
+        
+    

Modified: qpid/trunk/qpid/cpp/src/tests/run_cluster_tests
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/run_cluster_tests?rev=834193&r1=834192&r2=834193&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/run_cluster_tests (original)
+++ qpid/trunk/qpid/cpp/src/tests/run_cluster_tests Mon Nov  9 19:50:15 2009
@@ -20,24 +20,11 @@
 #
 
 absdir() { echo `cd $1; pwd`; }
-
 srcdir=$(absdir $(dirname $0))
 top_builddir=$(absdir ../..)
 
 . $srcdir/python_env.sh
-
-# Check AIS requirements
-. $srcdir/ais_check
-
-# Check XML exchange requirements
-XML_LIB=$srcdir/../.libs/xml.so
-if [ -f ${XML_LIB} ]; then
-	export XML_LIB
-fi
-
-
-# Set up environment for python tests
-export PYTHONPATH=${srcdir}:${PYTHON_DIR}
+export PYTHONPATH=${srcdir}:${PYTHONPATH}
 export QPIDD_EXEC=${top_builddir}/src/qpidd
 export CLUSTER_LIB=${top_builddir}/src/.libs/cluster.so
 export QPID_CONFIG_EXEC=${srcdir}/../../../python/commands/qpid-config
@@ -45,26 +32,21 @@
 export RECEIVER_EXEC=${top_builddir}/src/tests/receiver
 export SENDER_EXEC=${top_builddir}/src/tests/sender
 
+# Check XML exchange requirements
+XML_LIB=$srcdir/../.libs/xml.so
+test -f ${XML_LIB} && export XML_LIB
 
-# Check for existence of qpid tools (either in svn tree or full install)
-# This prevents make dist / make distcheck from failing without python tools being present
-if test ! -x ${top_builddir}/../python/commands/qpid-config; then
-	path=`which qpid-config`
-	if test $?; then
-		echo "WARNING: qpid tools not found, skipping test ${CLUSTER_TEST}" 
-		exit 0
-	fi
-fi
+# Check AIS requirements
+. $srcdir/ais_check
 
 # Delete old cluster test data
 OUTDIR=brokertest.tmp
 rm -rf $OUTDIR
 mkdir -p $OUTDIR
 
-# FIXME aconway 2009-11-06: pass OUTDIR to test.
+# Ignore tests requiring a store by default. 
+TESTS="-i cluster_tests.ClusterStoreTests.* -I $srcdir/cluster_tests.fail"
 
-# Run the test
-with_ais_group $PYTHON_COMMANDS/qpid-python-test -m cluster_tests
-## || exit 1
-#rm -rf $OUTDIR
+with_ais_group $PYTHON_COMMANDS/qpid-python-test -DOUTDIR=$OUTDIR -m cluster_tests $TESTS
|| exit 1
+rm -rf $OUTDIR
 #exit 0



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message