@@ -191,9 +191,7 @@ def _check_rx_rate_limiting(test_microvm):
191
191
# First step: get the transfer rate when no rate limiting is enabled.
192
192
# We are receiving the result in KBytes from iperf.
193
193
print ("Run guest RX iperf with no rate limiting" )
194
- rate_no_limit_kbps = _get_rx_bandwidth_with_duration (
195
- test_microvm , eth0 .guest_ip , IPERF_TRANSMIT_TIME
196
- )
194
+ rate_no_limit_kbps = _get_rx_bandwidth (test_microvm , eth0 .guest_ip )
197
195
print ("RX rate_no_limit_kbps: {}" .format (rate_no_limit_kbps ))
198
196
199
197
# Calculate the number of bytes that are expected to be sent
@@ -207,9 +205,7 @@ def _check_rx_rate_limiting(test_microvm):
207
205
208
206
# Second step: check bandwidth when rate limiting is on.
209
207
print ("Run guest RX iperf for rate limiting without burst" )
210
- observed_kbps = _get_rx_bandwidth_with_duration (
211
- test_microvm , eth1 .guest_ip , IPERF_TRANSMIT_TIME
212
- )
208
+ observed_kbps = _get_rx_bandwidth (test_microvm , eth1 .guest_ip )
213
209
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
214
210
215
211
# Third step: get the number of bytes when rate limiting is on and there is
@@ -231,9 +227,7 @@ def _check_rx_rate_limiting(test_microvm):
231
227
assert _diff (burst_kbps , expected_kbps ) > 100
232
228
233
229
# Since the burst should be consumed, check rate limit is in place.
234
- observed_kbps = _get_rx_bandwidth_with_duration (
235
- test_microvm , eth2 .guest_ip , IPERF_TRANSMIT_TIME
236
- )
230
+ observed_kbps = _get_rx_bandwidth (test_microvm , eth2 .guest_ip )
237
231
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
238
232
239
233
@@ -273,23 +267,17 @@ def _check_rx_rate_limit_patch(test_microvm):
273
267
# Check that an RX rate limiter can be applied to a previously unlimited
274
268
# interface.
275
269
_patch_iface_bw (test_microvm , "eth0" , "RX" , bucket_size , REFILL_TIME_MS )
276
- observed_kbps = _get_rx_bandwidth_with_duration (
277
- test_microvm , eth0 .guest_ip , IPERF_TRANSMIT_TIME
278
- )
270
+ observed_kbps = _get_rx_bandwidth (test_microvm , eth0 .guest_ip )
279
271
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
280
272
281
273
# Check that an RX rate limiter can be updated.
282
274
_patch_iface_bw (test_microvm , "eth1" , "RX" , bucket_size , REFILL_TIME_MS )
283
- observed_kbps = _get_rx_bandwidth_with_duration (
284
- test_microvm , eth1 .guest_ip , IPERF_TRANSMIT_TIME
285
- )
275
+ observed_kbps = _get_rx_bandwidth (test_microvm , eth1 .guest_ip )
286
276
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
287
277
288
278
# Check that an RX rate limiter can be removed.
289
279
_patch_iface_bw (test_microvm , "eth0" , "RX" , 0 , 0 )
290
- rate_no_limit_kbps = _get_rx_bandwidth_with_duration (
291
- test_microvm , eth0 .guest_ip , IPERF_TRANSMIT_TIME
292
- )
280
+ rate_no_limit_kbps = _get_rx_bandwidth (test_microvm , eth0 .guest_ip )
293
281
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
294
282
# than the one when rate limiting was enabled.
295
283
assert _diff (rate_no_limit_kbps , expected_kbps ) > 50
@@ -318,7 +306,7 @@ def _get_tx_bandwidth_with_duration(test_microvm, host_ip, duration):
318
306
return observed_kbps
319
307
320
308
321
- def _get_rx_bandwidth_with_duration (test_microvm , guest_ip , duration ):
309
+ def _get_rx_bandwidth (test_microvm , guest_ip ):
322
310
"""Check that the rate-limited RX bandwidth is close to what we expect."""
323
311
324
312
_start_iperf_server_on_guest (test_microvm )
@@ -327,7 +315,7 @@ def _get_rx_bandwidth_with_duration(test_microvm, guest_ip, duration):
327
315
test_microvm .netns .cmd_prefix (),
328
316
IPERF_BINARY ,
329
317
guest_ip ,
330
- duration ,
318
+ IPERF_TRANSMIT_TIME ,
331
319
IPERF_TCP_WINDOW ,
332
320
)
333
321
iperf_out = _run_iperf_on_host (iperf_cmd , test_microvm )
0 commit comments