qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1509418 - /qpid/trunk/qpid/cpp/src/tests/brokertest.py
Date Thu, 01 Aug 2013 20:26:27 GMT
Author: aconway
Date: Thu Aug  1 20:26:27 2013
New Revision: 1509418

URL: http://svn.apache.org/r1509418
Log:
QPID-4327: Optimize brokertest.ready() to improve test runtimes.

Modified:
    qpid/trunk/qpid/cpp/src/tests/brokertest.py

Modified: qpid/trunk/qpid/cpp/src/tests/brokertest.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/brokertest.py?rev=1509418&r1=1509417&r2=1509418&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/brokertest.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/brokertest.py Thu Aug  1 20:26:27 2013
@@ -285,7 +285,6 @@ class Broker(Popen):
         test.cleanup_stop(self)
         self._host = "127.0.0.1"
         log.debug("Started broker %s (%s, %s)" % (self.name, self.pname, self.log))
-        self._log_ready = False
 
     def startQmf(self, handler=None):
         self.qmf_session = qmf.console.Session(handler)
@@ -363,29 +362,21 @@ class Broker(Popen):
 
     def host_port(self): return "%s:%s" % (self.host(), self.port())
 
-    def log_contains(self, str, timeout=1):
-        """Wait for str to appear in the log file up to timeout. Return true if found"""
-        return retry(lambda: find_in_file(str, self.log), timeout)
-
-    def log_ready(self):
-        """Return true if the log file exists and contains a broker ready message"""
-        if not self._log_ready:
-            self._log_ready = find_in_file("notice Broker running", self.log)
-        return self._log_ready
-
     def ready(self, timeout=30, **kwargs):
         """Wait till broker is ready to serve clients"""
-        # First make sure the broker is listening by checking the log.
-        if not retry(self.log_ready, timeout=timeout):
-            raise Exception(
-                "Timed out waiting for broker %s%s"%(self.name, error_line(self.log,5)))
-        # Create a connection and a session.
-        try:
-            c = self.connect(**kwargs)
-            try: c.session()
-            finally: c.close()
-        except Exception,e: raise RethrownException(
-            "Broker %s not responding: (%s)%s"%(self.name,e,error_line(self.log, 5)))
+        deadline = time.time()+timeout
+        while True:
+            try:
+                c = self.connect(**kwargs)
+                try:
+                    c.session()
+                    return      # All good
+                finally: c.close()
+            except Exception,e: # Retry up to timeout
+                if time.time() > deadline:
+                    raise RethrownException(
+                        "Broker %s not responding: (%s)%s"%(
+                            self.name,e,error_line(self.log, 5)))
 
 def browse(session, queue, timeout=0, transform=lambda m: m.content):
     """Return a list with the contents of each message on queue."""



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


Mime
View raw message