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