You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by mgoulish <gi...@git.apache.org> on 2017/06/29 06:34:38 UTC

[GitHub] qpid-dispatch pull request #170: DISPATCH-209 : linkroute test better for pr...

GitHub user mgoulish opened a pull request:

    https://github.com/apache/qpid-dispatch/pull/170

    DISPATCH-209 : linkroute test better for proactor

    I stole code from LinkRoute test in multi tenancy system test -- to make my linkroute test better for proactor -- don't hog control so long while checking for linkroute address to appear at the far router.
    
    All 4 tests survived a 100-iteration test on my machine.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mgoulish/qpid-dispatch master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/qpid-dispatch/pull/170.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #170
    
----
commit f7437644d1a938ab3220aa38dccbdc2627ffaefc
Author: mick goulish <mg...@redhat.com>
Date:   2017-06-29T06:26:17Z

    DISPATCH-209 : linkroute test better for proactor

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] qpid-dispatch pull request #170: DISPATCH-209 : linkroute test better for pr...

Posted by ted-ross <gi...@git.apache.org>.
Github user ted-ross commented on a diff in the pull request:

    https://github.com/apache/qpid-dispatch/pull/170#discussion_r124781204
  
    --- 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
    --- End diff --
    
    More information is needed here.   Which endpoint is the initiator of the link?  Which endpoint is connected as the route_container?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] qpid-dispatch issue #170: DISPATCH-209 : linkroute test better for proactor

Posted by mgoulish <gi...@git.apache.org>.
Github user mgoulish commented on the issue:

    https://github.com/apache/qpid-dispatch/pull/170
  
    new one coming shortly...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] qpid-dispatch pull request #170: DISPATCH-209 : linkroute test better for pr...

Posted by ted-ross <gi...@git.apache.org>.
Github user ted-ross commented on a diff in the pull request:

    https://github.com/apache/qpid-dispatch/pull/170#discussion_r124780487
  
    --- 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
    --- End diff --
    
    self.route_container is a host address (0.0.0.0:<some-port>), not an AMQP address.  If you look at the trace of the test, you will see that the addresses in the paired attach frames are different.  This should not be the case.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] qpid-dispatch pull request #170: DISPATCH-209 : linkroute test better for pr...

Posted by ted-ross <gi...@git.apache.org>.
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?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


[GitHub] qpid-dispatch pull request #170: DISPATCH-209 : linkroute test better for pr...

Posted by mgoulish <gi...@git.apache.org>.
Github user mgoulish closed the pull request at:

    https://github.com/apache/qpid-dispatch/pull/170


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org