mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Increase shutdown_timeout for the websocket test server which hopefully fixes the conn reset errors on travis
This commit is contained in:
parent
a9879c63fd
commit
c4905e4d99
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
from __future__ import (unicode_literals, division, absolute_import,
|
from __future__ import (unicode_literals, division, absolute_import,
|
||||||
print_function)
|
print_function)
|
||||||
import socket, os, struct, errno
|
import socket, os, struct
|
||||||
from base64 import standard_b64encode
|
from base64 import standard_b64encode
|
||||||
from collections import deque, namedtuple
|
from collections import deque, namedtuple
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@ -148,7 +148,7 @@ class WSClient(object):
|
|||||||
class WSTestServer(TestServer):
|
class WSTestServer(TestServer):
|
||||||
|
|
||||||
def __init__(self, handler):
|
def __init__(self, handler):
|
||||||
TestServer.__init__(self, None)
|
TestServer.__init__(self, None, shutdown_timeout=0.5)
|
||||||
from calibre.srv.http_response import create_http_handler
|
from calibre.srv.http_response import create_http_handler
|
||||||
self.loop.handler = create_http_handler(websocket_handler=handler())
|
self.loop.handler = create_http_handler(websocket_handler=handler())
|
||||||
|
|
||||||
@ -214,51 +214,41 @@ class WebSocketTest(BaseTest):
|
|||||||
fragments = 'Hello-µ@ßöä üàá-UTF-8!!'.split()
|
fragments = 'Hello-µ@ßöä üàá-UTF-8!!'.split()
|
||||||
nc = struct.pack(b'!H', NORMAL_CLOSE)
|
nc = struct.pack(b'!H', NORMAL_CLOSE)
|
||||||
|
|
||||||
def ic_test(*args, **kwargs):
|
|
||||||
try:
|
|
||||||
simple_test(*args, **kwargs)
|
|
||||||
except socket.error as err:
|
|
||||||
if err.errno not in (errno.EPIPE, errno.ECONNRESET):
|
|
||||||
# This is raised on OS X occassionally, when the server
|
|
||||||
# closes the connection before the client has finished
|
|
||||||
# writing all data.
|
|
||||||
raise
|
|
||||||
|
|
||||||
with server.silence_log:
|
with server.silence_log:
|
||||||
for rsv in xrange(1, 7):
|
for rsv in xrange(1, 7):
|
||||||
ic_test([{'rsv':rsv, 'opcode':BINARY}], [], close_code=PROTOCOL_ERROR, send_close=False)
|
simple_test([{'rsv':rsv, 'opcode':BINARY}], [], close_code=PROTOCOL_ERROR, send_close=False)
|
||||||
for opcode in (3, 4, 5, 6, 7, 11, 12, 13, 14, 15):
|
for opcode in (3, 4, 5, 6, 7, 11, 12, 13, 14, 15):
|
||||||
ic_test([{'opcode':opcode}], [], close_code=PROTOCOL_ERROR, send_close=False)
|
simple_test([{'opcode':opcode}], [], close_code=PROTOCOL_ERROR, send_close=False)
|
||||||
|
|
||||||
for opcode in (PING, PONG):
|
for opcode in (PING, PONG):
|
||||||
ic_test([
|
simple_test([
|
||||||
{'opcode':opcode, 'payload':'f1', 'fin':0}, {'opcode':opcode, 'payload':'f2'}
|
{'opcode':opcode, 'payload':'f1', 'fin':0}, {'opcode':opcode, 'payload':'f2'}
|
||||||
], close_code=PROTOCOL_ERROR, send_close=False)
|
], close_code=PROTOCOL_ERROR, send_close=False)
|
||||||
ic_test([(CLOSE, nc + b'x'*124)], send_close=False, close_code=PROTOCOL_ERROR)
|
simple_test([(CLOSE, nc + b'x'*124)], send_close=False, close_code=PROTOCOL_ERROR)
|
||||||
|
|
||||||
for fin in (0, 1):
|
for fin in (0, 1):
|
||||||
ic_test([{'opcode':0, 'fin': fin, 'payload':b'non-continuation frame'}, 'some text'], close_code=PROTOCOL_ERROR, send_close=False)
|
simple_test([{'opcode':0, 'fin': fin, 'payload':b'non-continuation frame'}, 'some text'], close_code=PROTOCOL_ERROR, send_close=False)
|
||||||
|
|
||||||
ic_test([
|
simple_test([
|
||||||
{'opcode':TEXT, 'payload':fragments[0], 'fin':0}, {'opcode':CONTINUATION, 'payload':fragments[1]}, {'opcode':0, 'fin':0}
|
{'opcode':TEXT, 'payload':fragments[0], 'fin':0}, {'opcode':CONTINUATION, 'payload':fragments[1]}, {'opcode':0, 'fin':0}
|
||||||
], [''.join(fragments)], close_code=PROTOCOL_ERROR, send_close=False)
|
], [''.join(fragments)], close_code=PROTOCOL_ERROR, send_close=False)
|
||||||
|
|
||||||
ic_test([
|
simple_test([
|
||||||
{'opcode':TEXT, 'payload':fragments[0], 'fin':0}, {'opcode':TEXT, 'payload':fragments[1]},
|
{'opcode':TEXT, 'payload':fragments[0], 'fin':0}, {'opcode':TEXT, 'payload':fragments[1]},
|
||||||
], close_code=PROTOCOL_ERROR, send_close=False)
|
], close_code=PROTOCOL_ERROR, send_close=False)
|
||||||
|
|
||||||
frags = []
|
frags = []
|
||||||
for payload in (b'\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5', b'\xed\xa0\x80', b'\x80\x65\x64\x69\x74\x65\x64'):
|
for payload in (b'\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5', b'\xed\xa0\x80', b'\x80\x65\x64\x69\x74\x65\x64'):
|
||||||
frags.append({'opcode':(CONTINUATION if frags else TEXT), 'fin':1 if len(frags) == 2 else 0, 'payload':payload})
|
frags.append({'opcode':(CONTINUATION if frags else TEXT), 'fin':1 if len(frags) == 2 else 0, 'payload':payload})
|
||||||
ic_test(frags, close_code=INCONSISTENT_DATA, send_close=False)
|
simple_test(frags, close_code=INCONSISTENT_DATA, send_close=False)
|
||||||
|
|
||||||
frags, q = [], b'\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5\xed\xa0\x80\x80\x65\x64\x69\x74\x65\x64'
|
frags, q = [], b'\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5\xed\xa0\x80\x80\x65\x64\x69\x74\x65\x64'
|
||||||
for i, b in enumerate(q):
|
for i, b in enumerate(q):
|
||||||
frags.append({'opcode':(TEXT if i == 0 else CONTINUATION), 'fin':1 if i == len(q)-1 else 0, 'payload':b})
|
frags.append({'opcode':(TEXT if i == 0 else CONTINUATION), 'fin':1 if i == len(q)-1 else 0, 'payload':b})
|
||||||
ic_test(frags, close_code=INCONSISTENT_DATA, send_close=False)
|
simple_test(frags, close_code=INCONSISTENT_DATA, send_close=False)
|
||||||
|
|
||||||
for q in (b'\xce', b'\xce\xba\xe1'):
|
for q in (b'\xce', b'\xce\xba\xe1'):
|
||||||
ic_test([{'opcode':TEXT, 'payload':q}], close_code=INCONSISTENT_DATA, send_close=False)
|
simple_test([{'opcode':TEXT, 'payload':q}], close_code=INCONSISTENT_DATA, send_close=False)
|
||||||
|
|
||||||
simple_test([
|
simple_test([
|
||||||
{'opcode':TEXT, 'payload':fragments[0], 'fin':0}, {'opcode':CONTINUATION, 'payload':fragments[1]}
|
{'opcode':TEXT, 'payload':fragments[0], 'fin':0}, {'opcode':CONTINUATION, 'payload':fragments[1]}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user