Merge "Wait for iperf3 server before starting client POD"
This commit is contained in:
commit
79828463b2
3 files changed
+31
-16
No files matched your search
@@ -764,8 +764,12 @@ def start_iperf3(
|
||||
**kwargs): # noqa; pylint: disable=W0613
|
||||
|
||||
if iperf3_server_ssh_client:
|
||||
iperf3.start_iperf3_server(
|
||||
port, protocol, iperf3_server_ssh_client)
|
||||
# Wait until the server is listening before starting the client
|
||||
# POD. Otherwise iperf3 exits with "Connection refused" and the
|
||||
# POD (restartPolicy: Never) goes to Error/Failed.
|
||||
iperf3.ensure_iperf3_server(
|
||||
port=port, protocol=protocol,
|
||||
ssh_client=iperf3_server_ssh_client)
|
||||
|
||||
parameters = iperf3.iperf3_client_parameters(
|
||||
address=address, bitrate=bitrate,
|
||||
|
||||
@@ -29,6 +29,7 @@ get_iperf3_logs_filepath = _execute.get_iperf3_logs_filepath
|
||||
iperf3_client_alive = _execute.iperf3_client_alive
|
||||
stop_iperf3_client = _execute.stop_iperf3_client
|
||||
start_iperf3_server = _execute.start_iperf3_server
|
||||
ensure_iperf3_server = _execute.ensure_iperf3_server
|
||||
parse_json_stream_output = _execute.parse_json_stream_output
|
||||
|
||||
get_iperf3_client_command = _interface.get_iperf3_client_command
|
||||
|
||||
@@ -140,22 +140,9 @@ def execute_iperf3_client_in_background(
|
||||
# failure in the previous run, it may report that is still "busy" thus
|
||||
# iperf3 client will not start properly
|
||||
if iperf3_server_ssh_client:
|
||||
_stop_iperf3_server(
|
||||
ensure_iperf3_server(
|
||||
port=port, protocol=protocol,
|
||||
ssh_client=iperf3_server_ssh_client)
|
||||
start_iperf3_server(
|
||||
port=port, protocol=protocol,
|
||||
ssh_client=iperf3_server_ssh_client)
|
||||
|
||||
# if iperf3 server does not start properly, fail the test
|
||||
for attempt in tobiko.retry(count=5, sleep_time=.5):
|
||||
if _iperf3_server_alive(
|
||||
port=port, protocol=protocol,
|
||||
ssh_client=iperf3_server_ssh_client):
|
||||
break
|
||||
elif attempt.is_last:
|
||||
tobiko.fail('iperf3 server did not start properly '
|
||||
f'on the server {iperf3_server_ssh_client}')
|
||||
|
||||
# Now, finally iperf3 client should be ready to start
|
||||
execute_iperf3_client(
|
||||
@@ -334,6 +321,29 @@ def start_iperf3_server(
|
||||
process.execute()
|
||||
|
||||
|
||||
def ensure_iperf3_server(
|
||||
port: typing.Union[int, None],
|
||||
protocol: typing.Union[str, None],
|
||||
ssh_client: ssh.SSHClientType):
|
||||
"""Stop any existing server, start a fresh one, wait until it is alive.
|
||||
|
||||
Used by both the SSH-backed and pod-backed iperf3 client paths so the
|
||||
client does not race ahead of the server listen socket (connection
|
||||
refused).
|
||||
"""
|
||||
_stop_iperf3_server(
|
||||
port=port, protocol=protocol, ssh_client=ssh_client)
|
||||
start_iperf3_server(
|
||||
port=port, protocol=protocol, ssh_client=ssh_client)
|
||||
for attempt in tobiko.retry(count=5, sleep_time=.5):
|
||||
if _iperf3_server_alive(
|
||||
port=port, protocol=protocol, ssh_client=ssh_client):
|
||||
return
|
||||
elif attempt.is_last:
|
||||
tobiko.fail('iperf3 server did not start properly '
|
||||
f'on the server {ssh_client}')
|
||||
|
||||
|
||||
def _iperf3_server_alive(
|
||||
port: typing.Union[int, None],
|
||||
protocol: typing.Union[str, None],
|
||||
|
||||
Reference in new issue
Block a user