@@ -188,9 +188,6 @@ def _check_rx_rate_limiting(test_microvm):
188
188
eth1 = test_microvm .iface ["eth1" ]["iface" ]
189
189
eth2 = test_microvm .iface ["eth2" ]["iface" ]
190
190
191
- # Start iperf server on guest.
192
- _start_iperf_server_on_guest (test_microvm )
193
-
194
191
# First step: get the transfer rate when no rate limiting is enabled.
195
192
# We are receiving the result in KBytes from iperf.
196
193
print ("Run guest RX iperf with no rate limiting" )
@@ -297,10 +294,10 @@ def _check_tx_bandwidth(test_microvm, ip, expected_kbps):
297
294
298
295
def _get_tx_bandwidth_with_duration (test_microvm , host_ip , duration ):
299
296
"""Check that the rate-limited TX bandwidth is close to what we expect."""
297
+
300
298
iperf_cmd = "{} -c {} -t {} -f KBytes -w {} -N" .format (
301
299
IPERF_BINARY , host_ip , duration , IPERF_TCP_WINDOW
302
300
)
303
-
304
301
iperf_out = _run_iperf_on_guest (test_microvm , iperf_cmd )
305
302
print (iperf_out )
306
303
@@ -320,6 +317,9 @@ def _check_rx_bandwidth(test_microvm, ip, expected_kbps):
320
317
321
318
def _get_rx_bandwidth_with_duration (test_microvm , guest_ip , duration ):
322
319
"""Check that the rate-limited RX bandwidth is close to what we expect."""
320
+
321
+ _start_iperf_server_on_guest (test_microvm )
322
+
323
323
iperf_cmd = "{} {} -c {} -t {} -f KBytes -w {} -N" .format (
324
324
test_microvm .netns .cmd_prefix (),
325
325
IPERF_BINARY ,
@@ -351,10 +351,13 @@ def _patch_iface_bw(test_microvm, iface_id, rx_or_tx, new_bucket_size, new_refil
351
351
352
352
def _start_iperf_server_on_guest (test_microvm ):
353
353
"""Start iperf in server mode through an SSH connection."""
354
+ kill_cmd = f"pkill { IPERF_BINARY } "
355
+ test_microvm .ssh .run (kill_cmd )
356
+
354
357
iperf_cmd = f"{ IPERF_BINARY } -sD -f KBytes --logfile { GUEST_IPERF_SERVER_LOG } "
355
358
test_microvm .ssh .run (iperf_cmd )
356
359
357
- # Wait for the iperf daemon to start.
360
+ # Wait for the iperf to start.
358
361
time .sleep (1 )
359
362
360
363
0 commit comments