diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2009-12-01 00:41:44 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2009-12-01 00:41:44 +0000 |
commit | ab4f5a70d1b6a0e00cb5bbc9edc1d3215e77cf5d (patch) | |
tree | 1e1b34398e9d592a489cf72807045375e079649b /java/testkit/testkit.py | |
parent | 5ed8423e696661ca3d68bd8cae03108e408d26c9 (diff) | |
download | qpid-python-ab4f5a70d1b6a0e00cb5bbc9edc1d3215e77cf5d.tar.gz |
Added improved error handling
Modified the script to adapt to changes made by Alan in brokertest.py
The testkit can now receive and handle errors published by the JMS sender or receiver via an error queue.
For example if the test detects and out of order message it will notify the test framework and it will use that information to throw an exception with the captured java stack trace.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@885635 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/testkit/testkit.py')
-rwxr-xr-x | java/testkit/testkit.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/java/testkit/testkit.py b/java/testkit/testkit.py index 66623b9b8c..f0e49072bd 100755 --- a/java/testkit/testkit.py +++ b/java/testkit/testkit.py @@ -19,7 +19,7 @@ # under the License. # -import time, string +import time, string, traceback from brokertest import * from qpid.messaging import * @@ -82,20 +82,22 @@ class JavaClientTest(BrokerTest): for j in range(i): try: m = err_watcher.fetch(timeout=error_ck_freq) - print self.check_for_error() + print "Java process notified of an error" + print self.check_for_error(m) except messaging.Empty, e: pass # do nothing ssn.close() - def check_for_error(msg): - raise Exception("Error:%s \ntime:%s\ntrace:%s\n" % - (msg.properties["desc"], - msg.properties["time"], - msg.properties["exception-trace"] + def check_for_error(self,msg): + raise Exception("Error:%s \nTime:%s\nTrace:%s\n" % + (msg.properties.get("desc"), + msg.properties.get("time"), + msg.properties.get("exception-trace") )) def terminate_and_capture_logs(self,popen, process_name): - popen.terminate() + if popen.is_running(): + popen.terminate() log = os.path.join(self.dir, process_name+".out") f = open(log, 'w') f.write(popen.stdout.read()) @@ -124,7 +126,7 @@ class ConcurrencyTest(JavaClientTest): """Tests multiple sessions on a single connection""" cluster = Cluster(self, 2) - p = cluster[0].port + p = cluster[0].port() self.start_error_watcher(broker=cluster[0]) @@ -149,7 +151,7 @@ class ConcurrencyTest(JavaClientTest): cluster = Cluster(self,2) ssn = cluster[0].connect().session() - p = cluster[0].port + p = cluster[0].port() self.start_error_watcher(broker=cluster[0]) @@ -176,7 +178,7 @@ class SoakTest(JavaClientTest): def test_failover(self): cluster = self.cluster(4, expect=EXPECT_EXIT_FAIL) - p = cluster[0].port + p = cluster[0].port() self.start_error_watcher(broker=cluster[0]) receiver = self.popen(self.client(receiver=True, ssn_count=1, @@ -202,9 +204,10 @@ class SoakTest(JavaClientTest): b=cluster.start() self.monitor_clients(broker=b,run_time=30,error_ck_freq=30) except ConnectError, e1: - error_msg = "Unable to connect to new cluster node" + error_msg = "Unable to connect to new cluster node : " + traceback.format_exc(e1) + except SessionError, e2: - error_msg = "Session error while connected to new cluster node" + error_msg = "Session error while connected to new cluster node : " + traceback.format_exc(e2) # verify also captures out/err streams self.verify(receiver,sender) |