Skip to content

Commit 427d765

Browse files
committed
refactor(tests): remove duration from _get_rx_bandwidth_with_duration
The duration was always the same, so no need to have it as an argument. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent dd56fca commit 427d765

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

tests/integration_tests/performance/test_rate_limiter.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ def _check_rx_rate_limiting(test_microvm):
191191
# First step: get the transfer rate when no rate limiting is enabled.
192192
# We are receiving the result in KBytes from iperf.
193193
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)
197195
print("RX rate_no_limit_kbps: {}".format(rate_no_limit_kbps))
198196

199197
# Calculate the number of bytes that are expected to be sent
@@ -207,9 +205,7 @@ def _check_rx_rate_limiting(test_microvm):
207205

208206
# Second step: check bandwidth when rate limiting is on.
209207
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)
213209
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
214210

215211
# 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):
231227
assert _diff(burst_kbps, expected_kbps) > 100
232228

233229
# 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)
237231
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
238232

239233

@@ -273,23 +267,17 @@ def _check_rx_rate_limit_patch(test_microvm):
273267
# Check that an RX rate limiter can be applied to a previously unlimited
274268
# interface.
275269
_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)
279271
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
280272

281273
# Check that an RX rate limiter can be updated.
282274
_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)
286276
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
287277

288278
# Check that an RX rate limiter can be removed.
289279
_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)
293281
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
294282
# than the one when rate limiting was enabled.
295283
assert _diff(rate_no_limit_kbps, expected_kbps) > 50
@@ -318,7 +306,7 @@ def _get_tx_bandwidth_with_duration(test_microvm, host_ip, duration):
318306
return observed_kbps
319307

320308

321-
def _get_rx_bandwidth_with_duration(test_microvm, guest_ip, duration):
309+
def _get_rx_bandwidth(test_microvm, guest_ip):
322310
"""Check that the rate-limited RX bandwidth is close to what we expect."""
323311

324312
_start_iperf_server_on_guest(test_microvm)
@@ -327,7 +315,7 @@ def _get_rx_bandwidth_with_duration(test_microvm, guest_ip, duration):
327315
test_microvm.netns.cmd_prefix(),
328316
IPERF_BINARY,
329317
guest_ip,
330-
duration,
318+
IPERF_TRANSMIT_TIME,
331319
IPERF_TCP_WINDOW,
332320
)
333321
iperf_out = _run_iperf_on_host(iperf_cmd, test_microvm)

0 commit comments

Comments
 (0)