Tests: don't try to return response when "no_recv" is True.
This commit is contained in:
parent
8d976cac52
commit
8e1e047191
14 changed files with 30 additions and 50 deletions
|
@ -277,10 +277,9 @@ custom-header: BLAH
|
|||
|
||||
assert self.get()['status'] == 200, 'init'
|
||||
|
||||
(_, sock) = self.http(
|
||||
sock = self.http(
|
||||
b"""GET / HTTP/1.1
|
||||
""",
|
||||
start=True,
|
||||
raw=True,
|
||||
no_recv=True,
|
||||
)
|
||||
|
@ -358,14 +357,13 @@ Connection: close
|
|||
socks = []
|
||||
|
||||
for i in range(2):
|
||||
(_, sock) = self.get(
|
||||
sock = self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Delay': '3',
|
||||
'Connection': 'close',
|
||||
},
|
||||
no_recv=True,
|
||||
start=True,
|
||||
)
|
||||
|
||||
socks.append(sock)
|
||||
|
|
|
@ -1001,14 +1001,13 @@ class TestJavaApplication(TestApplicationJava):
|
|||
socks = []
|
||||
|
||||
for i in range(4):
|
||||
(_, sock) = self.get(
|
||||
sock = self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Delay': '2',
|
||||
'Connection': 'close',
|
||||
},
|
||||
no_recv=True,
|
||||
start=True,
|
||||
)
|
||||
|
||||
socks.append(sock)
|
||||
|
|
|
@ -259,14 +259,13 @@ class TestPerlApplication(TestApplicationPerl):
|
|||
socks = []
|
||||
|
||||
for i in range(4):
|
||||
(_, sock) = self.get(
|
||||
sock = self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Delay': '2',
|
||||
'Connection': 'close',
|
||||
},
|
||||
no_recv=True,
|
||||
start=True,
|
||||
)
|
||||
|
||||
socks.append(sock)
|
||||
|
|
|
@ -185,9 +185,8 @@ Content-Length: 10
|
|||
|
||||
socks = []
|
||||
for i in range(10):
|
||||
_, sock = self.post_http10(
|
||||
sock = self.post_http10(
|
||||
body=payload + str(i),
|
||||
start=True,
|
||||
no_recv=True,
|
||||
read_buffer_size=buff_size,
|
||||
)
|
||||
|
@ -248,9 +247,7 @@ Content-Length: 10
|
|||
), 'custom header 5'
|
||||
|
||||
def test_proxy_fragmented(self):
|
||||
_, sock = self.http(
|
||||
b"""GET / HTT""", raw=True, start=True, no_recv=True
|
||||
)
|
||||
sock = self.http(b"""GET / HTT""", raw=True, no_recv=True)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -266,9 +263,7 @@ Content-Length: 10
|
|||
sock.close()
|
||||
|
||||
def test_proxy_fragmented_close(self):
|
||||
_, sock = self.http(
|
||||
b"""GET / HTT""", raw=True, start=True, no_recv=True
|
||||
)
|
||||
sock = self.http(b"""GET / HTT""", raw=True, no_recv=True)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -277,9 +272,7 @@ Content-Length: 10
|
|||
sock.close()
|
||||
|
||||
def test_proxy_fragmented_body(self):
|
||||
_, sock = self.http(
|
||||
b"""GET / HTT""", raw=True, start=True, no_recv=True
|
||||
)
|
||||
sock = self.http(b"""GET / HTT""", raw=True, no_recv=True)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -306,9 +299,7 @@ Content-Length: 10
|
|||
assert resp['body'] == "X" * 30000, 'body'
|
||||
|
||||
def test_proxy_fragmented_body_close(self):
|
||||
_, sock = self.http(
|
||||
b"""GET / HTT""", raw=True, start=True, no_recv=True
|
||||
)
|
||||
sock = self.http(b"""GET / HTT""", raw=True, no_recv=True)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -398,7 +389,7 @@ Content-Length: 10
|
|||
{"pass": "applications/delayed"}, 'listeners/*:7081'
|
||||
), 'delayed configure'
|
||||
|
||||
_, sock = self.post_http10(
|
||||
sock = self.post_http10(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'Content-Length': '10000',
|
||||
|
@ -406,14 +397,13 @@ Content-Length: 10
|
|||
'X-Delay': '1',
|
||||
},
|
||||
body='0123456789' * 1000,
|
||||
start=True,
|
||||
no_recv=True,
|
||||
)
|
||||
|
||||
assert re.search('200 OK', sock.recv(100).decode()), 'first'
|
||||
sock.close()
|
||||
|
||||
_, sock = self.post_http10(
|
||||
sock = self.post_http10(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'Content-Length': '10000',
|
||||
|
@ -421,7 +411,6 @@ Content-Length: 10
|
|||
'X-Delay': '1',
|
||||
},
|
||||
body='0123456789' * 1000,
|
||||
start=True,
|
||||
no_recv=True,
|
||||
)
|
||||
|
||||
|
|
|
@ -765,14 +765,13 @@ last line: 987654321
|
|||
socks = []
|
||||
|
||||
for i in range(4):
|
||||
(_, sock) = self.get(
|
||||
sock = self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Delay': '2',
|
||||
'Connection': 'close',
|
||||
},
|
||||
no_recv=True,
|
||||
start=True,
|
||||
)
|
||||
|
||||
socks.append(sock)
|
||||
|
|
|
@ -21,10 +21,9 @@ class TestReconfigure(TestApplicationProto):
|
|||
assert 'success' in self.conf({"listeners": {}, "applications": {}})
|
||||
|
||||
def test_reconfigure(self):
|
||||
(_, sock) = self.http(
|
||||
sock = self.http(
|
||||
b"""GET / HTTP/1.1
|
||||
""",
|
||||
start=True,
|
||||
raw=True,
|
||||
no_recv=True,
|
||||
)
|
||||
|
@ -42,7 +41,7 @@ Connection: close
|
|||
assert resp['status'] == 200, 'finish request'
|
||||
|
||||
def test_reconfigure_2(self):
|
||||
(_, sock) = self.http(b'', raw=True, start=True, no_recv=True)
|
||||
sock = self.http(b'', raw=True, no_recv=True)
|
||||
|
||||
# Waiting for connection completion.
|
||||
# Delay should be more than TCP_DEFER_ACCEPT.
|
||||
|
|
|
@ -1485,7 +1485,7 @@ class TestRouting(TestApplicationPython):
|
|||
|
||||
def test_routes_source_port(self):
|
||||
def sock_port():
|
||||
_, sock = self.http(b'', start=True, raw=True, no_recv=True)
|
||||
sock = self.http(b'', raw=True, no_recv=True)
|
||||
port = sock.getsockname()[1]
|
||||
return (sock, port)
|
||||
|
||||
|
|
|
@ -388,14 +388,13 @@ class TestRubyApplication(TestApplicationRuby):
|
|||
socks = []
|
||||
|
||||
for i in range(4):
|
||||
(_, sock) = self.get(
|
||||
sock = self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'X-Delay': '2',
|
||||
'Connection': 'close',
|
||||
},
|
||||
no_recv=True,
|
||||
start=True,
|
||||
)
|
||||
|
||||
socks.append(sock)
|
||||
|
|
|
@ -50,20 +50,18 @@ Connection: close
|
|||
{'http': {'header_read_timeout': 4}}, 'settings'
|
||||
)
|
||||
|
||||
(resp, sock) = self.http(
|
||||
sock = self.http(
|
||||
b"""GET / HTTP/1.1
|
||||
""",
|
||||
start=True,
|
||||
raw=True,
|
||||
no_recv=True,
|
||||
)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
(resp, sock) = self.http(
|
||||
sock = self.http(
|
||||
b"""Host: localhost
|
||||
""",
|
||||
start=True,
|
||||
sock=sock,
|
||||
raw=True,
|
||||
no_recv=True,
|
||||
|
@ -245,7 +243,7 @@ Connection: close
|
|||
self.load('empty')
|
||||
|
||||
def req():
|
||||
_, sock = self.http(b'', start=True, raw=True, no_recv=True)
|
||||
sock = self.http(b'', raw=True, no_recv=True)
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
|
|
|
@ -262,8 +262,8 @@ class TestStatic(TestApplicationProto):
|
|||
assert self.get(url='/../assets/')['status'] == 400, 'path invalid 5'
|
||||
|
||||
def test_static_two_clients(self):
|
||||
_, sock = self.get(url='/', start=True, no_recv=True)
|
||||
_, sock2 = self.get(url='/', start=True, no_recv=True)
|
||||
sock = self.get(no_recv=True)
|
||||
sock2 = self.get(no_recv=True)
|
||||
|
||||
assert sock.recv(1) == b'H', 'client 1'
|
||||
assert sock2.recv(1) == b'H', 'client 2'
|
||||
|
|
|
@ -81,7 +81,7 @@ Connection: close
|
|||
)
|
||||
assert Status.get('/requests/total') == 6, 'pipeline'
|
||||
|
||||
(_, sock) = self.get(port=7081, no_recv=True, start=True)
|
||||
sock = self.get(port=7081, no_recv=True)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
@ -112,7 +112,7 @@ Connection: close
|
|||
|
||||
# idle
|
||||
|
||||
_, sock = self.http(b'', start=True, raw=True, no_recv=True)
|
||||
sock = self.http(b'', raw=True, no_recv=True)
|
||||
self.check_connections(2, 0, 1, 1)
|
||||
|
||||
self.get(sock=sock)
|
||||
|
|
|
@ -290,14 +290,13 @@ Connection: close
|
|||
socks = []
|
||||
for i in range(req):
|
||||
delay = 1 if i % 5 == 0 else 0
|
||||
_, sock = self.get(
|
||||
sock = self.get(
|
||||
headers={
|
||||
'Host': 'localhost',
|
||||
'Content-Length': '0',
|
||||
'X-Delay': str(delay),
|
||||
'Connection': 'close',
|
||||
},
|
||||
start=True,
|
||||
no_recv=True,
|
||||
)
|
||||
socks.append(sock)
|
||||
|
@ -320,17 +319,16 @@ Connection: close
|
|||
socks2 = []
|
||||
|
||||
for _ in range(conns):
|
||||
_, sock = self.get(start=True, no_recv=True)
|
||||
sock = self.get(no_recv=True)
|
||||
socks.append(sock)
|
||||
|
||||
_, sock2 = self.http(
|
||||
sock2 = self.http(
|
||||
b"""POST / HTTP/1.1
|
||||
Host: localhost
|
||||
Content-Length: 10
|
||||
Connection: close
|
||||
|
||||
""",
|
||||
start=True,
|
||||
no_recv=True,
|
||||
raw=True,
|
||||
)
|
||||
|
|
|
@ -43,10 +43,9 @@ class TestApplicationWebsocket(TestApplicationProto):
|
|||
'Sec-WebSocket-Version': 13,
|
||||
}
|
||||
|
||||
_, sock = self.get(
|
||||
sock = self.get(
|
||||
headers=headers,
|
||||
no_recv=True,
|
||||
start=True,
|
||||
)
|
||||
|
||||
resp = ''
|
||||
|
|
|
@ -104,6 +104,9 @@ class TestHTTP:
|
|||
|
||||
resp = self.recvall(sock, **recvall_kwargs).decode(encoding)
|
||||
|
||||
else:
|
||||
return sock
|
||||
|
||||
self.log_in(resp)
|
||||
|
||||
if 'raw_resp' not in kwargs:
|
||||
|
|
Loading…
Reference in a new issue