qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1627383 - in /qpid/dispatch/trunk/tests: system_test.py system_tests_management.py system_tests_one_router.py system_tests_two_routers.py
Date Wed, 24 Sep 2014 18:16:45 GMT
Author: aconway
Date: Wed Sep 24 18:16:45 2014
New Revision: 1627383

URL: http://svn.apache.org/r1627383
Log:
NO-JIRA: Fix "subscription-ready" check for system tests.

Previously was pumping messenger work queue to check for subscription ready.
This has stopped working and was a dodgy hack anyway, instead wait till the
subscription has a valid address.

Cleaned up a bunch of unnecessary flush() calls.

Modified:
    qpid/dispatch/trunk/tests/system_test.py
    qpid/dispatch/trunk/tests/system_tests_management.py
    qpid/dispatch/trunk/tests/system_tests_one_router.py
    qpid/dispatch/trunk/tests/system_tests_two_routers.py

Modified: qpid/dispatch/trunk/tests/system_test.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_test.py?rev=1627383&r1=1627382&r2=1627383&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_test.py (original)
+++ qpid/dispatch/trunk/tests/system_test.py Wed Sep 24 18:16:45 2014
@@ -441,38 +441,19 @@ class Qpidd(Process):
     def wait_ready(self):
         wait_port(self.port)
 
-# Decorator to add an optional flush argument to a method, defaulting to
-# the _flush value for the messenger.
-def flush_arg(method):
-    """Decorator for Messenger methods that adds an optional flush argument,
-    defaulting to the Messenger default"""
-    def wrapper(self, *args, **kwargs):
-        """Wrapper that adds flush argument"""
-        flush = self._flush # pylint: disable=protected-access
-        if 'flush' in kwargs:
-            flush = kwargs['flush']
-            del kwargs['flush']
-        r = method(self, *args, **kwargs)
-        if flush:
-            self.flush()
-        return r
-    return wrapper
-
 class Messenger(proton.Messenger): # pylint: disable=too-many-public-methods
     """Convenience additions to proton.Messenger"""
 
-    def __init__(self, name=None, timeout=DEFAULT_TIMEOUT, blocking=True, flush=False):
+    def __init__(self, name=None, timeout=DEFAULT_TIMEOUT, blocking=True):
         super(Messenger, self).__init__(name)
         self.timeout = timeout
         self.blocking = blocking
-        self._flush = flush
 
     def flush(self):
         """Call work() till there is no work left."""
         while self.work(0.1):
             pass
 
-    @flush_arg
     def fetch(self, accept=True):
         """Fetch a single message"""
         msg = Message()
@@ -482,8 +463,11 @@ class Messenger(proton.Messenger): # pyl
             self.accept()
         return msg
 
