You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2018/03/28 15:54:18 UTC

qpid-dispatch git commit: DISPATCH-947 - test_17_management in system_tests_one_router is de-Messengerized

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master a90d8b458 -> a2a545ca3


DISPATCH-947 - test_17_management in system_tests_one_router is de-Messengerized


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

Branch: refs/heads/master
Commit: a2a545ca35c2c5914232db059f2f2d7055b30ed7
Parents: a90d8b4
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Wed Mar 28 10:54:02 2018 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Wed Mar 28 11:53:31 2018 -0400

----------------------------------------------------------------------
 tests/system_tests_one_router.py  | 138 ++++++++++++++++++---------------
 tests/system_tests_two_routers.py |   1 -
 2 files changed, 74 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a2a545ca/tests/system_tests_one_router.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_one_router.py b/tests/system_tests_one_router.py
index 284f8e7..d4df862 100644
--- a/tests/system_tests_one_router.py
+++ b/tests/system_tests_one_router.py
@@ -393,63 +393,10 @@ class OneRouterTest(TestCase):
         M1.stop()
         M2.stop()
 
-
-
     def test_17_management(self):
-        addr  = "amqp:/$management"
-
-        M = self.messenger()
-        M.start()
-        M.route("amqp:/*", self.address+"/$1")
-        sub = M.subscribe("amqp:/#")
-        reply = sub.address
-
-        request  = Message()
-        response = Message()
-
-        request.address        = addr
-        request.reply_to       = reply
-        request.correlation_id = "C1"
-        request.properties     = {u'type':u'org.amqp.management', u'name':u'self', u'operation':u'GET-MGMT-NODES'}
-
-        M.put(request)
-        M.send()
-        M.recv()
-        M.get(response)
-
-        assert response.properties['statusCode'] == 200, response.properties['statusCode']
-        self.assertEqual(response.correlation_id, "C1")
-        self.assertEqual(response.body, [])
-
-        request.address        = addr
-        request.reply_to       = reply
-        request.correlation_id = 135
-        request.properties     = {u'type':u'org.amqp.management', u'name':u'self', u'operation':u'GET-MGMT-NODES'}
-
-        M.put(request)
-        M.send()
-        M.recv()
-        M.get(response)
-
-        self.assertEqual(response.properties['statusCode'], 200)
-        self.assertEqual(response.correlation_id, 135)
-        self.assertEqual(response.body, [])
-
-        request.address        = addr
-        request.reply_to       = reply
-        request.properties     = {u'type':u'org.amqp.management', u'name':u'self', u'operation':u'GET-MGMT-NODES'}
-
-        M.put(request)
-        M.send()
-        M.recv()
-        M.get(response)
-
-        self.assertEqual(response.properties['statusCode'], 200)
-        self.assertEqual(response.body, [])
-
-        M.stop()
-
-
+        test = ManagementTest(self.address)
+        test.run()
+        self.assertEqual(None, test.error)
 
     def test_18_management_no_reply(self):
         addr  = "amqp:/$management"
@@ -472,8 +419,6 @@ class OneRouterTest(TestCase):
 
         M.stop()
 
-
-
     def test_19_management_get_operations(self):
         addr  = "amqp:/_local/$management"
 
@@ -506,8 +451,6 @@ class OneRouterTest(TestCase):
 
         M.stop()
 
-
-
     def test_20_management_not_implemented(self):
         addr  = "amqp:/$management"
 
@@ -536,10 +479,6 @@ class OneRouterTest(TestCase):
 
         M.stop()
 
-
-
-
-
     def test_21_semantics_multicast(self):
         addr = self.address+"/multicast.10"
         M1 = self.messenger()
@@ -870,6 +809,77 @@ class OneRouterTest(TestCase):
         client.connection.close()
 
 
+class ManagementTest(MessagingHandler):
+    def __init__(self, address):
+        super(ManagementTest, self).__init__()
+        self.address = address
+        self.timer = None
+        self.conn = None
+        self.sender = None
+        self.receiver = None
+        self.sent_count = 0
+        self.msg_not_sent = True
+        self.error = None
+        self.num_messages = 0
+        self.response1 = False
+        self.response2 = False
+
+    def timeout(self):
+        if not self.response1:
+            self.error = "Incorrect response received for message with correlation id C1"
+        if not self.response1:
+            self.error = self.error + "and incorrect response received for message with correlation id C2"
+
+    def on_start(self, event):
+        self.timer = event.reactor.schedule(TIMEOUT, Timeout(self))
+        self.conn = event.container.connect(self.address)
+        self.sender = event.container.create_sender(self.conn)
+        self.receiver = event.container.create_receiver(self.conn, None, dynamic=True)
+
+    def on_sendable(self, event):
+        if self.num_messages < 2:
+            request = Message()
+            request.address = "amqp:/$management"
+            request.reply_to = self.receiver.remote_source.address
+            request.correlation_id = "C1"
+            request.properties = {u'type': u'org.amqp.management', u'name': u'self', u'operation': u'GET-MGMT-NODES'}
+
+            event.sender.send(request)
+            self.num_messages += 1
+
+            request = Message()
+            request.address = "amqp:/_topo/0/QDR.B/$management"
+            request.correlation_id = "C2"
+            request.reply_to = self.receiver.remote_source.address
+            request.properties = {u'type': u'org.amqp.management', u'name': u'self', u'operation': u'GET-MGMT-NODES'}
+            event.sender.send(request)
+            self.num_messages += 1
+
+    def on_message(self, event):
+        if event.receiver == self.receiver:
+            if event.message.correlation_id == "C1":
+                if event.message.properties['statusCode'] == 200 and \
+                        event.message.properties['statusDescription'] is not None \
+                        and event.message.body == []:
+                    self.response1 = True
+            elif event.message.correlation_id == "C2":
+                if event.message.properties['statusCode'] == 200 and \
+                        event.message.properties['statusDescription'] is not None \
+                        and event.message.body == []:
+                    self.response2 = True
+
+        if self.response1 and self.response2:
+            self.error = None
+
+        if self.error is None:
+            self.timer.cancel()
+            self.conn.close()
+
+    def run(self):
+        Container(self).run()
+
+
+
 class CustomTimeout(object):
     def __init__(self, parent):
         self.parent = parent

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/a2a545ca/tests/system_tests_two_routers.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_two_routers.py b/tests/system_tests_two_routers.py
index 5a808a2..650fcf8 100644
--- a/tests/system_tests_two_routers.py
+++ b/tests/system_tests_two_routers.py
@@ -546,7 +546,6 @@ class ManagementTest(MessagingHandler):
     def __init__(self, address):
         super(ManagementTest, self).__init__()
         self.address = address
-        self.dest = "strip_message_annotations_in/1"
         self.timer = None
         self.conn = None
         self.sender = None


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