Skip to content

Commit a2b2db9

Browse files
ShadowCurseroypat
authored andcommitted
refactor(tests): inline _check_rx_bandwidth
The function is too small, so inline it. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 4533de7 commit a2b2db9

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

tests/integration_tests/performance/test_rate_limiter.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ def _check_rx_rate_limiting(test_microvm):
207207

208208
# Second step: check bandwidth when rate limiting is on.
209209
print("Run guest RX iperf for rate limiting without burst")
210-
_check_rx_bandwidth(test_microvm, eth1.guest_ip, expected_kbps)
210+
observed_kbps = _get_rx_bandwidth_with_duration(
211+
test_microvm, eth1.guest_ip, IPERF_TRANSMIT_TIME
212+
)
213+
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
211214

212215
# Third step: get the number of bytes when rate limiting is on and there is
213216
# an initial burst size from where to consume.
@@ -228,7 +231,10 @@ def _check_rx_rate_limiting(test_microvm):
228231
assert _diff(burst_kbps, expected_kbps) > 100
229232

230233
# Since the burst should be consumed, check rate limit is in place.
231-
_check_rx_bandwidth(test_microvm, eth2.guest_ip, expected_kbps)
234+
observed_kbps = _get_rx_bandwidth_with_duration(
235+
test_microvm, eth2.guest_ip, IPERF_TRANSMIT_TIME
236+
)
237+
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
232238

233239

234240
def _check_tx_rate_limit_patch(test_microvm):
@@ -267,11 +273,17 @@ def _check_rx_rate_limit_patch(test_microvm):
267273
# Check that an RX rate limiter can be applied to a previously unlimited
268274
# interface.
269275
_patch_iface_bw(test_microvm, "eth0", "RX", bucket_size, REFILL_TIME_MS)
270-
_check_rx_bandwidth(test_microvm, eth0.guest_ip, expected_kbps)
276+
observed_kbps = _get_rx_bandwidth_with_duration(
277+
test_microvm, eth0.guest_ip, IPERF_TRANSMIT_TIME
278+
)
279+
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
271280

272281
# Check that an RX rate limiter can be updated.
273282
_patch_iface_bw(test_microvm, "eth1", "RX", bucket_size, REFILL_TIME_MS)
274-
_check_rx_bandwidth(test_microvm, eth1.guest_ip, expected_kbps)
283+
observed_kbps = _get_rx_bandwidth_with_duration(
284+
test_microvm, eth1.guest_ip, IPERF_TRANSMIT_TIME
285+
)
286+
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
275287

276288
# Check that an RX rate limiter can be removed.
277289
_patch_iface_bw(test_microvm, "eth0", "RX", 0, 0)
@@ -306,15 +318,6 @@ def _get_tx_bandwidth_with_duration(test_microvm, host_ip, duration):
306318
return observed_kbps
307319

308320

309-
def _check_rx_bandwidth(test_microvm, ip, expected_kbps):
310-
"""Check that the rate-limited RX bandwidth is close to what we expect."""
311-
observed_kbps = _get_rx_bandwidth_with_duration(
312-
test_microvm, ip, IPERF_TRANSMIT_TIME
313-
)
314-
diff_pc = _diff(observed_kbps, expected_kbps)
315-
assert diff_pc < MAX_BYTES_DIFF_PERCENTAGE
316-
317-
318321
def _get_rx_bandwidth_with_duration(test_microvm, guest_ip, duration):
319322
"""Check that the rate-limited RX bandwidth is close to what we expect."""
320323

0 commit comments

Comments
 (0)