You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2016/09/15 17:11:59 UTC

[1/2] qpid-dispatch git commit: DISPATCH-495 - Additional autolink test

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 536e4daf3 -> 87bc8fce5


DISPATCH-495 - Additional autolink test


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/87bc8fce
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/87bc8fce
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/87bc8fce

Branch: refs/heads/master
Commit: 87bc8fce5a1ba2b8e1197bceeb195f3b5721958e
Parents: d1be867
Author: Ted Ross <tr...@redhat.com>
Authored: Wed Sep 7 15:27:46 2016 -0700
Committer: Ted Ross <tr...@redhat.com>
Committed: Wed Sep 14 19:37:04 2016 -0400

----------------------------------------------------------------------
 tests/system_tests_autolinks.py | 100 ++++++++++++++++++++++++++++++++++-
 1 file changed, 98 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/87bc8fce/tests/system_tests_autolinks.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_autolinks.py b/tests/system_tests_autolinks.py
index b38a71f..f899881 100644
--- a/tests/system_tests_autolinks.py
+++ b/tests/system_tests_autolinks.py
@@ -22,8 +22,6 @@ from proton import Message, Delivery, PENDING, ACCEPTED, REJECTED
 from system_test import TestCase, Qdrouterd, main_module
 from proton.handlers import MessagingHandler
 from proton.reactor import Container, AtMostOnce, AtLeastOnce
-from proton.utils import BlockingConnection, SyncRequestResponse
-from qpid_dispatch.management.client import Node
 
 CONNECTION_PROPERTIES = {u'connection': u'properties', u'int_property': 6451}
 
@@ -117,6 +115,16 @@ class AutolinkTest(TestCase):
         self.assertEqual(None, test.error)
 
 
+    def test_06_manage_autolinks(self):
+        """
+        Create a route-container connection and a normal receiver.  Ensure that messages sent from the
+        route-container are received by the receiver and that settlement propagates back to the sender.
+        """
+        test = ManageAutolinksTest(self.normal_address, self.route_address)
+        test.run()
+        self.assertEqual(None, test.error)
+
+
 class Timeout(object):
     def __init__(self, parent):
         self.parent = parent
@@ -407,5 +415,93 @@ class InterContainerTransferTest(MessagingHandler):
         container.run()
 
 
+class ManageAutolinksTest(MessagingHandler):
+    def __init__(self, normal_address, route_address):
+        super(ManageAutolinksTest, self).__init__()
+        self.normal_address = normal_address
+        self.route_address  = route_address
+        self.count          = 5
+        self.normal_conn    = None
+        self.route_conn     = None
+        self.error          = None
+        self.n_created      = 0
+        self.n_attached     = 0
+        self.n_deleted      = 0
+        self.n_detached     = 0
+
+    def timeout(self):
+        self.error = "Timeout Expired: n_created=%d n_attached=%d n_deleted=%d n_detached=%d" % \
+                     (self.n_created, self.n_attached, self.n_deleted, self.n_detached)
+        self.normal_conn.close()
+        self.route_conn.close()
+
+    def on_start(self, event):
+        self.timer  = event.reactor.schedule(5, Timeout(self))
+        event.container.container_id = 'container.new'
+        self.route_conn  = event.container.connect(self.route_address)
+        self.normal_conn = event.container.connect(self.normal_address)
+        self.reply       = event.container.create_receiver(self.normal_conn, dynamic=True)
+        self.agent       = event.container.create_sender(self.normal_conn, "$management");
+
+    def on_link_opening(self, event):
+        if event.sender:
+            event.sender.source.address = event.sender.remote_source.address
+        if event.receiver:
+            event.receiver.target.address = event.receiver.remote_target.address
+
+    def on_link_opened(self, event):
+        if event.receiver == self.reply:
+            self.reply_to = self.reply.remote_source.address
+        if event.connection == self.route_conn:
+            self.n_attached += 1
+            if self.n_attached == self.count:
+                self.send_ops()
+
+    def on_link_remote_close(self, event):
+        self.n_detached += 1
+        if self.n_detached == self.count:
+            self.timer.cancel()
+            self.normal_conn.close()
+            self.route_conn.close()
+
+    def send_ops(self):
+        if self.n_created < self.count:
+            while self.n_created < self.count and self.agent.credit > 0:
+                props = {'operation': 'CREATE',
+                         'type': 'org.apache.qpid.dispatch.router.config.autoLink',
+                         'name': 'AL.%d' % self.n_created }
+                body  = {'dir': 'out',
+                         'containerId': 'container.new',
+                         'addr': 'node.%d' % self.n_created }
+                msg = Message(properties=props, body=body, reply_to=self.reply_to)
+                self.agent.send(msg)
+                self.n_created += 1
+        elif self.n_attached == self.count and self.n_deleted < self.count:
+            while self.n_deleted < self.count and self.agent.credit > 0:
+                props = {'operation': 'DELETE',
+                         'type': 'org.apache.qpid.dispatch.router.config.autoLink',
+                         'name': 'AL.%d' % self.n_deleted }
+                body  = {}
+                msg = Message(properties=props, body=body, reply_to=self.reply_to)
+                self.agent.send(msg)
+                self.n_deleted += 1
+
+    def on_sendable(self, event):
+        if event.sender == self.agent:
+            self.send_ops()
+
+    def on_message(self, event):
+        if event.message.properties['statusCode'] / 100 != 2:
+            self.error = 'Op Error: %d %s' % (event.message.properties['statusCode'],
+                                              event.message.properties['statusDescription'])
+            self.timer.cancel()
+            self.normal_conn.close()
+            self.route_conn.close()
+
+    def run(self):
+        container = Container(self)
+        container.run()
+
+
 if __name__ == '__main__':
     unittest.main(main_module())


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


