@@ -104,7 +104,7 @@ def test_rx_rate_limiting_cpu_load(uvm_plain):
104
104
test_microvm .start ()
105
105
106
106
# Start iperf server on guest.
107
- _start_iperf_server_on_guest (test_microvm , iface . guest_ip )
107
+ _start_iperf_server_on_guest (test_microvm )
108
108
109
109
# Run iperf client sending UDP traffic.
110
110
iperf_cmd = "{} {} -u -c {} -b 1000000000 -t{} -f KBytes" .format (
@@ -143,7 +143,7 @@ def _check_tx_rate_limiting(test_microvm):
143
143
# We are receiving the result in KBytes from iperf.
144
144
print ("Run guest TX iperf with no rate-limit" )
145
145
rate_no_limit_kbps = _get_tx_bandwidth_with_duration (
146
- test_microvm , eth0 .guest_ip , eth0 . host_ip , IPERF_TRANSMIT_TIME
146
+ test_microvm , eth0 .host_ip , IPERF_TRANSMIT_TIME
147
147
)
148
148
print ("TX rate_no_limit_kbps: {}" .format (rate_no_limit_kbps ))
149
149
@@ -157,7 +157,7 @@ def _check_tx_rate_limiting(test_microvm):
157
157
assert _get_percentage_difference (rate_no_limit_kbps , expected_kbps ) > 100
158
158
159
159
# Second step: check bandwidth when rate limiting is on.
160
- _check_tx_bandwidth (test_microvm , eth1 .guest_ip , eth1 . host_ip , expected_kbps )
160
+ _check_tx_bandwidth (test_microvm , eth1 .host_ip , expected_kbps )
161
161
162
162
# Third step: get the number of bytes when rate limiting is on and there is
163
163
# an initial burst size from where to consume.
@@ -167,15 +167,15 @@ def _check_tx_rate_limiting(test_microvm):
167
167
iperf_cmd = "{} -c {} -n {} -f KBytes -w {} -N" .format (
168
168
IPERF_BINARY , eth2 .host_ip , BURST_SIZE , IPERF_TCP_WINDOW
169
169
)
170
- iperf_out = _run_iperf_on_guest (test_microvm , iperf_cmd , eth2 . guest_ip )
170
+ iperf_out = _run_iperf_on_guest (test_microvm , iperf_cmd )
171
171
print (iperf_out )
172
172
_ , burst_kbps = _process_iperf_output (iperf_out )
173
173
print ("TX burst_kbps: {}" .format (burst_kbps ))
174
174
# Test that the burst bandwidth is at least as two times the rate limit.
175
175
assert _get_percentage_difference (burst_kbps , expected_kbps ) > 100
176
176
177
177
# Since the burst should be consumed, check rate limit is in place.
178
- _check_tx_bandwidth (test_microvm , eth2 .guest_ip , eth2 . host_ip , expected_kbps )
178
+ _check_tx_bandwidth (test_microvm , eth2 .host_ip , expected_kbps )
179
179
180
180
181
181
def _check_rx_rate_limiting (test_microvm ):
@@ -185,7 +185,7 @@ def _check_rx_rate_limiting(test_microvm):
185
185
eth2 = test_microvm .iface ["eth2" ]["iface" ]
186
186
187
187
# Start iperf server on guest.
188
- _start_iperf_server_on_guest (test_microvm , eth0 . guest_ip )
188
+ _start_iperf_server_on_guest (test_microvm )
189
189
190
190
# First step: get the transfer rate when no rate limiting is enabled.
191
191
# We are receiving the result in KBytes from iperf.
@@ -240,16 +240,16 @@ def _check_tx_rate_limit_patch(test_microvm):
240
240
# Check that a TX rate limiter can be applied to a previously unlimited
241
241
# interface.
242
242
_patch_iface_bw (test_microvm , "eth0" , "TX" , bucket_size , REFILL_TIME_MS )
243
- _check_tx_bandwidth (test_microvm , eth0 .guest_ip , eth0 . host_ip , expected_kbps )
243
+ _check_tx_bandwidth (test_microvm , eth0 .host_ip , expected_kbps )
244
244
245
245
# Check that a TX rate limiter can be updated.
246
246
_patch_iface_bw (test_microvm , "eth1" , "TX" , bucket_size , REFILL_TIME_MS )
247
- _check_tx_bandwidth (test_microvm , eth1 .guest_ip , eth1 . host_ip , expected_kbps )
247
+ _check_tx_bandwidth (test_microvm , eth1 .host_ip , expected_kbps )
248
248
249
249
# Check that a TX rate limiter can be removed.
250
250
_patch_iface_bw (test_microvm , "eth0" , "TX" , 0 , 0 )
251
251
rate_no_limit_kbps = _get_tx_bandwidth_with_duration (
252
- test_microvm , eth0 .guest_ip , eth0 . host_ip , IPERF_TRANSMIT_TIME
252
+ test_microvm , eth0 .host_ip , IPERF_TRANSMIT_TIME
253
253
)
254
254
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
255
255
# than the one when rate limiting was enabled.
@@ -282,15 +282,15 @@ def _check_rx_rate_limit_patch(test_microvm):
282
282
assert _get_percentage_difference (rate_no_limit_kbps , expected_kbps ) > 50
283
283
284
284
285
- def _check_tx_bandwidth (test_microvm , guest_ip , host_ip , expected_kbps ):
285
+ def _check_tx_bandwidth (test_microvm , ip , expected_kbps ):
286
286
"""Check that the rate-limited TX bandwidth is close to what we expect.
287
287
288
288
At this point, a daemonized iperf3 server is expected to be running on
289
289
the host.
290
290
"""
291
291
print ("Check guest TX rate-limit; expected kbps {}" .format (expected_kbps ))
292
292
observed_kbps = _get_tx_bandwidth_with_duration (
293
- test_microvm , guest_ip , host_ip , IPERF_TRANSMIT_TIME
293
+ test_microvm , ip , IPERF_TRANSMIT_TIME
294
294
)
295
295
296
296
diff_pc = _get_percentage_difference (observed_kbps , expected_kbps )
@@ -300,37 +300,37 @@ def _check_tx_bandwidth(test_microvm, guest_ip, host_ip, expected_kbps):
300
300
print ("Short duration test failed. Try another run with 10x duration." )
301
301
302
302
observed_kbps = _get_tx_bandwidth_with_duration (
303
- test_microvm , guest_ip , host_ip , 10 * IPERF_TRANSMIT_TIME
303
+ test_microvm , ip , 10 * IPERF_TRANSMIT_TIME
304
304
)
305
305
diff_pc = _get_percentage_difference (observed_kbps , expected_kbps )
306
306
print ("TX calculated diff percentage: {}\n " .format (diff_pc ))
307
307
308
308
assert diff_pc < MAX_BYTES_DIFF_PERCENTAGE
309
309
310
310
311
- def _get_tx_bandwidth_with_duration (test_microvm , guest_ip , host_ip , duration ):
311
+ def _get_tx_bandwidth_with_duration (test_microvm , host_ip , duration ):
312
312
"""Check that the rate-limited TX bandwidth is close to what we expect."""
313
313
iperf_cmd = "{} -c {} -t {} -f KBytes -w {} -N" .format (
314
314
IPERF_BINARY , host_ip , duration , IPERF_TCP_WINDOW
315
315
)
316
316
317
- iperf_out = _run_iperf_on_guest (test_microvm , iperf_cmd , guest_ip )
317
+ iperf_out = _run_iperf_on_guest (test_microvm , iperf_cmd )
318
318
print (iperf_out )
319
319
320
320
_ , observed_kbps = _process_iperf_output (iperf_out )
321
321
print ("TX observed_kbps: {}" .format (observed_kbps ))
322
322
return observed_kbps
323
323
324
324
325
- def _check_rx_bandwidth (test_microvm , guest_ip , expected_kbps ):
325
+ def _check_rx_bandwidth (test_microvm , ip , expected_kbps ):
326
326
"""Check that the rate-limited RX bandwidth is close to what we expect.
327
327
328
328
At this point, a daemonized iperf3 server is expected to be running on
329
329
the guest.
330
330
"""
331
331
print ("Check guest RX rate-limit; expected kbps {}" .format (expected_kbps ))
332
332
observed_kbps = _get_rx_bandwidth_with_duration (
333
- test_microvm , guest_ip , IPERF_TRANSMIT_TIME
333
+ test_microvm , ip , IPERF_TRANSMIT_TIME
334
334
)
335
335
336
336
diff_pc = _get_percentage_difference (observed_kbps , expected_kbps )
@@ -340,7 +340,7 @@ def _check_rx_bandwidth(test_microvm, guest_ip, expected_kbps):
340
340
print ("Short duration test failed. Try another run with 10x duration." )
341
341
342
342
observed_kbps = _get_rx_bandwidth_with_duration (
343
- test_microvm , guest_ip , 10 * IPERF_TRANSMIT_TIME
343
+ test_microvm , ip , 10 * IPERF_TRANSMIT_TIME
344
344
)
345
345
diff_pc = _get_percentage_difference (observed_kbps , expected_kbps )
346
346
print ("TX calculated diff percentage: {}\n " .format (diff_pc ))
@@ -381,20 +381,17 @@ def _patch_iface_bw(test_microvm, iface_id, rx_or_tx, new_bucket_size, new_refil
381
381
test_microvm .api .network .patch (** args )
382
382
383
383
384
- def _start_iperf_server_on_guest (test_microvm , hostname ):
384
+ def _start_iperf_server_on_guest (test_microvm ):
385
385
"""Start iperf in server mode through an SSH connection."""
386
- test_microvm .guest_ip = hostname
387
-
388
386
iperf_cmd = "{} -sD -f KBytes\n " .format (IPERF_BINARY )
389
387
test_microvm .ssh .run (iperf_cmd )
390
388
391
389
# Wait for the iperf daemon to start.
392
390
time .sleep (1 )
393
391
394
392
395
- def _run_iperf_on_guest (test_microvm , iperf_cmd , hostname ):
393
+ def _run_iperf_on_guest (test_microvm , iperf_cmd ):
396
394
"""Run a client related iperf command through an SSH connection."""
397
- test_microvm .guest_ip = hostname
398
395
return test_microvm .ssh .check_output (iperf_cmd ).stdout
399
396
400
397
0 commit comments