qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1466602 - in /qpid/proton/trunk/tests/python/proton_tests: common.py engine.py soak.py
Date Wed, 10 Apr 2013 18:14:39 GMT
Author: rhs
Date: Wed Apr 10 18:14:38 2013
New Revision: 1466602

URL: http://svn.apache.org/r1466602
Log:
added profile, delay, and timeout parameters for test suite; adjusted defaults for soak tests;
made idle and keepalive tests use newly added delay and timeout parameters

Modified:
    qpid/proton/trunk/tests/python/proton_tests/common.py
    qpid/proton/trunk/tests/python/proton_tests/engine.py
    qpid/proton/trunk/tests/python/proton_tests/soak.py

Modified: qpid/proton/trunk/tests/python/proton_tests/common.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/python/proton_tests/common.py?rev=1466602&r1=1466601&r2=1466602&view=diff
==============================================================================
--- qpid/proton/trunk/tests/python/proton_tests/common.py (original)
+++ qpid/proton/trunk/tests/python/proton_tests/common.py Wed Apr 10 18:14:38 2013
@@ -24,24 +24,24 @@ from proton import Driver, Connection, S
 
 
 def free_tcp_ports(count=1):
-    """ return a list of 'count' TCP ports that are free to used (ie. unbound)
-    """
-    retry = 0
-    ports = []
-    sockets = []
-    while len(ports) != count:
-        port = randint(49152, 65535)
-        sockets.append( socket( AF_INET, SOCK_STREAM ) )
-        try:
-            sockets[-1].bind( ("0.0.0.0", port ) )
-            ports.append( port )
-            retry = 0
-        except:
-            retry += 1
-            assert retry != 100, "No free sockets available for test!"
-    for s in sockets:
-        s.close()
-    return ports
+  """ return a list of 'count' TCP ports that are free to used (ie. unbound)
+  """
+  retry = 0
+  ports = []
+  sockets = []
+  while len(ports) != count:
+    port = randint(49152, 65535)
+    sockets.append( socket( AF_INET, SOCK_STREAM ) )
+    try:
+      sockets[-1].bind( ("0.0.0.0", port ) )
+      ports.append( port )
+      retry = 0
+    except:
+      retry += 1
+      assert retry != 100, "No free sockets available for test!"
+  for s in sockets:
+    s.close()
+  return ports
 
 
 class Test:
@@ -49,6 +49,28 @@ class Test:
   def __init__(self, name):
     self.name = name
 
+  def configure(self, config):
+    self.config = config
+
+  def default(self, name, value, **profiles):
+    default = value
+    profile = self.config.defines.get("profile")
+    if profile:
+      default = profiles.get(profile, default)
+    return self.config.defines.get(name, default)
+
+  @property
+  def delay(self):
+    return float(self.default("delay", "1", fast="0.1"))
+
+  @property
+  def timeout(self):
+    return float(self.default("timeout", "60", fast="10"))
+
+  @property
+  def verbose(self):
+    return int(self.default("verbose", 0))
+
 class Skipped(Exception):
   skipped = True
 

Modified: qpid/proton/trunk/tests/python/proton_tests/engine.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/python/proton_tests/engine.py?rev=1466602&r1=1466601&r2=1466602&view=diff
==============================================================================
--- qpid/proton/trunk/tests/python/proton_tests/engine.py (original)
+++ qpid/proton/trunk/tests/python/proton_tests/engine.py Wed Apr 10 18:14:38 2013
@@ -1346,12 +1346,12 @@ class ServerTest(Test):
   def testKeepalive(self):
     """ Verify that idle frames are sent to keep a Connection alive
     """
-    idle_timeout_secs = 1
+    idle_timeout_secs = self.delay
     self.server = common.TestServerDrain()
     self.server.start()
     self.driver = Driver()
     self.cxtr = self.driver.connector(self.server.host, self.server.port)
-    self.cxtr.transport.idle_timeout = idle_timeout_secs * 1000  #msecs
+    self.cxtr.transport.idle_timeout = int(idle_timeout_secs * 1000)  #msecs
     self.cxtr.sasl().mechanisms("ANONYMOUS")
     self.cxtr.sasl().client()
     self.conn = Connection()
@@ -1364,9 +1364,9 @@ class ServerTest(Test):
 
     # wait for the connection to come up
 
-    timeout = time() + 10
+    deadline = time() + self.timeout
     while self.conn.state != (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE) \
-          and time() <= timeout:
+          and time() <= deadline:
       self.cxtr.process()
       self.driver.wait(1)
       self.cxtr.process()
@@ -1376,10 +1376,10 @@ class ServerTest(Test):
     # wait up to 3x the idle timeout
     old_count = self.cxtr.transport.frames_input
     duration = 3 * idle_timeout_secs
