summaryrefslogtreecommitdiff
path: root/python/qpid
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-06-03 16:16:18 +0000
committerAlan Conway <aconway@apache.org>2010-06-03 16:16:18 +0000
commita5bf1aec82703d272f5e63a1fd9da6219a1ea4aa (patch)
treee3f6f592abd407ef4ecab3663cb0f5dcc994ce36 /python/qpid
parent910203e835d9f58a0079b9318e2bcb8dc15cd22e (diff)
downloadqpid-python-a5bf1aec82703d272f5e63a1fd9da6219a1ea4aa.tar.gz
Add tail of broker log to exception message when broker fails to start.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@951050 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid')
-rw-r--r--python/qpid/brokertest.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/python/qpid/brokertest.py b/python/qpid/brokertest.py
index 1debabf3df..cd16aa14e0 100644
--- a/python/qpid/brokertest.py
+++ b/python/qpid/brokertest.py
@@ -79,16 +79,18 @@ class ExceptionWrapper:
except Exception, e:
raise Exception("%s: %s" %(self.msg, str(e)))
-def error_line(filename):
- """Get the last line of filename for error messages"""
- result = ""
+def error_line(filename, n=1):
+ """Get the last n line(s) of filename for error messages"""
+ result = []
try:
f = open(filename)
try:
- for l in f: result = ": " + l
+ for l in f:
+ if len(result) == n: result.pop(0)
+ result.append("\n "+l)
finally: f.close()
except: return ""
- return result
+ return ":" + "".join(result)
def retry(function, timeout=10, delay=.01):
"""Call function until it returns True or timeout expires.
@@ -380,10 +382,12 @@ class Broker(Popen):
"""Wait till broker is ready to serve clients"""
# First make sure the broker is listening by checking the log.
if not retry(self.log_ready):
- raise Exception("Timed out waiting for broker %s" % self.name)
+ raise Exception(
+ "Timed out waiting for broker %s%s"%(self.name, error_line(self.log,4)))
# Make a connection, this will wait for extended cluster init to finish.
try: self.connect(**kwargs).close()
- except: raise RethrownException("Broker %s failed ready test"%self.name)
+ except: raise RethrownException(
+ "Broker %s failed ready test%s"%(self.name,error_line(self.log,4)))
def store_state(self):
uuids = open(os.path.join(self.datadir, "cluster", "store.status")).readlines()
@@ -407,7 +411,7 @@ class Cluster:
self.args = copy(args)
self.args += [ "--cluster-name", "%s-%s:%d" % (self.name, socket.gethostname(), os.getpid()) ]
self.args += [ "--log-enable=info+", "--log-enable=debug+:cluster"]
- assert BrokerTest.cluster_lib
+ assert BrokerTest.cluster_lib, "Cannot locate cluster plug-in"
self.args += [ "--load-module", BrokerTest.cluster_lib ]
self.start_n(count, expect=expect, wait=wait)
@@ -477,7 +481,7 @@ class BrokerTest(TestCase):
if (wait):
try: b.ready()
except Exception, e:
- raise Exception("Failed to start broker %s(%s): %s" % (b.name, b.log, e))
+ raise RethrownException("Failed to start broker %s(%s): %s" % (b.name, b.log, e))
return b
def cluster(self, count=0, args=[], expect=EXPECT_RUNNING, wait=True):