Skip to content

Commit 9d7bb2d

Browse files
committed
test: Print log of iperf server running in guest
We occasionally see failures of `test_rx_rate_limiting` with the following error: ``` iperf3: error - unable to connect to server - server may have stopped running or use a different port, firewall issue, etc.: Connection refused ``` However, we didn't have any diagnostic info about what happened inside a guest. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent c476050 commit 9d7bb2d

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tests/integration_tests/performance/test_rate_limiter.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# The iperf version to run this tests with
1010
IPERF_BINARY = "iperf3"
1111

12+
# iperf server side log path inside guest
13+
GUEST_IPERF_SERVER_LOG = "/tmp/iperf-server.log"
14+
1215
# Interval used by iperf to get maximum bandwidth
1316
IPERF_TRANSMIT_TIME = 4
1417

@@ -127,7 +130,7 @@ def test_rx_rate_limiting_cpu_load(uvm_plain):
127130
threshold=20,
128131
)
129132
with cpu_load_monitor:
130-
_run_iperf_on_host(iperf_cmd)
133+
_run_iperf_on_host(iperf_cmd, test_microvm)
131134

132135

133136
def _check_tx_rate_limiting(test_microvm):
@@ -219,8 +222,7 @@ def _check_rx_rate_limiting(test_microvm):
219222
BURST_SIZE,
220223
IPERF_TCP_WINDOW,
221224
)
222-
iperf_out = _run_iperf_on_host(iperf_cmd)
223-
print(iperf_out)
225+
iperf_out = _run_iperf_on_host(iperf_cmd, test_microvm)
224226
_, burst_kbps = _process_iperf_output(iperf_out)
225227
print("RX burst_kbps: {}".format(burst_kbps))
226228
# Test that the burst bandwidth is at least as two times the rate limit.
@@ -357,9 +359,7 @@ def _get_rx_bandwidth_with_duration(test_microvm, guest_ip, duration):
357359
duration,
358360
IPERF_TCP_WINDOW,
359361
)
360-
iperf_out = _run_iperf_on_host(iperf_cmd)
361-
print(iperf_out)
362-
362+
iperf_out = _run_iperf_on_host(iperf_cmd, test_microvm)
363363
_, observed_kbps = _process_iperf_output(iperf_out)
364364
print("RX observed_kbps: {}".format(observed_kbps))
365365
return observed_kbps
@@ -383,7 +383,7 @@ def _patch_iface_bw(test_microvm, iface_id, rx_or_tx, new_bucket_size, new_refil
383383

384384
def _start_iperf_server_on_guest(test_microvm):
385385
"""Start iperf in server mode through an SSH connection."""
386-
iperf_cmd = "{} -sD -f KBytes\n".format(IPERF_BINARY)
386+
iperf_cmd = f"{IPERF_BINARY} -sD -f KBytes --logfile {GUEST_IPERF_SERVER_LOG}"
387387
test_microvm.ssh.run(iperf_cmd)
388388

389389
# Wait for the iperf daemon to start.
@@ -411,10 +411,15 @@ def _start_iperf_server_on_host(netns_cmd_prefix):
411411
time.sleep(1)
412412

413413

414-
def _run_iperf_on_host(iperf_cmd):
414+
def _run_iperf_on_host(iperf_cmd, test_microvm):
415415
"""Execute a client related iperf command locally."""
416-
code, stdout, stderr = utils.check_output(iperf_cmd)
417-
assert code == 0, f"stdout: {stdout}\nstderr: {stderr}"
416+
rc, stdout, stderr = utils.run_cmd(iperf_cmd)
417+
assert rc == 0, "stdout:\n{}\nstderr:\n{}\niperf server log:\n{}\n".format(
418+
stdout,
419+
stderr,
420+
test_microvm.ssh.check_output(f"cat {GUEST_IPERF_SERVER_LOG}").stdout,
421+
)
422+
print(f"iperf log:\n{stdout}")
418423

419424
return stdout
420425

0 commit comments

Comments
 (0)