[2/2] qpid-dispatch git commit: DISPATCH-495 - Added three more autolink tests to verify proper message transfer and settlement.

Posted by tr...@apache.org.
DISPATCH-495 - Added three more autolink tests to verify proper message transfer and settlement.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/d1be867d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/d1be867d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/d1be867d

Branch: refs/heads/master
Commit: d1be867daeea50ac75687e81b0d3778a95c4f580
Parents: 536e4da
Author: Ted Ross <tr...@redhat.com>
Authored: Tue Sep 6 10:49:59 2016 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Wed Sep 14 19:37:04 2016 -0400

----------------------------------------------------------------------
 tests/system_tests_autolinks.py | 215 +++++++++++++++++++++++++++++++++++
 1 file changed, 215 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d1be867d/tests/system_tests_autolinks.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_autolinks.py b/tests/system_tests_autolinks.py
index cc79c64..b38a71f 100644
--- a/tests/system_tests_autolinks.py
+++ b/tests/system_tests_autolinks.py
@@ -87,6 +87,36 @@ class AutolinkTest(TestCase):
         self.assertEqual(None, test.error)
 
 
+    def test_03_autolink_sender(self):
+        """
+        Create a route-container connection and a normal sender.  Ensure that messages sent on the sender
+        link are received by the route container and that settlement propagates back to the sender.
+        """
+        test = AutolinkSenderTest(self.normal_address, self.route_address)
+        test.run()
+        self.assertEqual(None, test.error)
+
+
+    def test_04_autolink_receiver(self):
+        """
+        Create a route-container connection and a normal receiver.  Ensure that messages sent from the
+        route-container are received by the receiver and that settlement propagates back to the sender.
+        """
+        test = AutolinkReceiverTest(self.normal_address, self.route_address)
+        test.run()
+        self.assertEqual(None, test.error)
+
+
+    def test_05_inter_container_transfer(self):
+        """
+        Create a route-container connection and a normal receiver.  Ensure that messages sent from the
+        route-container are received by the receiver and that settlement propagates back to the sender.
+        """
+        test = InterContainerTransferTest(self.normal_address, self.route_address)
+        test.run()
+        self.assertEqual(None, test.error)
+
+
 class Timeout(object):
     def __init__(self, parent):
         self.parent = parent
@@ -192,5 +222,190 @@ class AutolinkCreditTest(MessagingHandler):
         container.run()
 
 
