Merge lp://staging/~esteve/txamqp/396679-report-trial-connection-error into lp://staging/txamqp

Proposed by Esteve Fernandez
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~esteve/txamqp/396679-report-trial-connection-error
Merge into: lp://staging/txamqp
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~esteve/txamqp/396679-report-trial-connection-error
Reviewer Review Type Date Requested Status
Thomas Herve Approve
Dan Di Spaltro code Approve
Zooko Wilcox-O'Hearn (community) Approve
Esteve Fernandez Approve
Terry Jones Pending
Review via email: mp+8496@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Esteve Fernandez (esteve) :
review: Approve
24. By Esteve Fernandez

fix error output

Revision history for this message
Zooko Wilcox-O'Hearn (zooko) wrote :

Looks good.

review: Approve
Revision history for this message
Dan Di Spaltro (dan-dispaltro) wrote :

+1, this should help out new comers to AMQP and twisted...

review: Approve (code)
Revision history for this message
Esteve Fernandez (esteve) wrote :

Thomas? Terry? What do you think?

Revision history for this message
Thomas Herve (therve) wrote :

It looks ok, just 2 pyflakes to fix:

src/txamqp/testlib.py:23: 'log' imported but unused
src/txamqp/testlib.py:82: undefined name 'broker'

review: Approve
25. By Esteve Fernandez

fixed undefined variable (broker)

Revision history for this message
Terry Jones (terrycojones) wrote :

>>>>> "Esteve" == Esteve Fernandez <email address hidden> writes:
Esteve> Thomas? Terry? What do you think?

I pushed some small changes to

  lp:~terrycojones/txamqp/396679-report-trial-connection-error

There were 4 unused imports, I fixed the broker -> self.broker issue,
added a var to hold the names of all brokers, and removed a duplicate
method (consume).

Terry

Revision history for this message
Esteve Fernandez (esteve) wrote :

> There were 4 unused imports, I fixed the broker -> self.broker issue,
> added a var to hold the names of all brokers, and removed a duplicate
> method (consume).

I'll merge lp:~esteve/txamqp/396679-report-trial-connection-error and file a separate report for those issues (unused imports, duplicate methods, etc.)

Thank you all for your reviews.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/txamqp/testlib.py'
2--- src/txamqp/testlib.py 2009-06-17 16:01:31 +0000
3+++ src/txamqp/testlib.py 2009-07-09 20:55:26 +0000
4@@ -25,7 +25,7 @@
5
6 from txamqp.protocol import AMQChannel, AMQClient, TwistedDelegate
7
8-from twisted.internet import protocol, reactor
9+from twisted.internet import error, protocol, reactor
10 from twisted.trial import unittest
11 from twisted.internet.defer import inlineCallbacks, Deferred, returnValue, DeferredQueue, DeferredLock
12 from twisted.python import failure
13@@ -52,6 +52,9 @@
14 return os.environ.get("TXAMQP_BROKER")
15
16
17+USERNAME='guest'
18+PASSWORD='guest'
19+VHOST='localhost'
20 class TestBase(unittest.TestCase):
21
22 def __init__(self, *args, **kwargs):
23@@ -75,9 +78,9 @@
24 raise RuntimeError(
25 "Unsupported broker '%s'. Use one of RABBITMQ, OPENAMQ or "
26 "QPID" % broker)
27- self.user = 'guest'
28- self.password = 'guest'
29- self.vhost = 'localhost'
30+ self.user = USERNAME
31+ self.password = PASSWORD
32+ self.vhost = VHOST
33 self.queues = []
34 self.exchanges = []
35 self.connectors = []
36@@ -95,6 +98,13 @@
37 onConn = Deferred()
38 f = protocol._InstanceFactory(reactor, AMQClient(delegate, vhost, txamqp.spec.load(spec)), onConn)
39 c = reactor.connectTCP(host, port, f)
40+ def errb(thefailure):
41+ thefailure.trap(error.ConnectionRefusedError)
42+ print "failed to connect to host: %s, port: %s; These tests are designed to run against a running instance" \
43+ " of the %s AMQP broker on the given host and port. failure: %s" % (_get_broker(), host, port, thefailure,)
44+ thefailure.raiseException()
45+ onConn.addErrback(errb)
46+
47 self.connectors.append(c)
48 client = yield onConn
49
50@@ -103,7 +113,14 @@
51
52 @inlineCallbacks
53 def setUp(self):
54- self.client = yield self.connect()
55+ try:
56+ self.client = yield self.connect()
57+ except txamqp.client.Closed, le:
58+ le.args = tuple(("Unable to connect to AMQP broker in order to run tests (perhaps due to auth failure?). " \
59+ "The tests assume that an instance of the %s AMQP broker is already set up and that this test script " \
60+ "can connect to it and use it as user '%s', password '%s', vhost '%s'." % (_get_broker(),
61+ USERNAME, PASSWORD, VHOST),) + le.args)
62+ raise
63
64 self.channel = yield self.client.channel(1)
65 yield self.channel.channel_open()

Subscribers

People subscribed via source and target branches

to status/vote changes: