[
https://issues.apache.org/jira/browse/DISPATCH-209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16068247#comment-16068247
]
ASF GitHub Bot commented on DISPATCH-209:
-----------------------------------------
Github user ted-ross commented on a diff in the pull request:
https://github.com/apache/qpid-dispatch/pull/170#discussion_r124780999
--- Diff: tests/system_tests_three_routers.py ---
@@ -373,5 +433,189 @@ def run(self):
+
+class Entity(object):
+ def __init__(self, status_code, status_description, attrs):
+ self.status_code = status_code
+ self.status_description = status_description
+ self.attrs = attrs
+
+ def __getattr__(self, key):
+ return self.attrs[key]
+
+
+
+
+class RouterProxy(object):
+ def __init__(self, reply_addr):
+ self.reply_addr = reply_addr
+
+ def response(self, msg):
+ ap = msg.properties
+ return Entity(ap['statusCode'], ap['statusDescription'], msg.body)
+
+ def read_address(self, name):
+ ap = {'operation': 'READ', 'type':
'org.apache.qpid.dispatch.router.address', 'name': name}
+ return Message(properties=ap, reply_to=self.reply_addr)
+
+ def query_addresses(self):
+ ap = {'operation': 'QUERY', 'type':
'org.apache.qpid.dispatch.router.address'}
+ return Message(properties=ap, reply_to=self.reply_addr)
+
+
+
+
+class PollTimeout(object):
+ def __init__(self, parent):
+ self.parent = parent
+
+ def on_timer_task(self, event):
+ self.parent.poll_timeout()
+
+
+
+class Timeout(object):
+ def __init__(self, parent):
+ self.parent = parent
+
+ def on_timer_task(self, event):
+ self.parent.timeout()
+
+
+class LinkRoute ( MessagingHandler ):
+
+ """
+ Set up and use a link-route, to send a message this way:
+ receiver <--- A <--- B <--- C <--- sender
+
+ Check for appearance of the link-route at router A with a
+ technique that is appropriate to the 'proactor' style,
+ i.e. do not take control away from the proactor for an extended
+ period of time.
+ """
+
+ def __init__ ( self, route_container, linkroute_prefix,
route_check_address, send_address ):
+ super(LinkRoute, self).__init__(prefetch=0)
+ self.route_container = route_container
+ self.send_address = send_address
+ self.linkroute_prefix = linkroute_prefix
+ self.route_check_address = route_check_address
+ self.true_statement = "This IS the message you are looking
for."
+ self.error = None
+ self.send_connection = None
+ self.recv_connection = None
+ self.route_check_connection = None
+ self.route_check_sender = None
+ self.sender = None
+ self.route_check_timer = None
+ self.route_check_receiver = None
+ self.count = 1
+ self.sent = 0
+ self.route_checks_sent = 0
+
+
+ def bail ( self, error_text ) :
+ self.error = error_text
+ self.recv_connection.close()
+ self.route_check_connection.close()
+ self.send_connection.close()
+ self.timer.cancel()
+ if self.route_check_timer :
+ self.route_check_timer.cancel()
+ self.route_check_timer = None
+
+
+ def timeout(self):
+ self.bail ( "Timeout Expired" )
+
+
+ def poll_timeout ( self ) :
+ self.poll()
+
+
+ def on_start(self, event):
+ # Iff this timer expires, the test fails.
+ self.timer = event.reactor.schedule ( TIMEOUT, Timeout(self) )
+
+ # At startup, create only the receivers and the sender that checks
for
+ # the route being ready. Creation of the payload message sender
+ # has to wait until we know the address is available, to avoid a
+ # 'no route to destination' error.
+ self.recv_connection = event.container.connect (
self.route_container )
+
+ self.route_check_connection = event.container.connect (
self.route_check_address )
+ self.route_check_receiver = event.container.create_receiver (
self.route_check_connection,
+
dynamic=True
+ )
+ self.route_check_sender = event.container.create_sender (
self.route_check_connection,
+
"$management"
+ )
+
+
+
+ def poll ( self ):
+ # The router prepends this 'D' to the address. If we want
+ # to look for it down at router A, we have to do likewise.
+ doctored_linkroute_prefix = 'D' + self.linkroute_prefix
+ request = self.proxy.read_address ( doctored_linkroute_prefix )
+ self.route_check_sender.send ( request )
+
+
+
+ def on_link_opened ( self, event ):
+
+ if event.receiver:
+ event.receiver.flow ( self.count )
+
+ if event.receiver == self.route_check_receiver:
+ self.proxy = RouterProxy (
self.route_check_receiver.remote_source.address )
+ self.poll()
+
+
+ def on_link_opening ( self, event ):
+ if event.receiver:
+ event.receiver.target.address = self.route_container
+ event.receiver.flow(1)
+
+
+ def on_sendable ( self, event ):
+ if event.sender == self.sender and self.sent < self.count :
+ self.sender.send ( Message ( address = self.linkroute_prefix,
body = self.true_statement ) )
+ self.sent += 1
+
+
+ def on_message ( self, event ):
+ # Check that the incoming message is the one we sent.
+ if ( event.message.body == self.true_statement ) :
+ self.bail ( None )
+
+ if event.receiver == self.route_check_receiver:
+ response = self.proxy.response(event.message)
+ if response.status_code == 200 and (response.remoteCount +
response.containerCount) > 0:
+ if self.route_check_timer :
+ self.route_check_timer.cancel()
+ self.route_check_timer = None
+ # After address appears at the far end of my router line,
(router A)
+ # give more time to let it finish propagating.
+ time.sleep ( 2 )
--- End diff --
Is this sleep really necessary? Why do you need to allow more time for
propagation when you have just verified that the propagation is complete?
> Three+ router test is needed in the system test suite.
> ------------------------------------------------------
>
> Key: DISPATCH-209
> URL: https://issues.apache.org/jira/browse/DISPATCH-209
> Project: Qpid Dispatch
> Issue Type: New Feature
> Components: Tests
> Reporter: Ted Ross
> Assignee: michael goulish
> Fix For: 1.0.0
>
>
> There have arisen some issues that would have been caught had there been a
> three-router test in the regression suite. This test should be added.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]