@@ -145,7 +145,7 @@ def _check_tx_rate_limiting(test_microvm):
145
145
# First step: get the transfer rate when no rate limiting is enabled.
146
146
# We are receiving the result in KBytes from iperf.
147
147
print ("Run guest TX iperf for no rate limiting" )
148
- rate_no_limit_kbps = _get_tx_bandwidth_with_duration (
148
+ rate_no_limit_kbps = _get_tx_bandwidth (
149
149
test_microvm , eth0 .host_ip , IPERF_TRANSMIT_TIME
150
150
)
151
151
print ("TX rate_no_limit_kbps: {}" .format (rate_no_limit_kbps ))
@@ -161,9 +161,7 @@ def _check_tx_rate_limiting(test_microvm):
161
161
162
162
# Second step: check bandwidth when rate limiting is on.
163
163
print ("Run guest TX iperf for rate limiting without burst" )
164
- observed_kbps = _get_tx_bandwidth_with_duration (
165
- test_microvm , eth1 .host_ip , IPERF_TRANSMIT_TIME
166
- )
164
+ observed_kbps = _get_tx_bandwidth (test_microvm , eth1 .host_ip )
167
165
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
168
166
169
167
# Third step: get the number of bytes when rate limiting is on and there is
@@ -182,9 +180,7 @@ def _check_tx_rate_limiting(test_microvm):
182
180
assert _diff (burst_kbps , expected_kbps ) > 100
183
181
184
182
# Since the burst should be consumed, check rate limit is in place.
185
- observed_kbps = _get_tx_bandwidth_with_duration (
186
- test_microvm , eth2 .host_ip , IPERF_TRANSMIT_TIME
187
- )
183
+ observed_kbps = _get_tx_bandwidth (test_microvm , eth2 .host_ip )
188
184
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
189
185
190
186
@@ -247,23 +243,17 @@ def _check_tx_rate_limit_patch(test_microvm):
247
243
# Check that a TX rate limiter can be applied to a previously unlimited
248
244
# interface.
249
245
_patch_iface_bw (test_microvm , "eth0" , "TX" , bucket_size , REFILL_TIME_MS )
250
- observed_kbps = _get_tx_bandwidth_with_duration (
251
- test_microvm , eth0 .host_ip , IPERF_TRANSMIT_TIME
252
- )
246
+ observed_kbps = _get_tx_bandwidth (test_microvm , eth0 .host_ip )
253
247
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
254
248
255
249
# Check that a TX rate limiter can be updated.
256
250
_patch_iface_bw (test_microvm , "eth1" , "TX" , bucket_size , REFILL_TIME_MS )
257
- observed_kbps = _get_tx_bandwidth_with_duration (
258
- test_microvm , eth1 .host_ip , IPERF_TRANSMIT_TIME
259
- )
251
+ observed_kbps = _get_tx_bandwidth (test_microvm , eth1 .host_ip )
260
252
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
261
253
262
254
# Check that a TX rate limiter can be removed.
263
255
_patch_iface_bw (test_microvm , "eth0" , "TX" , 0 , 0 )
264
- rate_no_limit_kbps = _get_tx_bandwidth_with_duration (
265
- test_microvm , eth0 .host_ip , IPERF_TRANSMIT_TIME
266
- )
256
+ rate_no_limit_kbps = _get_tx_bandwidth (test_microvm , eth0 .host_ip )
267
257
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
268
258
# than the one when rate limiting was enabled.
269
259
assert _diff (rate_no_limit_kbps , expected_kbps ) > 50
@@ -295,11 +285,11 @@ def _check_rx_rate_limit_patch(test_microvm):
295
285
assert _diff (rate_no_limit_kbps , expected_kbps ) > 50
296
286
297
287
298
- def _get_tx_bandwidth_with_duration (test_microvm , host_ip , duration ):
288
+ def _get_tx_bandwidth (test_microvm , host_ip ):
299
289
"""Check that the rate-limited TX bandwidth is close to what we expect."""
300
290
301
291
iperf_cmd = "{} -c {} -t {} -f KBytes -w {} -N" .format (
302
- IPERF_BINARY , host_ip , duration , IPERF_TCP_WINDOW
292
+ IPERF_BINARY , host_ip , IPERF_TRANSMIT_TIME , IPERF_TCP_WINDOW
303
293
)
304
294
iperf_out = _run_iperf_on_guest (test_microvm , iperf_cmd )
305
295
print (iperf_out )
0 commit comments