You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2015/02/13 15:33:50 UTC

[2/3] qpid-proton git commit: removed driver API and bindings

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4b53bfca/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 0fae2b8..55c22f9 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -21,6 +21,7 @@ import os, common, gc
 from time import time, sleep
 from proton import *
 from common import pump
+from proton.reactors import Reactor
 
 # older versions of gc do not provide the garbage list
 if not hasattr(gc, "garbage"):
@@ -1844,45 +1845,32 @@ class ServerTest(Test):
     """
     if "java" in sys.platform:
       raise Skipped()
-    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
-    self.cxtr.sasl().mechanisms("ANONYMOUS")
-    self.conn = Connection()
-    self.cxtr.connection = self.conn
-    self.conn.open()
-    #self.session = self.conn.session()
-    #self.session.open()
-    #self.link = self.session.sender("test-sender")
-    #self.link.open()
-
-    # wait for the connection to come up
-
-    deadline = time() + self.timeout
-    while self.conn.state != (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE) \
-          and time() <= deadline:
-      self.cxtr.process()
-      self.driver.wait(0.001)
-      self.cxtr.process()
-
-    assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection failed"
-
-    # wait up to 3x the idle timeout
-    old_count = self.cxtr.transport.frames_input
-    duration = 3 * idle_timeout_secs
-    deadline = time() + duration
-    while time() <= deadline:
-      self.cxtr.process()
-      self.driver.wait(0.001)
-      self.cxtr.process()
-
-    assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection terminated"
-    assert self.cxtr.transport.frames_input > old_count, "No idle frames received"
-
-    self.server.stop()
+    idle_timeout = self.delay
+    server = common.TestServer()
+    server.start()
+
+    class Program:
+
+      def on_reactor_init(self, event):
+        self.conn = event.reactor.connection()
+        self.conn.hostname = "%s:%s" % (server.host, server.port)
+        self.conn.open()
+        self.old_count = None
+        event.reactor.schedule(3 * idle_timeout, self)
+
+      def on_connection_bound(self, event):
+        event.transport.idle_timeout = idle_timeout
+
+      def on_connection_remote_open(self, event):
+        self.old_count = event.transport.frames_input
+
+      def on_timer_task(self, event):
+        assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection terminated"
+        assert self.conn.transport.frames_input > self.old_count, "No idle frames received"
+        self.conn.close()
+
+    Reactor(Program()).run()
+    server.stop()
 
   def testIdleTimeout(self):
     """ Verify that a Connection is terminated properly when Idle frames do not
@@ -1890,55 +1878,40 @@ class ServerTest(Test):
     """
     if "java" in sys.platform:
       raise Skipped()
-    idle_timeout_secs = self.delay
-    self.server = common.TestServerDrain(idle_timeout=idle_timeout_secs)
-    self.server.start()
-    self.driver = Driver()
-    self.cxtr = self.driver.connector(self.server.host, self.server.port)
-    self.cxtr.sasl().mechanisms("ANONYMOUS")
-    self.conn = Connection()
-    self.cxtr.connection = self.conn
-    self.conn.open()
-
-    # wait for the connection to come up
-
-    deadline = time() + self.timeout
-    while self.conn.state != (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE) \
-          and time() <= deadline:
-      self.cxtr.process()
-      self.driver.wait(self.timeout)
-      self.cxtr.process()
-
-    assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection failed"
-
-    # verify the connection stays up even if we don't explicitly send stuff
-    # wait up to 3x the idle timeout
-    old_count = self.cxtr.transport.frames_output
-    duration = 3 * idle_timeout_secs
-    deadline = time() + duration
-    while time() <= deadline:
-      self.cxtr.process()
-      self.driver.wait(10 * duration)
-      self.cxtr.process()
-
-    assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection terminated"
-    assert self.cxtr.transport.frames_output > old_count, "No idle frames sent"
-
-    # now wait to explicitly cause the other side to expire:
-
-    sleep(idle_timeout_secs * 3)
-
-    # and check that the remote killed the connection:
-
-    deadline = time() + self.timeout
-    while (self.conn.state & Endpoint.REMOTE_ACTIVE) and time() <= deadline:
-      self.cxtr.process()
-      self.driver.wait(self.timeout)
-      self.cxtr.process()
-
-    assert self.conn.state & Endpoint.REMOTE_CLOSED, "Connection failed to close"
-
-    self.server.stop()
+    idle_timeout = self.delay
+    server = common.TestServer(idle_timeout=idle_timeout)
+    server.start()
+
+    class Program:
+
+      def on_reactor_init(self, event):
+        self.conn = event.reactor.connection()
+        self.conn.hostname = "%s:%s" % (server.host, server.port)
+        self.conn.open()
+        self.old_count = None
+        # verify the connection stays up even if we don't explicitly send stuff
+        # wait up to 3x the idle timeout
+        event.reactor.schedule(3 * idle_timeout, self)
+
+      def on_connection_remote_open(self, event):
+        self.old_count = event.transport.frames_output
+
+      def on_connection_remote_close(self, event):
+        assert self.conn.remote_condition
+        assert self.conn.remote_condition.name == "amqp:resource-limit-exceeded"
+
+      def on_timer_task(self, event):
+        assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection terminated"
+        assert self.conn.transport.frames_output > self.old_count, "No idle frames sent"
+
+        # now wait to explicitly cause the other side to expire:
+        sleep(3 * idle_timeout)
+
+    p = Program()
+    Reactor(p).run()
+    assert p.conn.remote_condition
+    assert p.conn.remote_condition.name == "amqp:resource-limit-exceeded"
+    server.stop()
 
 class NoValue:
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4b53bfca/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/messenger.py b/tests/python/proton_tests/messenger.py
index ba8686f..c7c7dd3 100644
--- a/tests/python/proton_tests/messenger.py
+++ b/tests/python/proton_tests/messenger.py
@@ -1046,7 +1046,7 @@ class IdleTimeoutTest(common.Test):
     idle_timeout_secs = self.delay
 
     try:
-      idle_server = common.TestServerDrain(idle_timeout=idle_timeout_secs)
+      idle_server = common.TestServer(idle_timeout=idle_timeout_secs)
       idle_server.timeout = self.timeout
       idle_server.start()
 
@@ -1067,18 +1067,7 @@ class IdleTimeoutTest(common.Test):
         continue
 
       # confirm link is still active
-      cxtr = idle_server.driver.head_connector()
-      assert not cxtr.closed, "Connector has unexpectedly been closed"
-      conn = cxtr.connection
-      assert conn.state == (Endpoint.LOCAL_ACTIVE
-                            | Endpoint.REMOTE_ACTIVE
-                            ), "Connection has unexpectedly terminated"
-      link = conn.link_head(0)
-      while link:
-        assert link.state != (Endpoint.REMOTE_CLOSED
-                              ), "Link unexpectedly closed"
-        link = link.next(0)
-
+      assert not idle_server.conditions, idle_server.conditions
     finally:
       try:
         idle_client.stop()


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