Skip to content

Commit aa34e99

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 242d06e commit aa34e99

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

tests/integration_tests/performance/test_rate_limiter.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +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(
148+
rate_no_limit_kbps = _get_tx_bandwidth(
149149
test_microvm, eth0.host_ip, IPERF_TRANSMIT_TIME
150150
)
151151
print("TX rate_no_limit_kbps: {}".format(rate_no_limit_kbps))
@@ -161,9 +161,7 @@ def _check_tx_rate_limiting(test_microvm):
161161

162162
# Second step: check bandwidth when rate limiting is on.
163163
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-
)
164+
observed_kbps = _get_tx_bandwidth(test_microvm, eth1.host_ip)
167165
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
168166

169167
# Third step: get the number of bytes when rate limiting is on and there is
@@ -182,9 +180,7 @@ def _check_tx_rate_limiting(test_microvm):
182180
assert _diff(burst_kbps, expected_kbps) > 100
183181

184182
# 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-
)
183+
observed_kbps = _get_tx_bandwidth(test_microvm, eth2.host_ip)
188184
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
189185

190186

@@ -247,23 +243,17 @@ def _check_tx_rate_limit_patch(test_microvm):
247243
# Check that a TX rate limiter can be applied to a previously unlimited
248244
# interface.
249245
_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-
)
246+
observed_kbps = _get_tx_bandwidth(test_microvm, eth0.host_ip)
253247
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
254248

255249
# Check that a TX rate limiter can be updated.
256250
_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-
)
251+
observed_kbps = _get_tx_bandwidth(test_microvm, eth1.host_ip)
260252
assert _diff(observed_kbps, expected_kbps) < MAX_BYTES_DIFF_PERCENTAGE
261253

262254
# Check that a TX rate limiter can be removed.
263255
_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-
)
256+
rate_no_limit_kbps = _get_tx_bandwidth(test_microvm, eth0.host_ip)
267257
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
268258
# than the one when rate limiting was enabled.
269259
assert _diff(rate_no_limit_kbps, expected_kbps) > 50
@@ -295,11 +285,11 @@ def _check_rx_rate_limit_patch(test_microvm):
295285
assert _diff(rate_no_limit_kbps, expected_kbps) > 50
296286

297287

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

301291
iperf_cmd = "{} -c {} -t {} -f KBytes -w {} -N".format(
302-
IPERF_BINARY, host_ip, duration, IPERF_TCP_WINDOW
292+
IPERF_BINARY, host_ip, IPERF_TRANSMIT_TIME, IPERF_TCP_WINDOW
303293
)
304294
iperf_out = _run_iperf_on_guest(test_microvm, iperf_cmd)
305295
print(iperf_out)

0 commit comments

Comments
 (0)