-    timeout = time() + duration
-    while time() <= timeout:
+    deadline = time() + duration
+    while time() <= deadline:
       self.cxtr.process()
-      self.driver.wait(10 * duration * 1000)
+      self.driver.wait(1)
       self.cxtr.process()
 
     assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection
terminated"
@@ -1391,8 +1391,8 @@ class ServerTest(Test):
     """ Verify that a Connection is terminated properly when Idle frames do not
     arrive in a timely manner.
     """
-    idle_timeout_secs = 1
-    self.server = common.TestServerDrain(idle_timeout=idle_timeout_secs * 1000)
+    idle_timeout_secs = self.delay
+    self.server = common.TestServerDrain(idle_timeout=int(idle_timeout_secs * 1000))
     self.server.start()
     self.driver = Driver()
     self.cxtr = self.driver.connector(self.server.host, self.server.port)
@@ -1404,11 +1404,11 @@ class ServerTest(Test):
 
     # wait for the connection to come up
 
-    timeout = time() + 10
+    deadline = time() + self.timeout
     while self.conn.state != (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE) \
-          and time() <= timeout:
+          and time() <= deadline:
       self.cxtr.process()
-      self.driver.wait(10 * 1000)
+      self.driver.wait(int(self.timeout * 1000))
       self.cxtr.process()
 
     assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection
failed"
@@ -1417,10 +1417,10 @@ class ServerTest(Test):
     # wait up to 3x the idle timeout
     old_count = self.cxtr.transport.frames_output
     duration = 3 * idle_timeout_secs
-    timeout = time() + duration
-    while time() <= timeout:
+    deadline = time() + duration
+    while time() <= deadline:
       self.cxtr.process()
-      self.driver.wait(10 * duration * 1000)
+      self.driver.wait(int(10 * duration * 1000))
       self.cxtr.process()
 
     assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection
terminated"
@@ -1432,10 +1432,10 @@ class ServerTest(Test):
 
     # and check that the remote killed the connection:
 
-    timeout = time() + 10
-    while (self.conn.state & Endpoint.REMOTE_ACTIVE) and time() <= timeout:
+    deadline = time() + self.timeout
+    while (self.conn.state & Endpoint.REMOTE_ACTIVE) and time() <= deadline:
       self.cxtr.process()
-      self.driver.wait(10*1000)
+      self.driver.wait(int(self.timeout*1000))
       self.cxtr.process()
 
     assert self.conn.state & Endpoint.REMOTE_CLOSED, "Connection failed to close"

Modified: qpid/proton/trunk/tests/python/proton_tests/soak.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/python/proton_tests/soak.py?rev=1466602&r1=1466601&r2=1466602&view=diff
==============================================================================
--- qpid/proton/trunk/tests/python/proton_tests/soak.py (original)
+++ qpid/proton/trunk/tests/python/proton_tests/soak.py Wed Apr 10 18:14:38 2013
@@ -244,9 +244,47 @@ class AppTests(common.Test):
 
     def __init__(self, *args):
         common.Test.__init__(self, *args)
+        self.is_valgrind = False
 
-    def configure(self, config):
-        self.config = config.defines
+    def default(self, name, value, **kwargs):
+        if self.is_valgrind:
+            default = kwargs.get("valgrind", value)
+        else:
+            default = value
+        return common.Test.default(self, name, default, **kwargs)
+
+    @property
+    def iterations(self):
+        return int(self.default("iterations", 2, fast=1, valgrind=1))
+
+    @property
+    def send_count(self):
+        return int(self.default("send_count", 17, fast=1, valgrind=1))
+
+    @property
+    def target_count(self):
+        return int(self.default("target_count", 5, fast=1, valgrind=1))
+
+    @property
+    def send_batch(self):
+        return int(self.default("send_batch", 7, fast=1, valgrind=1))
+
+    @property
+    def forward_count(self):
+        return int(self.default("forward_count", 5, fast=1, valgrind=1))
+
+    @property
+    def port_count(self):
+        return int(self.default("port_count", 3, fast=1, valgrind=1))
+
+    @property
+    def sender_count(self):
+        return int(self.default("sender_count", 3, fast=1, valgrind=1))
+
+    def valgrind_test(self):
+        if "VALGRIND" not in os.environ:
+            raise common.Skipped("Skipping test - $VALGRIND not set.")
+        self.is_valgrind = True
 
     def setup(self):
         self.senders = []
@@ -256,7 +294,7 @@ class AppTests(common.Test):
         pass
 
     def _do_test(self, iterations=1):
-        verbose = "verbose" in self.config
+        verbose = self.verbose
 
         for R in self.receivers:
             R.start( verbose )
