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