Skip to content

Commit

Permalink
Fixes #1373: HTTP/1 test timeout in wait_http_listeners_down (#1384)
Browse files Browse the repository at this point in the history
Fix prevents the router from reconnecting when the last active
connection closes by shutting down the listener socket after accepting
the last connection from the router.
  • Loading branch information
kgiusti authored Jan 15, 2024
1 parent 6a9d559 commit 93abd7c
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions tests/system_tests_http1_adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,11 @@ def test_3000_N_client_pipeline_cancel(self):
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind(("", self.server11_port))
listener.settimeout(TIMEOUT)
listener.listen(1)
listener.listen(0)
server, addr = listener.accept()
wait_http_listeners_up(self.EA1.addresses[0], l_filter={'name': 'L_testServer11'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

clients = []
for index in range(CLIENT_COUNT):
Expand Down Expand Up @@ -841,7 +843,7 @@ def test_3001_N_client_pipeline_recover(self):
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind((self.server11_host, self.server11_port))
listener.settimeout(TIMEOUT)
listener.listen(1)
listener.listen(0)
server, addr = listener.accept()
wait_http_listeners_up(self.EA1.addresses[0], l_filter={'name': 'L_testServer11'})

Expand Down Expand Up @@ -923,6 +925,8 @@ def test_3001_N_client_pipeline_recover(self):

server, addr = listener.accept()
wait_http_listeners_up(self.EA1.addresses[0], l_filter={'name': 'L_testServer11'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

# expect the remaining requests to complete successfully

Expand Down Expand Up @@ -982,9 +986,11 @@ def test_4000_client_half_close(self):
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind((self.server11_host, self.server11_port))
listener.settimeout(TIMEOUT)
listener.listen(1)
listener.listen(0)
server, addr = listener.accept()
wait_http_listeners_up(self.EA1.addresses[0], l_filter={'name': 'L_testServer11'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

clients = []
for index in range(CLIENT_COUNT):
Expand Down Expand Up @@ -1063,9 +1069,11 @@ def test_4001_server_half_close(self):
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind((self.server11_host, self.server11_port))
listener.settimeout(TIMEOUT)
listener.listen(1)
listener.listen(0)
server, addr = listener.accept()
wait_http_listeners_up(self.EA1.addresses[0], l_filter={'name': 'L_testServer11'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
Expand Down Expand Up @@ -1115,9 +1123,11 @@ def test_4002_server_early_reply(self):
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind((self.server11_host, self.server11_port))
listener.settimeout(TIMEOUT)
listener.listen(1)
listener.listen(0)
server, addr = listener.accept()
wait_http_listeners_up(self.EA1.addresses[0], l_filter={'name': 'L_testServer11'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
Expand Down Expand Up @@ -1310,9 +1320,11 @@ def test_4000_server_no_notify(self):
with self.server_ssl_context.wrap_socket(raw_listener,
server_side=True) as listener:
listener.bind((self.server11_host, self.server11_port))
listener.listen(1)
listener.listen(0)
server, addr = listener.accept()
wait_http_listeners_up(self.EA1.addresses[0], l_filter={'name': 'L_testServer11'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

raw_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
raw_client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
Expand Down Expand Up @@ -1361,9 +1373,11 @@ def test_4001_server_no_notify_truncated(self):
with self.server_ssl_context.wrap_socket(raw_listener,
server_side=True) as listener:
listener.bind((self.server11_host, self.server11_port))
listener.listen(1)
listener.listen(0)
server, addr = listener.accept()
wait_http_listeners_up(self.EA1.addresses[0], l_filter={'name': 'L_testServer11'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

raw_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
raw_client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
Expand Down Expand Up @@ -1689,9 +1703,11 @@ def test_06_bad_request_headers(self):
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind(("", self.http_server_port))
listener.settimeout(TIMEOUT)
listener.listen(1)
listener.listen(0)
server, addr = listener.accept()
wait_http_listeners_up(self.INT_A.listener, l_filter={'name': 'L_testServer'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

bad_requests = [
# malformed request line
Expand Down Expand Up @@ -1752,7 +1768,7 @@ def test_07_bad_response_line(self):
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind(("", self.http_server_port))
listener.settimeout(TIMEOUT)
listener.listen(1)
listener.listen(0)

bad_responses = [
# malformed response line
Expand All @@ -1771,9 +1787,13 @@ def test_07_bad_response_line(self):

# unterminated request to check client cleanup
request = b'GET / HTTP/1.1\r\nContent-Length: 100\r\n\r\nX'
for response in bad_responses:
for index in range(len(bad_responses)):
response = bad_responses[index]
server, addr = listener.accept()
wait_http_listeners_up(self.INT_A.listener, l_filter={'name': 'L_testServer'})
# prevent router reconnect when server socket closes (ISSUE-1373)
if index == len(bad_responses) - 1:
listener.shutdown(socket.SHUT_RDWR)

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
Expand Down Expand Up @@ -1811,7 +1831,7 @@ def test_08_bad_chunked_body(self):
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind(("", self.http_server_port))
listener.settimeout(TIMEOUT)
listener.listen(1)
listener.listen(0)

server, addr = listener.accept()
wait_http_listeners_up(self.INT_A.listener, l_filter={'name': 'L_testServer'})
Expand Down Expand Up @@ -1856,6 +1876,8 @@ def test_08_bad_chunked_body(self):

server, addr = listener.accept()
wait_http_listeners_up(self.INT_A.listener, l_filter={'name': 'L_testServer'})
# prevent router reconnect when server socket closes (ISSUE-1373)
listener.shutdown(socket.SHUT_RDWR)

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
Expand Down

0 comments on commit 93abd7c

Please sign in to comment.