9
9
# The iperf version to run this tests with
10
10
IPERF_BINARY = "iperf3"
11
11
12
+ # iperf server side log path inside guest
13
+ GUEST_IPERF_SERVER_LOG = "/tmp/iperf-server.log"
14
+
12
15
# Interval used by iperf to get maximum bandwidth
13
16
IPERF_TRANSMIT_TIME = 4
14
17
@@ -127,7 +130,7 @@ def test_rx_rate_limiting_cpu_load(uvm_plain):
127
130
threshold = 20 ,
128
131
)
129
132
with cpu_load_monitor :
130
- _run_iperf_on_host (iperf_cmd )
133
+ _run_iperf_on_host (iperf_cmd , test_microvm )
131
134
132
135
133
136
def _check_tx_rate_limiting (test_microvm ):
@@ -219,8 +222,7 @@ def _check_rx_rate_limiting(test_microvm):
219
222
BURST_SIZE ,
220
223
IPERF_TCP_WINDOW ,
221
224
)
222
- iperf_out = _run_iperf_on_host (iperf_cmd )
223
- print (iperf_out )
225
+ iperf_out = _run_iperf_on_host (iperf_cmd , test_microvm )
224
226
_ , burst_kbps = _process_iperf_output (iperf_out )
225
227
print ("RX burst_kbps: {}" .format (burst_kbps ))
226
228
# 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):
357
359
duration ,
358
360
IPERF_TCP_WINDOW ,
359
361
)
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 )
363
363
_ , observed_kbps = _process_iperf_output (iperf_out )
364
364
print ("RX observed_kbps: {}" .format (observed_kbps ))
365
365
return observed_kbps
@@ -383,7 +383,7 @@ def _patch_iface_bw(test_microvm, iface_id, rx_or_tx, new_bucket_size, new_refil
383
383
384
384
def _start_iperf_server_on_guest (test_microvm ):
385
385
"""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 } "
387
387
test_microvm .ssh .run (iperf_cmd )
388
388
389
389
# Wait for the iperf daemon to start.
@@ -411,10 +411,15 @@ def _start_iperf_server_on_host(netns_cmd_prefix):
411
411
time .sleep (1 )
412
412
413
413
414
- def _run_iperf_on_host (iperf_cmd ):
414
+ def _run_iperf_on_host (iperf_cmd , test_microvm ):
415
415
"""Execute a client related iperf command locally."""
416
- code , stdout , stderr = utils .check_output (iperf_cmd )
417
- assert code == 0 , f"stdout: { stdout } \n stderr: { stderr } "
416
+ rc , stdout , stderr = utils .run_cmd (iperf_cmd )
417
+ assert rc == 0 , "stdout:\n {}\n stderr:\n {}\n iperf 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 } " )
418
423
419
424
return stdout
420
425
0 commit comments