-    put = flush_arg(proton.Messenger.put)
-    subscribe = flush_arg(proton.Messenger.subscribe)
+    def subscribe(self, source, **retry_args):
+        """Do a proton.Messenger.subscribe and wait till the address is available."""
+        subscription = super(Messenger, self).subscribe(source)
+        assert retry(lambda: subscription.address, **retry_args) # Wait for address
+        return subscription
 
 class Tester(object):
     """Tools for use by TestCase

Modified: qpid/dispatch/trunk/tests/system_tests_management.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_management.py?rev=1627383&r1=1627382&r2=1627383&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_management.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_management.py Wed Sep 24 18:16:45 2014
@@ -141,7 +141,7 @@ class ManagementTest(system_test.TestCas
 
     def test_create_fixed_address(self):
         self.assert_create_ok(FIXED_ADDRESS, 'fixed1', dict(prefix='fixed1'))
-        msgr = self.messenger(flush=True)
+        msgr = self.messenger()
         address = self.router.addresses[0]+'/fixed1'
         msgr.subscribe(address)
         msgr.put(message(address=address, body='hello'))
@@ -172,7 +172,7 @@ class ManagementTest(system_test.TestCas
 
         # Send a message through self.router, verify it goes via wp_router
         address=self.router.addresses[0]+"/foo"
-        mr = self.messenger(flush=True)
+        mr = self.messenger()
         mr.subscribe(address)
         messages = ['a', 'b', 'c']
         for m in messages:

Modified: qpid/dispatch/trunk/tests/system_tests_one_router.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_one_router.py?rev=1627383&r1=1627382&r2=1627383&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_one_router.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_one_router.py Wed Sep 24 18:16:45 2014
@@ -30,7 +30,7 @@ class RouterTest(TestCase):
         super(RouterTest, cls).setUpClass()
         name = "test-router"
         config = Qdrouterd.Config([
-            ('log', {'module':'DEFAULT', 'level':'info', 'output':name+".log"}),
+            ('log', {'module':'DEFAULT', 'level':'trace', 'output':name+".log"}),
             ('container', {'worker-threads': 4, 'container-name': 'Qpid.Dispatch.Router.A'}),
             ('router', {'mode': 'standalone', 'router-id': 'QDR'}),
             ('listener', {'port': cls.tester.get_port()}),
@@ -68,7 +68,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -105,9 +105,9 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -159,9 +159,9 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -210,7 +210,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -245,7 +245,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -284,7 +284,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -364,7 +364,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -422,7 +422,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -530,7 +530,7 @@ class RouterTest(TestCase):
         M.timeout = 2.0
         M.start()
         M.route("amqp:/*", self.address+"/$1")
-        sub = M.subscribe("amqp:/#", flush=True)
+        sub = M.subscribe("amqp:/#")
         reply = sub.address
 
         request  = Message()
@@ -585,7 +585,7 @@ class RouterTest(TestCase):
         M.timeout = 2.0
         M.start()
         M.route("amqp:/*", self.address+"/$1")
-        sub = M.subscribe("amqp:/#", flush=True)
+        sub = M.subscribe("amqp:/#")
         reply = sub.address
 
         request  = Message()
@@ -667,7 +667,7 @@ class RouterTest(TestCase):
         M.timeout = 2.0
         M.start()
         M.route("amqp:/*", self.address+"/$1")
-        sub = M.subscribe("amqp:/#", flush=True)
+        sub = M.subscribe("amqp:/#")
         reply = sub.address
 
         request  = Message()
@@ -736,7 +736,7 @@ class RouterTest(TestCase):
         M.timeout = 2.0
         M.start()
         M.route("amqp:/*", self.address+"/$1")
-        sub = M.subscribe("amqp:/#", flush=True)
+        sub = M.subscribe("amqp:/#")
         reply = sub.address
 
         request  = Message()
@@ -770,7 +770,7 @@ class RouterTest(TestCase):
         M.timeout = 2.0
         M.start()
         M.route("amqp:/*", self.address+"/$1")
-        sub = M.subscribe("amqp:/#", flush=True)
+        sub = M.subscribe("amqp:/#")
         reply = sub.address
 
         request  = Message()
@@ -810,9 +810,9 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -858,9 +858,9 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -913,9 +913,9 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -962,7 +962,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
 
         tm = Message()
         rm = Message()

Modified: qpid/dispatch/trunk/tests/system_tests_two_routers.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_two_routers.py?rev=1627383&r1=1627382&r2=1627383&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_two_routers.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_two_routers.py Wed Sep 24 18:16:45 2014
@@ -76,7 +76,7 @@ class RouterTest(TestCase):
         M1.route("amqp:/*", self.routers[0].addresses[0]+"/$1")
         M2.route("amqp:/*", self.routers[1].addresses[0]+"/$1")
 
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
 
         tm = Message()
         rm = Message()
@@ -119,9 +119,9 @@ class RouterTest(TestCase):
         M2.start()
         M3.start()
         M4.start()
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
         self.routers[0].wait_address("pre_settled/multicast/1", 1, 1)
 
         tm = Message()
@@ -179,9 +179,9 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
         self.routers[0].wait_address("pre_settled/multicast/2", 1, 1)
 
         tm = Message()
@@ -234,7 +234,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
         self.routers[0].wait_address("settled/senderfirst/1", 0, 1)
 
         tm = Message()
@@ -278,7 +278,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
         self.routers[0].wait_address("unsettled/2", 0, 1)
 
         tm = Message()
@@ -363,7 +363,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
         self.routers[0].wait_address("three_ack/1", 0, 1)
 
         tm = Message()
@@ -425,7 +425,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
         self.routers[0].wait_address("ma/1", 0, 1)
 
         tm = Message()
@@ -513,9 +513,9 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
         self.routers[0].wait_address("multicast/1", 1, 1)
 
         tm = Message()
@@ -576,9 +576,9 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
         self.routers[0].wait_address("closest/1", 1, 1)
 
         tm = Message()
@@ -629,8 +629,8 @@ class RouterTest(TestCase):
         M3.start()
         M4.start()
 
-        M2.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M4.subscribe(addr)
         self.routers[0].wait_address("closest/2", 0, 1)
 
         tm = Message()
@@ -684,9 +684,9 @@ class RouterTest(TestCase):
         M2.start()
         M3.start()
         M4.start()
-        M2.subscribe(addr, flush=True)
-        M3.subscribe(addr, flush=True)
-        M4.subscribe(addr, flush=True)
+        M2.subscribe(addr)
+        M3.subscribe(addr)
+        M4.subscribe(addr)
         self.routers[0].wait_address("spread/1", 1, 1)
 
         tm = Message()
@@ -755,7 +755,7 @@ class RouterTest(TestCase):
 
         M1.start()
         M2.start()
-        M2.subscribe(addr, flush=True)
+        M2.subscribe(addr)
         self.routers[0].wait_address("toov/1", 0, 1)
 
         tm = Message()



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


Mime
View raw message