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/21 15:55:06 UTC

qpid-dispatch git commit: DISPATCH-947 - Additional fix to two more tests. Removed use of messenger and use python reactor instead.

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 143246f4e -> dfa5fd46d


DISPATCH-947 - Additional fix to two more tests. Removed use of messenger and use python reactor instead.


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

Branch: refs/heads/master
Commit: dfa5fd46db45aa3c5ec3e335983d46d7f84a326a
Parents: 143246f
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Wed Mar 21 11:54:44 2018 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Wed Mar 21 11:54:44 2018 -0400

----------------------------------------------------------------------
 tests/system_tests_management.py      | 55 ++++++++++++++++++++++--------
 tests/system_tests_protocol_family.py | 49 +++++++++++++++-----------
 2 files changed, 69 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/dfa5fd46/tests/system_tests_management.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_management.py b/tests/system_tests_management.py
index f5e915d..256a1ce 100644
--- a/tests/system_tests_management.py
+++ b/tests/system_tests_management.py
@@ -20,7 +20,10 @@
 """System tests for management of qdrouter"""
 
 import unittest2 as unittest
-import system_test, re, os, json, sys
+import system_test, re, os, json
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+from proton import Message
 from qpid_dispatch.management.client import Node, ManagementError, Url, BadRequestStatus, NotImplementedStatus, NotFoundStatus
 from qpid_dispatch_internal.management.qdrouter import QdSchema
 from qpid_dispatch_internal.compat import dictify
@@ -249,13 +252,10 @@ class ManagementTest(system_test.TestCase):
         self.assert_create_ok(CONFIG_ADDRESS, 'myConfigAddr', dict(prefix='prefixA'))
         self.assert_read_ok(CONFIG_ADDRESS, 'myConfigAddr',
                             dict(prefix='prefixA', pattern=None))
-        msgr = self.messenger()
-        address = self.router.addresses[0]+'/prefixA/other'
-        msgr.subscribe(address)
-        msgr.put(message(address=address, body='hello'))
-        self.assertEqual('hello', msgr.fetch().body)
-        msgr.stop()
-        del msgr
+        simple_send_receive_test = SimpleSndRecv(self.router.addresses[0], '/prefixA/other')
+        simple_send_receive_test.run()
+        self.assertTrue(simple_send_receive_test.message_received)
+
         self.node.delete(CONFIG_ADDRESS, name='myConfigAddr')
         self.assertRaises(NotFoundStatus, self.node.read,
                           type=CONFIG_ADDRESS, name='myConfigAddr')
@@ -264,13 +264,10 @@ class ManagementTest(system_test.TestCase):
         self.assert_create_ok(CONFIG_ADDRESS, 'patternAddr', dict(pattern='a.*.b'))
         self.assert_read_ok(CONFIG_ADDRESS, 'patternAddr',
                             dict(prefix=None, pattern='a.*.b'))
-        msgr = self.messenger()
-        address = self.router.addresses[0]+'/a.HITHERE.b'
-        msgr.subscribe(address)
-        msgr.put(message(address=address, body='hello'))
-        self.assertEqual('hello', msgr.fetch().body)
-        msgr.stop()
-        del msgr
+        simple_send_receive_test = SimpleSndRecv(self.router.addresses[0], '/a.HITHERE.b')
+        simple_send_receive_test.run()
+        self.assertTrue(simple_send_receive_test.message_received)
+
         self.node.delete(CONFIG_ADDRESS, name='patternAddr')
         self.assertRaises(NotFoundStatus, self.node.read,
                           type=CONFIG_ADDRESS, name='patternAddr')
@@ -466,5 +463,33 @@ class ManagementTest(system_test.TestCase):
         self.assertEquals(schema, got)
 
 
+class SimpleSndRecv(MessagingHandler):
+    def __init__(self, conn_address, address):
+        super(SimpleSndRecv, self).__init__()
+        self.conn_address = conn_address
+        self.address = address
+        self.sender = None
+        self.receiver = None
+        self.conn = None
+        self.message_received = False
+
+    def on_start(self, event):
+        self.conn = event.container.connect(self.conn_address)
+        self.receiver = event.container.create_receiver(self.conn, self.address)
+        self.sender = event.container.create_sender(self.conn, self.address)
+
+    def on_sendable(self, event):
+        msg = Message(body="Hello World")
+        event.sender.send(msg)
+
+    def on_message(self, event):
+        if "Hello World" == event.message.body:
+            self.message_received = True
+            self.conn.close()
+
+    def run(self):
+        Container(self).run()
+
+
 if __name__ == '__main__':
     unittest.main(system_test.main_module())

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/dfa5fd46/tests/system_tests_protocol_family.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_protocol_family.py b/tests/system_tests_protocol_family.py
index 512061c..0aea0ef 100644
--- a/tests/system_tests_protocol_family.py
+++ b/tests/system_tests_protocol_family.py
@@ -19,6 +19,8 @@
 
 import unittest2 as unittest
 from proton import Message
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
 from system_test import TestCase, Qdrouterd, main_module
 from qpid_dispatch_internal.policy.policy_util import is_ipv6_enabled
 
@@ -108,35 +110,42 @@ class ProtocolFamilyTest(TestCase):
     # Without at least one test the setUpClass does not execute
     # If this test has started executing, it means that the setUpClass() has successfully executed which means that
     # the routers were able to communicate with each other successfully using the specified protocol family.
-    def test_simple_pre_settled(self):
+
+    def test_simple_send_receive(self):
 
         if not is_ipv6_enabled():
             return self.skipTest("Skipping test..IPV6 not enabled")
 
-        addr = self.routers[0].addresses[4]+"/test/1"
-        M1 = self.messenger()
-        M2 = self.messenger()
+        simple_send_receive_test = SimpleSndRecv(self.routers[0].addresses[4])
+        simple_send_receive_test.run()
+        self.assertTrue(simple_send_receive_test.message_received)
+
 
-        M1.start()
-        M2.start()
-        M2.subscribe(addr)
+class SimpleSndRecv(MessagingHandler):
+    def __init__(self, address):
+        super(SimpleSndRecv, self).__init__()
+        self.address = address
+        self.sender = None
+        self.receiver = None
+        self.conn = None
+        self.message_received = False
 
-        tm = Message()
-        rm = Message()
+    def on_start(self, event):
+        self.conn = event.container.connect(self.address)
+        self.receiver = event.container.create_receiver(self.conn, "test_addr")
+        self.sender = event.container.create_sender(self.conn, "test_addr")
 
-        tm.address = addr
-        for i in range(100):
-            tm.body = {'number': i}
-            M1.put(tm)
-        M1.send()
+    def on_sendable(self, event):
+        msg = Message(body="Hello World")
+        event.sender.send(msg)
 
-        for i in range(100):
-            M2.recv(1)
-            M2.get(rm)
-            self.assertEqual(i, rm.body['number'])
+    def on_message(self, event):
+        if "Hello World" == event.message.body:
+            self.message_received = True
+            self.conn.close()
 
-        M1.stop()
-        M2.stop()
+    def run(self):
+        Container(self).run()
 
 
 if __name__ == '__main__':


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