Rev 6156: Setup the TestingSmartServer to set a default client timeout, in http://bazaar.launchpad.net/~jameinel/bzr/drop-idle-connections-824797
John Arbash Meinel
john at arbash-meinel.com
Thu Sep 15 12:01:36 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/drop-idle-connections-824797
------------------------------------------------------------
revno: 6156
revision-id: john at arbash-meinel.com-20110915120121-w0am8xkmja3ddv5o
parent: john at arbash-meinel.com-20110915114830-zzqrsryimw2rtv8r
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: drop-idle-connections-824797
timestamp: Thu 2011-09-15 14:01:21 +0200
message:
Setup the TestingSmartServer to set a default client timeout,
which is suitable for the test suite case.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_server.py'
--- a/bzrlib/tests/test_server.py 2011-09-15 11:12:30 +0000
+++ b/bzrlib/tests/test_server.py 2011-09-15 12:01:21 +0000
@@ -600,6 +600,8 @@
self._serve_one_request(server_protocol)
+_DEFAULT_TESTING_CLIENT_TIMEOUT = 4.0
+
class TestingSmartServer(TestingThreadingTCPServer, server.SmartTCPServer):
def __init__(self, server_address, request_handler_class,
@@ -607,7 +609,8 @@
TestingThreadingTCPServer.__init__(self, server_address,
request_handler_class)
server.SmartTCPServer.__init__(self, backing_transport,
- root_client_path)
+ root_client_path, client_timeout=_DEFAULT_TESTING_CLIENT_TIMEOUT)
+
def serve(self):
self.run_server_started_hooks()
try:
=== modified file 'bzrlib/tests/test_test_server.py'
--- a/bzrlib/tests/test_test_server.py 2011-02-08 16:26:23 +0000
+++ b/bzrlib/tests/test_test_server.py 2011-09-15 12:01:21 +0000
@@ -81,7 +81,7 @@
class TestTCPServerInAThread(tests.TestCase):
- scenarios = [
+ scenarios = [
(name, {'server_class': getattr(test_server, name)})
for name in
('TestingTCPServer', 'TestingThreadingTCPServer')]
@@ -218,3 +218,16 @@
# The connection wasn't served properly but the exception should have
# been swallowed.
server.pending_exception()
+
+
+class TestTestingSmartServer(tests.TestCase):
+
+ def test_sets_client_timeout(self):
+ server = test_server.TestingSmartServer(('localhost', 0), None, None,
+ root_client_path='/no-such-client/path')
+ self.assertEqual(test_server._DEFAULT_TESTING_CLIENT_TIMEOUT,
+ server._client_timeout)
+ sock = socket.socket()
+ h = server._create_handler(sock)
+ self.assertEqual(test_server._DEFAULT_TESTING_CLIENT_TIMEOUT,
+ h._client_timeout)
More information about the bazaar-commits
mailing list