Skip to content

Commit 1135450

Browse files
committed
refactor(tests): remove duration from _get_tx_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 1e77dcf commit 1135450

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
@@ -145,9 +145,7 @@ def _check_tx_rate_limiting(test_microvm):
145145
# First step: get the transfer rate when no rate limiting is enabled.
146146
# We are receiving the result in KBytes from iperf.
147147
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)
151149
print("TX rate_no_limit_kbps: {}".format(rate_no_limit_kbps))
152150

153151
# Calculate the number of bytes that are expected to be sent
@@ -161,9 +159,7 @@ def _check_tx_rate_limiting(test_microvm):
161159

162160
# Second step: check bandwidth when rate limiting is on.
163161
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)
167163
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
168164

169165
# 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):
182178
assert _diff(burst_kbps, expected_kbps) > 100
183179

184180
# 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)
188182
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
189183

190184

@@ -247,23 +241,17 @@ def _check_tx_rate_limit_patch(test_microvm):
247241
# Check that a TX rate limiter can be applied to a previously unlimited
248242
# interface.
249243
_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)
253245
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
254246

255247
# Check that a TX rate limiter can be updated.
256248
_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)
260250
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
261251

262252
# Check that a TX rate limiter can be removed.
263253
_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)
267255
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
268256
# than the one when rate limiting was enabled.
269257
assert _diff(rate_no_limit_kbps, expected_kbps) > 50
@@ -295,11 +283,11 @@ def _check_rx_rate_limit_patch(test_microvm):
295283
assert _diff(rate_no_limit_kbps, expected_kbps) > 50
296284

297285

298-
def _get_tx_bandwidth_with_duration(test_microvm, host_ip, duration):
286+
def _get_tx_bandwidth(test_microvm, host_ip):
299287
"""Check that the rate-limited TX bandwidth is close to what we expect."""
300288

301289
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
303291
)
304292
iperf_out = _run_iperf_on_guest(test_microvm, iperf_cmd)
305293
print(iperf_out)

0 commit comments

Comments
 (0)