@@ -145,9 +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 (
149
- test_microvm , eth0 .host_ip , IPERF_TRANSMIT_TIME
150
- )
148
+ rate_no_limit_kbps = _get_tx_bandwidth (test_microvm , eth0 .host_ip )
151
149
print ("TX rate_no_limit_kbps: {}" .format (rate_no_limit_kbps ))
152
150
153
151
# Calculate the number of bytes that are expected to be sent
@@ -161,9 +159,7 @@ def _check_tx_rate_limiting(test_microvm):
161
159
162
160
# Second step: check bandwidth when rate limiting is on.
163
161
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
- )
162
+ observed_kbps = _get_tx_bandwidth (test_microvm , eth1 .host_ip )
167
163
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
168
164
169
165
# Third step: get the number of bytes when rate limiting is on and there is
@@ -182,9 +178,7 @@ def _check_tx_rate_limiting(test_microvm):
182
178
assert _diff (burst_kbps , expected_kbps ) > 100
183
179
184
180
# 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
- )
181
+ observed_kbps = _get_tx_bandwidth (test_microvm , eth2 .host_ip )
188
182
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
189
183
190
184
@@ -247,23 +241,17 @@ def _check_tx_rate_limit_patch(test_microvm):
247
241
# Check that a TX rate limiter can be applied to a previously unlimited
248
242
# interface.
249
243
_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
- )
244
+ observed_kbps = _get_tx_bandwidth (test_microvm , eth0 .host_ip )
253
245
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
254
246
255
247
# Check that a TX rate limiter can be updated.
256
248
_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
- )
249
+ observed_kbps = _get_tx_bandwidth (test_microvm , eth1 .host_ip )
260
250
assert _diff (observed_kbps , expected_kbps ) < MAX_BYTES_DIFF_PERCENTAGE
261
251
262
252
# Check that a TX rate limiter can be removed.
263
253
_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
- )
254
+ rate_no_limit_kbps = _get_tx_bandwidth (test_microvm , eth0 .host_ip )
267
255
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
268
256
# than the one when rate limiting was enabled.
269
257
assert _diff (rate_no_limit_kbps , expected_kbps ) > 50
@@ -295,11 +283,11 @@ def _check_rx_rate_limit_patch(test_microvm):
295
283
assert _diff (rate_no_limit_kbps , expected_kbps ) > 50
296
284
297
285
298
- def _get_tx_bandwidth_with_duration (test_microvm , host_ip , duration ):
286
+ def _get_tx_bandwidth (test_microvm , host_ip ):
299
287
"""Check that the rate-limited TX bandwidth is close to what we expect."""
300
288
301
289
iperf_cmd = "{} -c {} -t {} -f KBytes -w {} -N" .format (
302
- IPERF_BINARY , host_ip , duration , IPERF_TCP_WINDOW
290
+ IPERF_BINARY , host_ip , IPERF_TRANSMIT_TIME , IPERF_TCP_WINDOW
303
291
)
304
292
iperf_out = _run_iperf_on_guest (test_microvm , iperf_cmd )
305
293
print (iperf_out )
0 commit comments