MCPcopy Create free account
hub / github.com/apache/qpid-proton / testIdleTimeout

Method testIdleTimeout

python/tests/proton_tests/engine.py:2176–2222  ·  view source on GitHub ↗

Verify that a Connection is terminated properly when Idle frames do not arrive in a timely manner.

(self)

Source from the content-addressed store, hash-verified

2174 server.stop()
2175
2176 def testIdleTimeout(self):
2177 """ Verify that a Connection is terminated properly when Idle frames do not
2178 arrive in a timely manner.
2179 """
2180 idle_timeout = self.delay
2181 server = common.TestServer(idle_timeout=idle_timeout)
2182 server.start()
2183
2184 class Program:
2185
2186 def on_reactor_init(self, event):
2187 self.conn = event.reactor.connection()
2188 self.conn.hostname = "%s:%s" % (server.host, server.port)
2189 self.conn.open()
2190 self.remote_condition = None
2191 self.old_count = None
2192 # verify the connection stays up even if we don't explicitly send stuff
2193 # wait up to 3x the idle timeout
2194 event.reactor.schedule(3 * idle_timeout, self)
2195
2196 def on_connection_bound(self, event):
2197 self.transport = event.transport
2198
2199 def on_connection_remote_open(self, event):
2200 self.old_count = event.transport.frames_output
2201
2202 def on_connection_remote_close(self, event):
2203 assert self.conn.remote_condition
2204 assert self.conn.remote_condition.name == "amqp:resource-limit-exceeded"
2205 self.remote_condition = self.conn.remote_condition
2206
2207 def on_timer_task(self, event):
2208 assert self.conn.state == (Endpoint.LOCAL_ACTIVE | Endpoint.REMOTE_ACTIVE), "Connection terminated"
2209 assert self.conn.transport.frames_output > self.old_count, "No idle frames sent"
2210
2211 # now wait to explicitly cause the other side to expire:
2212 suspend_time = 3 * idle_timeout
2213 if os.name == "nt":
2214 # On windows, the full delay gets too close to the graceful/hard close tipping point
2215 suspend_time = 2.5 * idle_timeout
2216 sleep(suspend_time)
2217
2218 p = Program()
2219 Container(p).run()
2220 assert p.remote_condition
2221 assert p.remote_condition.name == "amqp:resource-limit-exceeded"
2222 server.stop()
2223
2224
2225class NoValue:

Callers

nothing calls this directly

Calls 5

startMethod · 0.95
stopMethod · 0.95
ContainerClass · 0.90
ProgramClass · 0.70
runMethod · 0.45

Tested by

no test coverage detected