+class AutolinkSenderTest(MessagingHandler):
+    def __init__(self, normal_address, route_address):
+        super(AutolinkSenderTest, self).__init__()
+        self.normal_address = normal_address
+        self.route_address  = route_address
+        self.dest           = 'node.1'
+        self.count          = 275
+        self.normal_conn    = None
+        self.route_conn     = None
+        self.error          = None
+        self.last_action    = "None"
+        self.n_sent         = 0
+        self.n_received     = 0
+        self.n_settled      = 0
+
+    def timeout(self):
+        self.error = "Timeout Expired: last_action=%s n_sent=%d n_received=%d n_settled=%d" % \
+                     (self.last_action, self.n_sent, self.n_received, self.n_settled)
+        if self.normal_conn:
+            self.normal_conn.close()
+        if self.route_conn:
+            self.route_conn.close()
+
+    def on_start(self, event):
+        self.timer       = event.reactor.schedule(5, Timeout(self))
+        self.route_conn  = event.container.connect(self.route_address)
+        self.last_action = "Connected route container"
+
+    def on_link_opening(self, event):
+        if event.sender:
+            event.sender.source.address = event.sender.remote_source.address
+        if event.receiver:
+            event.receiver.target.address = event.receiver.remote_target.address
+
+    def on_link_opened(self, event):
+        if event.receiver and not self.normal_conn:
+            self.normal_conn = event.container.connect(self.normal_address)
+            self.sender      = event.container.create_sender(self.normal_conn, self.dest)
+            self.last_action = "Attached normal sender"
+
+    def on_sendable(self, event):
+        if event.sender == self.sender:
+            while self.n_sent < self.count and event.sender.credit > 0:
+                msg = Message(body="AutoLinkTest")
+                self.sender.send(msg)
+                self.n_sent += 1
+
+    def on_message(self, event):
+        self.n_received += 1
+        self.accept(event.delivery)
+
+    def on_settled(self, event):
+        self.n_settled += 1
+        if self.n_settled == self.count:
+            self.timer.cancel()
+            self.normal_conn.close()
+            self.route_conn.close()
+
+    def run(self):
+        container = Container(self)
+        container.container_id = 'container.1'
+        container.run()
+
+
+class AutolinkReceiverTest(MessagingHandler):
+    def __init__(self, normal_address, route_address):
+        super(AutolinkReceiverTest, self).__init__()
+        self.normal_address = normal_address
+        self.route_address  = route_address
+        self.dest           = 'node.1'
+        self.count          = 275
+        self.normal_conn    = None
+        self.route_conn     = None
+        self.error          = None
+        self.last_action    = "None"
+        self.n_sent         = 0
+        self.n_received     = 0
+        self.n_settled      = 0
+
+    def timeout(self):
+        self.error = "Timeout Expired: last_action=%s n_sent=%d n_received=%d n_settled=%d" % \
+                     (self.last_action, self.n_sent, self.n_received, self.n_settled)
+        if self.normal_conn:
+            self.normal_conn.close()
+        if self.route_conn:
+            self.route_conn.close()
+
+    def on_start(self, event):
+        self.timer       = event.reactor.schedule(5, Timeout(self))
+        self.route_conn  = event.container.connect(self.route_address)
+        self.last_action = "Connected route container"
+
+    def on_link_opening(self, event):
+        if event.sender:
+            event.sender.source.address = event.sender.remote_source.address
+            self.sender = event.sender
+        if event.receiver:
+            event.receiver.target.address = event.receiver.remote_target.address
+
+    def on_link_opened(self, event):
+        if event.sender and not self.normal_conn:
+            self.normal_conn = event.container.connect(self.normal_address)
+            self.receiver    = event.container.create_receiver(self.normal_conn, self.dest)
+            self.last_action = "Attached normal receiver"
+
+    def on_sendable(self, event):
+        if event.sender == self.sender:
+            while self.n_sent < self.count and event.sender.credit > 0:
+                msg = Message(body="AutoLinkTest")
+                self.sender.send(msg)
+                self.n_sent += 1
+
+    def on_message(self, event):
+        self.n_received += 1
+        self.accept(event.delivery)
+
+    def on_settled(self, event):
+        self.n_settled += 1
+        if self.n_settled == self.count:
+            self.timer.cancel()
+            self.normal_conn.close()
+            self.route_conn.close()
+
+    def run(self):
+        container = Container(self)
+        container.container_id = 'container.1'
+        container.run()
+
+
+class InterContainerTransferTest(MessagingHandler):
+    def __init__(self, normal_address, route_address):
+        super(InterContainerTransferTest, self).__init__()
+        self.normal_address = normal_address
+        self.route_address  = route_address
+        self.count          = 275
+        self.conn_1         = None
+        self.conn_2         = None
+        self.error          = None
+        self.n_sent         = 0
+        self.n_received     = 0
+        self.n_settled      = 0
+
+    def timeout(self):
+        self.error = "Timeout Expired:  n_sent=%d n_received=%d n_settled=%d" % \
+                     (self.n_sent, self.n_received, self.n_settled)
+        self.conn_1.close()
+        self.conn_2.close()
+
+    def on_start(self, event):
+        self.timer  = event.reactor.schedule(5, Timeout(self))
+        event.container.container_id = 'container.2'
+        self.conn_1 = event.container.connect(self.route_address)
+        event.container.container_id = 'container.3'
+        self.conn_2 = event.container.connect(self.route_address)
+
+    def on_link_opening(self, event):
+        if event.sender:
+            event.sender.source.address = event.sender.remote_source.address
+            self.sender = event.sender
+        if event.receiver:
+            event.receiver.target.address = event.receiver.remote_target.address
+
+    def on_sendable(self, event):
+        if event.sender == self.sender:
+            while self.n_sent < self.count and event.sender.credit > 0:
+                msg = Message(body="AutoLinkTest")
+                self.sender.send(msg)
+                self.n_sent += 1
+
+    def on_message(self, event):
+        self.n_received += 1
+        self.accept(event.delivery)
+
+    def on_settled(self, event):
+        self.n_settled += 1
+        if self.n_settled == self.count:
+            self.timer.cancel()
+            self.conn_1.close()
+            self.conn_2.close()
+
+    def run(self):
+        container = Container(self)
+        container.run()
+
+
 if __name__ == '__main__':
     unittest.main(main_module())


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