1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
From: YOKOTA Hiroshi <yokota.hgml@gmail.com>
Date: Fri, 17 Apr 2020 20:10:46 +0900
Subject: Extend timeout limit
Forwarded: not-needed
Some non-x86 architecture is much slower than x86.
Add some more time to wait test results.
---
src/calibre/srv/tests/base.py | 2 +-
src/calibre/srv/tests/http.py | 16 ++++++++--------
src/calibre/srv/tests/loop.py | 4 ++--
src/calibre/test_build.py | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/calibre/srv/tests/base.py b/src/calibre/srv/tests/base.py
index b57abd5..77b3614 100644
--- a/src/calibre/srv/tests/base.py
+++ b/src/calibre/srv/tests/base.py
@@ -119,7 +119,7 @@ class TestServer(Thread):
self.log = self.loop.log
def setup_defaults(self, kwargs):
- kwargs['shutdown_timeout'] = kwargs.get('shutdown_timeout', 0.1)
+ kwargs['shutdown_timeout'] = kwargs.get('shutdown_timeout', 10)
kwargs['listen_on'] = kwargs.get('listen_on', 'localhost')
kwargs['port'] = kwargs.get('port', 0)
kwargs['userdb'] = kwargs.get('userdb', ':memory:')
diff --git a/src/calibre/srv/tests/http.py b/src/calibre/srv/tests/http.py
index ecdd024..4f7e263 100644
--- a/src/calibre/srv/tests/http.py
+++ b/src/calibre/srv/tests/http.py
@@ -100,7 +100,7 @@ class TestHTTP(BaseTest):
def handler(data):
return data.lang_code + data._('Unknown')
- with TestServer(handler, timeout=1) as server:
+ with TestServer(handler, timeout=100) as server:
conn = server.connect()
def test(al, q):
@@ -159,7 +159,7 @@ class TestHTTP(BaseTest):
conn._HTTPConnection__state = http_client._CS_REQ_SENT
return conn.getresponse()
- base_timeout = 0.5 if is_ci else 0.1
+ base_timeout = 50 if is_ci else 10
with TestServer(handler, timeout=base_timeout, max_header_line_size=100./1024, max_request_body_size=100./(1024*1024)) as server:
conn = server.connect()
@@ -285,7 +285,7 @@ class TestHTTP(BaseTest):
conn = server.connect()
# Test closing
- server.loop.opts.timeout = 10 # ensure socket is not closed because of timeout
+ server.loop.opts.timeout = 1000 # ensure socket is not closed because of timeout
conn.request('GET', '/close', headers={'Connection':'close'})
r = conn.getresponse()
self.ae(r.status, 200), self.ae(r.read(), b'close')
@@ -298,8 +298,8 @@ class TestHTTP(BaseTest):
self.assertIsNone(conn.sock)
# Test timeout
- server.loop.opts.timeout = 0.1
- conn = server.connect(timeout=1)
+ server.loop.opts.timeout = 10
+ conn = server.connect(timeout=100)
conn.request('GET', '/something')
r = conn.getresponse()
self.ae(r.status, 200), self.ae(r.read(), b'something')
@@ -313,7 +313,7 @@ class TestHTTP(BaseTest):
def handler(conn):
return conn.generate_static_output('test', lambda: ''.join(conn.path))
with NamedTemporaryFile(suffix='test.epub') as f, open(P('localization/locales.zip'), 'rb') as lf, \
- TestServer(handler, timeout=1, compress_min_size=0) as server:
+ TestServer(handler, timeout=100, compress_min_size=0) as server:
fdata = (string.ascii_letters * 100).encode('ascii')
f.write(fdata), f.seek(0)
@@ -414,7 +414,7 @@ class TestHTTP(BaseTest):
lf.seek(0)
data = lf.read()
server.change_handler(lambda conn: lf)
- conn = server.connect(timeout=1)
+ conn = server.connect(timeout=100)
conn.request('GET', '/test')
r = conn.getresponse()
self.ae(r.status, http_client.OK)
@@ -423,7 +423,7 @@ class TestHTTP(BaseTest):
self.ae(hashlib.sha1(data).hexdigest(), hashlib.sha1(rdata).hexdigest())
self.ae(data, rdata)
time_taken = monotonic() - start_time
- self.assertLess(time_taken, 1, 'Large file transfer took too long')
+ self.assertLess(time_taken, 100, 'Large file transfer took too long')
# }}}
diff --git a/src/calibre/srv/tests/loop.py b/src/calibre/srv/tests/loop.py
index c0101c8..7cf02a6 100644
--- a/src/calibre/srv/tests/loop.py
+++ b/src/calibre/srv/tests/loop.py
@@ -113,8 +113,8 @@ class LoopTest(BaseTest):
from calibre.srv.bonjour import BonJour
b = BonJour(wait_for_stop=False)
- with TestServer(lambda data:(data.path[0] + data.read()), plugins=(b,), shutdown_timeout=5) as server:
- self.assertTrue(b.started.wait(5), 'BonJour not started')
+ with TestServer(lambda data:(data.path[0] + data.read()), plugins=(b,), shutdown_timeout=500) as server:
+ self.assertTrue(b.started.wait(50), 'BonJour not started')
self.ae(b.advertised_port, server.address[1])
service = b.services[0]
self.ae(service.type, '_calibre._tcp.local.')
diff --git a/src/calibre/test_build.py b/src/calibre/test_build.py
index 3658deb..06a9357 100644
--- a/src/calibre/test_build.py
+++ b/src/calibre/test_build.py
@@ -409,7 +409,7 @@ class BuildTest(unittest.TestCase):
p.titleChanged.connect(do_webengine_test)
p.renderProcessTerminated.connect(render_process_crashed)
p.runJavaScript(f'document.title = "test-run-{os.getpid()}";')
- timeout = 10
+ timeout = 1000
QTimer.singleShot(timeout * 1000, lambda: QApplication.instance().quit())
QApplication.instance().exec()
self.assertTrue(hasattr(callback, 'result'), f'Qt WebEngine failed to run in {timeout} seconds')
|