@@ -295,9 +333,9 @@ class MessengerTests(AppTests):
         target_count = # of targets to send to.
         send_count = # messages sent to each target
         """
-        iterations = int(self.config.get("iterations", 2))
-        send_count = int(self.config.get("send_count", 997))
-        target_count = int(self.config.get("target_count", 5))
+        iterations = self.iterations
+        send_count = self.send_count
+        target_count = self.target_count
 
         send_total = send_count * target_count
         receive_total = send_total * iterations
@@ -324,10 +362,10 @@ class MessengerTests(AppTests):
         send_count = # messages sent to each target
         send_batch - wait for replies after this many messages sent
         """
-        iterations = int(self.config.get("iterations", 2))
-        send_count = int(self.config.get("send_count", 1097))
-        target_count = int(self.config.get("target_count", 3))
-        send_batch = int(self.config.get("send_batch", 13))
+        iterations = self.iterations
+        send_count = self.send_count
+        target_count = self.target_count
+        send_batch = self.send_batch
 
         send_total = send_count * target_count
         receive_total = send_total * iterations
@@ -359,11 +397,11 @@ class MessengerTests(AppTests):
         send_batch - wait for replies after this many messages sent
         forward_count - forward to this many targets
         """
-        iterations = int(self.config.get("iterations", 2))
-        send_count = int(self.config.get("send_count", 857))
-        target_count = int(self.config.get("target_count", 3))
-        send_batch = int(self.config.get("send_batch", 11))
-        forward_count = int(self.config.get("forward_count", 3))
+        iterations = self.iterations
+        send_count = self.send_count
+        target_count = self.target_count
+        send_batch = self.send_batch
+        forward_count = self.forward_count
 
         send_total = send_count * target_count
         receive_total = send_total * iterations
@@ -411,12 +449,12 @@ class MessengerTests(AppTests):
         send_count - # of messages sent to each target
         send_batch - # of messages to send before waiting for response
         """
-        iterations = int(self.config.get("iterations", 2))
-        port_count = int(self.config.get("port_count", 3))
-        sender_count = int(self.config.get("sender_count", 11))
-        target_count = int(self.config.get("target_count", 3))
-        send_count = int(self.config.get("send_count", 101))
-        send_batch = int(self.config.get("send_batch", 17))
+        iterations = self.iterations
+        port_count = self.port_count
+        sender_count = self.sender_count
+        target_count = self.target_count
+        send_count = self.send_count
+        send_batch = self.send_batch
 
         send_total = port_count * target_count * send_count
         receive_total = send_total * sender_count * iterations
@@ -445,9 +483,7 @@ class MessengerTests(AppTests):
         self._do_oneway_test(MessengerReceiverC(), MessengerSenderC())
 
     def test_oneway_valgrind(self):
-        if "VALGRIND" not in os.environ:
-            raise common.Skipped("Skipping test - $VALGRIND not set.")
-        self.config["iterations"] = int(self.config.get("iterations", 1))
+        self.valgrind_test()
         self._do_oneway_test(MessengerReceiverValgrind(), MessengerSenderValgrind())
 
     def test_oneway_Python(self):
@@ -463,9 +499,7 @@ class MessengerTests(AppTests):
         self._do_echo_test(MessengerReceiverC(), MessengerSenderC())
 
     def test_echo_valgrind(self):
-        if "VALGRIND" not in os.environ:
-            raise common.Skipped("Skipping test - $VALGRIND not set.")
-        self.config["iterations"] = int(self.config.get("iterations", 1))
+        self.valgrind_test()
         self._do_echo_test(MessengerReceiverValgrind(), MessengerSenderValgrind())
 
     def test_echo_Python(self):
@@ -481,9 +515,7 @@ class MessengerTests(AppTests):
         self._do_relay_test(MessengerReceiverC(), MessengerReceiverC(), MessengerSenderC())
 
     def test_relay_valgrind(self):
-        if "VALGRIND" not in os.environ:
-            raise common.Skipped("Skipping test - $VALGRIND not set.")
-        self.config["iterations"] = int(self.config.get("iterations", 1))
+        self.valgrind_test()
         self._do_relay_test(MessengerReceiverValgrind(), MessengerReceiverValgrind(), MessengerSenderValgrind())
 
     def test_relay_C_Python(self):
@@ -496,9 +528,7 @@ class MessengerTests(AppTests):
         self._do_star_topology_test( MessengerReceiverC, MessengerSenderC )
 
     def test_star_topology_valgrind(self):
-        if "VALGRIND" not in os.environ:
-            raise common.Skipped("Skipping test - $VALGRIND not set.")
-        self.config["iterations"] = int(self.config.get("iterations", 1))
+        self.valgrind_test()
         self._do_star_topology_test( MessengerReceiverValgrind, MessengerSenderValgrind )
 
     def test_star_topology_Python(self):



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


Mime
View raw message