@@ -157,7 +157,7 @@ def _check_tx_rate_limiting(test_microvm):
157
157
158
158
# Sanity check that bandwidth with no rate limiting is at least double
159
159
# than the one expected when rate limiting is in place.
160
- assert _get_percentage_difference (rate_no_limit_kbps , expected_kbps ) > 100
160
+ assert _diff (rate_no_limit_kbps , expected_kbps ) > 100
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" )
@@ -176,7 +176,7 @@ def _check_tx_rate_limiting(test_microvm):
176
176
_ , burst_kbps = _process_iperf_output (iperf_out )
177
177
print ("TX burst_kbps: {}" .format (burst_kbps ))
178
178
# Test that the burst bandwidth is at least as two times the rate limit.
179
- assert _get_percentage_difference (burst_kbps , expected_kbps ) > 100
179
+ assert _diff (burst_kbps , expected_kbps ) > 100
180
180
181
181
# Since the burst should be consumed, check rate limit is in place.
182
182
_check_tx_bandwidth (test_microvm , eth2 .host_ip , expected_kbps )
@@ -203,7 +203,7 @@ def _check_rx_rate_limiting(test_microvm):
203
203
204
204
# Sanity check that bandwidth with no rate limiting is at least double
205
205
# than the one expected when rate limiting is in place.
206
- assert _get_percentage_difference (rate_no_limit_kbps , expected_kbps ) > 100
206
+ assert _diff (rate_no_limit_kbps , expected_kbps ) > 100
207
207
208
208
# Second step: check bandwidth when rate limiting is on.
209
209
print ("Run guest RX iperf for rate limiting without burst" )
@@ -225,7 +225,7 @@ def _check_rx_rate_limiting(test_microvm):
225
225
_ , burst_kbps = _process_iperf_output (iperf_out )
226
226
print ("RX burst_kbps: {}" .format (burst_kbps ))
227
227
# Test that the burst bandwidth is at least as two times the rate limit.
228
- assert _get_percentage_difference (burst_kbps , expected_kbps ) > 100
228
+ assert _diff (burst_kbps , expected_kbps ) > 100
229
229
230
230
# Since the burst should be consumed, check rate limit is in place.
231
231
_check_rx_bandwidth (test_microvm , eth2 .guest_ip , expected_kbps )
@@ -254,7 +254,7 @@ def _check_tx_rate_limit_patch(test_microvm):
254
254
)
255
255
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
256
256
# than the one when rate limiting was enabled.
257
- assert _get_percentage_difference (rate_no_limit_kbps , expected_kbps ) > 50
257
+ assert _diff (rate_no_limit_kbps , expected_kbps ) > 50
258
258
259
259
260
260
def _check_rx_rate_limit_patch (test_microvm ):
@@ -280,15 +280,15 @@ def _check_rx_rate_limit_patch(test_microvm):
280
280
)
281
281
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
282
282
# than the one when rate limiting was enabled.
283
- assert _get_percentage_difference (rate_no_limit_kbps , expected_kbps ) > 50
283
+ assert _diff (rate_no_limit_kbps , expected_kbps ) > 50
284
284
285
285
286
286
def _check_tx_bandwidth (test_microvm , ip , expected_kbps ):
287
287
"""Check that the rate-limited TX bandwidth is close to what we expect."""
288
288
observed_kbps = _get_tx_bandwidth_with_duration (
289
289
test_microvm , ip , IPERF_TRANSMIT_TIME
290
290
)
291
- diff_pc = _get_percentage_difference (observed_kbps , expected_kbps )
291
+ diff_pc = _diff (observed_kbps , expected_kbps )
292
292
assert diff_pc < MAX_BYTES_DIFF_PERCENTAGE
293
293
294
294
@@ -311,7 +311,7 @@ def _check_rx_bandwidth(test_microvm, ip, expected_kbps):
311
311
observed_kbps = _get_rx_bandwidth_with_duration (
312
312
test_microvm , ip , IPERF_TRANSMIT_TIME
313
313
)
314
- diff_pc = _get_percentage_difference (observed_kbps , expected_kbps )
314
+ diff_pc = _diff (observed_kbps , expected_kbps )
315
315
assert diff_pc < MAX_BYTES_DIFF_PERCENTAGE
316
316
317
317
@@ -395,7 +395,7 @@ def _run_iperf_on_host(iperf_cmd, test_microvm):
395
395
return stdout
396
396
397
397
398
- def _get_percentage_difference (measured , base ):
398
+ def _diff (measured , base ):
399
399
"""Return the percentage delta between the arguments."""
400
400
assert base != 0
401
401
return (abs (measured - base ) / base ) * 100.0
0 commit comments