Skip to content

Commit 6cd6af4

Browse files
pb8oroypat
authored andcommitted
tests: remove spurious assignments
Remove some assignments without purpose. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 3fd5c90 commit 6cd6af4

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

tests/integration_tests/performance/test_rate_limiter.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_rx_rate_limiting_cpu_load(uvm_plain):
104104
test_microvm.start()
105105

106106
# Start iperf server on guest.
107-
_start_iperf_server_on_guest(test_microvm, iface.guest_ip)
107+
_start_iperf_server_on_guest(test_microvm)
108108

109109
# Run iperf client sending UDP traffic.
110110
iperf_cmd = "{} {} -u -c {} -b 1000000000 -t{} -f KBytes".format(
@@ -143,7 +143,7 @@ def _check_tx_rate_limiting(test_microvm):
143143
# We are receiving the result in KBytes from iperf.
144144
print("Run guest TX iperf with no rate-limit")
145145
rate_no_limit_kbps = _get_tx_bandwidth_with_duration(
146-
test_microvm, eth0.guest_ip, eth0.host_ip, IPERF_TRANSMIT_TIME
146+
test_microvm, eth0.host_ip, IPERF_TRANSMIT_TIME
147147
)
148148
print("TX rate_no_limit_kbps: {}".format(rate_no_limit_kbps))
149149

@@ -157,7 +157,7 @@ def _check_tx_rate_limiting(test_microvm):
157157
assert _get_percentage_difference(rate_no_limit_kbps, expected_kbps) > 100
158158

159159
# Second step: check bandwidth when rate limiting is on.
160-
_check_tx_bandwidth(test_microvm, eth1.guest_ip, eth1.host_ip, expected_kbps)
160+
_check_tx_bandwidth(test_microvm, eth1.host_ip, expected_kbps)
161161

162162
# Third step: get the number of bytes when rate limiting is on and there is
163163
# an initial burst size from where to consume.
@@ -167,15 +167,15 @@ def _check_tx_rate_limiting(test_microvm):
167167
iperf_cmd = "{} -c {} -n {} -f KBytes -w {} -N".format(
168168
IPERF_BINARY, eth2.host_ip, BURST_SIZE, IPERF_TCP_WINDOW
169169
)
170-
iperf_out = _run_iperf_on_guest(test_microvm, iperf_cmd, eth2.guest_ip)
170+
iperf_out = _run_iperf_on_guest(test_microvm, iperf_cmd)
171171
print(iperf_out)
172172
_, burst_kbps = _process_iperf_output(iperf_out)
173173
print("TX burst_kbps: {}".format(burst_kbps))
174174
# Test that the burst bandwidth is at least as two times the rate limit.
175175
assert _get_percentage_difference(burst_kbps, expected_kbps) > 100
176176

177177
# Since the burst should be consumed, check rate limit is in place.
178-
_check_tx_bandwidth(test_microvm, eth2.guest_ip, eth2.host_ip, expected_kbps)
178+
_check_tx_bandwidth(test_microvm, eth2.host_ip, expected_kbps)
179179

180180

181181
def _check_rx_rate_limiting(test_microvm):
@@ -185,7 +185,7 @@ def _check_rx_rate_limiting(test_microvm):
185185
eth2 = test_microvm.iface["eth2"]["iface"]
186186

187187
# Start iperf server on guest.
188-
_start_iperf_server_on_guest(test_microvm, eth0.guest_ip)
188+
_start_iperf_server_on_guest(test_microvm)
189189

190190
# First step: get the transfer rate when no rate limiting is enabled.
191191
# We are receiving the result in KBytes from iperf.
@@ -240,16 +240,16 @@ def _check_tx_rate_limit_patch(test_microvm):
240240
# Check that a TX rate limiter can be applied to a previously unlimited
241241
# interface.
242242
_patch_iface_bw(test_microvm, "eth0", "TX", bucket_size, REFILL_TIME_MS)
243-
_check_tx_bandwidth(test_microvm, eth0.guest_ip, eth0.host_ip, expected_kbps)
243+
_check_tx_bandwidth(test_microvm, eth0.host_ip, expected_kbps)
244244

245245
# Check that a TX rate limiter can be updated.
246246
_patch_iface_bw(test_microvm, "eth1", "TX", bucket_size, REFILL_TIME_MS)
247-
_check_tx_bandwidth(test_microvm, eth1.guest_ip, eth1.host_ip, expected_kbps)
247+
_check_tx_bandwidth(test_microvm, eth1.host_ip, expected_kbps)
248248

249249
# Check that a TX rate limiter can be removed.
250250
_patch_iface_bw(test_microvm, "eth0", "TX", 0, 0)
251251
rate_no_limit_kbps = _get_tx_bandwidth_with_duration(
252-
test_microvm, eth0.guest_ip, eth0.host_ip, IPERF_TRANSMIT_TIME
252+
test_microvm, eth0.host_ip, IPERF_TRANSMIT_TIME
253253
)
254254
# Check that bandwidth when rate-limit disabled is at least 1.5x larger
255255
# than the one when rate limiting was enabled.
@@ -282,15 +282,15 @@ def _check_rx_rate_limit_patch(test_microvm):
282282
assert _get_percentage_difference(rate_no_limit_kbps, expected_kbps) > 50
283283

284284

285-
def _check_tx_bandwidth(test_microvm, guest_ip, host_ip, expected_kbps):
285+
def _check_tx_bandwidth(test_microvm, ip, expected_kbps):
286286
"""Check that the rate-limited TX bandwidth is close to what we expect.
287287
288288
At this point, a daemonized iperf3 server is expected to be running on
289289
the host.
290290
"""
291291
print("Check guest TX rate-limit; expected kbps {}".format(expected_kbps))
292292
observed_kbps = _get_tx_bandwidth_with_duration(
293-
test_microvm, guest_ip, host_ip, IPERF_TRANSMIT_TIME
293+
test_microvm, ip, IPERF_TRANSMIT_TIME
294294
)
295295

296296
diff_pc = _get_percentage_difference(observed_kbps, expected_kbps)
@@ -300,37 +300,37 @@ def _check_tx_bandwidth(test_microvm, guest_ip, host_ip, expected_kbps):
300300
print("Short duration test failed. Try another run with 10x duration.")
301301

302302
observed_kbps = _get_tx_bandwidth_with_duration(
303-
test_microvm, guest_ip, host_ip, 10 * IPERF_TRANSMIT_TIME
303+
test_microvm, ip, 10 * IPERF_TRANSMIT_TIME
304304
)
305305
diff_pc = _get_percentage_difference(observed_kbps, expected_kbps)
306306
print("TX calculated diff percentage: {}\n".format(diff_pc))
307307

308308
assert diff_pc < MAX_BYTES_DIFF_PERCENTAGE
309309

310310

311-
def _get_tx_bandwidth_with_duration(test_microvm, guest_ip, host_ip, duration):
311+
def _get_tx_bandwidth_with_duration(test_microvm, host_ip, duration):
312312
"""Check that the rate-limited TX bandwidth is close to what we expect."""
313313
iperf_cmd = "{} -c {} -t {} -f KBytes -w {} -N".format(
314314
IPERF_BINARY, host_ip, duration, IPERF_TCP_WINDOW
315315
)
316316

317-
iperf_out = _run_iperf_on_guest(test_microvm, iperf_cmd, guest_ip)
317+
iperf_out = _run_iperf_on_guest(test_microvm, iperf_cmd)
318318
print(iperf_out)
319319

320320
_, observed_kbps = _process_iperf_output(iperf_out)
321321
print("TX observed_kbps: {}".format(observed_kbps))
322322
return observed_kbps
323323

324324

325-
def _check_rx_bandwidth(test_microvm, guest_ip, expected_kbps):
325+
def _check_rx_bandwidth(test_microvm, ip, expected_kbps):
326326
"""Check that the rate-limited RX bandwidth is close to what we expect.
327327
328328
At this point, a daemonized iperf3 server is expected to be running on
329329
the guest.
330330
"""
331331
print("Check guest RX rate-limit; expected kbps {}".format(expected_kbps))
332332
observed_kbps = _get_rx_bandwidth_with_duration(
333-
test_microvm, guest_ip, IPERF_TRANSMIT_TIME
333+
test_microvm, ip, IPERF_TRANSMIT_TIME
334334
)
335335

336336
diff_pc = _get_percentage_difference(observed_kbps, expected_kbps)
@@ -340,7 +340,7 @@ def _check_rx_bandwidth(test_microvm, guest_ip, expected_kbps):
340340
print("Short duration test failed. Try another run with 10x duration.")
341341

342342
observed_kbps = _get_rx_bandwidth_with_duration(
343-
test_microvm, guest_ip, 10 * IPERF_TRANSMIT_TIME
343+
test_microvm, ip, 10 * IPERF_TRANSMIT_TIME
344344
)
345345
diff_pc = _get_percentage_difference(observed_kbps, expected_kbps)
346346
print("TX calculated diff percentage: {}\n".format(diff_pc))
@@ -381,20 +381,17 @@ def _patch_iface_bw(test_microvm, iface_id, rx_or_tx, new_bucket_size, new_refil
381381
test_microvm.api.network.patch(**args)
382382

383383

384-
def _start_iperf_server_on_guest(test_microvm, hostname):
384+
def _start_iperf_server_on_guest(test_microvm):
385385
"""Start iperf in server mode through an SSH connection."""
386-
test_microvm.guest_ip = hostname
387-
388386
iperf_cmd = "{} -sD -f KBytes\n".format(IPERF_BINARY)
389387
test_microvm.ssh.run(iperf_cmd)
390388

391389
# Wait for the iperf daemon to start.
392390
time.sleep(1)
393391

394392

395-
def _run_iperf_on_guest(test_microvm, iperf_cmd, hostname):
393+
def _run_iperf_on_guest(test_microvm, iperf_cmd):
396394
"""Run a client related iperf command through an SSH connection."""
397-
test_microvm.guest_ip = hostname
398395
return test_microvm.ssh.check_output(iperf_cmd).stdout
399396

400397

0 commit comments

Comments
 (0)