Fix test_10_propagated_disposition in system_tests_two_routers. This test was closing connections before dispositions could arrive
@@ -197,6 +197,7 @@ class TwoRouterTest(TestCase):
def test_10_propagated_disposition(self):
test = PropagatedDisposition(self, self.routers[0].addresses[0], self.routers[1].addresses[0])
test.run()
+ self.assertTrue(test.passed)
def test_11_three_ack(self):
test = ThreeAck(self, self.routers[0].addresses[0], self.routers[1].addresses[0])
@@ -1426,43 +1427,66 @@ class SemanticsBalanced(MessagingHandler):
class PropagatedDisposition(MessagingHandler):
def __init__(self, test, address1, address2):
super(PropagatedDisposition, self).__init__(auto_accept=False)
- self.addrs = [address1, address2]
+ self.address1 = address1
+ self.address2 = address2
self.settled = []
self.test = test
+ self.sender_conn = None
+ self.receiver_conn = None
+ self.passed = False
def on_start(self, event):
- connections = [event.container.connect(a) for a in self.addrs]
+ self.timer = event.reactor.schedule(TIMEOUT, Timeout(self))
+ self.sender_conn = event.container.connect(self.address1)
+ self.receiver_conn = event.container.connect(self.address2)
addr = "unsettled/2"
- self.sender = event.container.create_sender(connections[0], addr)
- self.receiver = event.container.create_receiver(connections[1], addr)
+ self.sender = event.container.create_sender(self.sender_conn, addr)
+ self.receiver = event.container.create_receiver(self.receiver_conn, addr)
self.receiver.flow(2)
self.trackers = {}
+
+ def timeout(self):
+ unique_list = list(dict.fromkeys(self.settled))
+ self.error = "Timeout Expired: Expected ['accept', 'reject'] got " + unique_list
+ self.sender_conn.close()
+ self.receiver_conn.close()
+
+ def check(self):
+ unique_list = list(dict.fromkeys(self.settled))
+ if unique_list == [u'accept', u'reject']:
+ self.passed = True
+ self.sender_conn.close()
+ self.receiver_conn.close()
+ self.timer.cancel()
+
+ def on_sendable(self, event):
+ if self.sender == event.sender:
for b in ['accept', 'reject']:
- self.trackers[self.sender.send(Message(body=b))] = b
+ msg = Message(body=b)
+ self.trackers[self.sender.send(msg)] = b
def on_message(self, event):
- if event.message.body == 'accept':
+ if event.message.body == u'accept':
event.delivery.update(Delivery.ACCEPTED)
event.delivery.settle()
- elif event.message.body == 'reject':
+ elif event.message.body == u'reject':
event.delivery.update(Delivery.REJECTED)
event.delivery.settle()
- event.connection.close()
def on_accepted(self, event):
self.test.assertEqual(Delivery.ACCEPTED, event.delivery.remote_state)
self.test.assertEqual('accept', self.trackers[event.delivery])
self.settled.append('accept')
+ self.check()
def on_rejected(self, event):
self.test.assertEqual(Delivery.REJECTED, event.delivery.remote_state)
self.test.assertEqual('reject', self.trackers[event.delivery])
self.settled.append('reject')
- event.connection.close()
+ self.check()
def run(self):
Container(self).run()
- self.test.assertEqual(['accept', 'reject'], sorted(self.settled))
class ThreeAck(MessagingHandler):
