Skip to content

Commit 6dedfa5

Browse files
zulinx86wearyzen
authored andcommitted
refactor(test): Clarify iperf3 setting
Some comments were confusing, since their descriptions were vague or wrong. To make it easy to understand what tests do, clarify iperf3 settings (server or client mode and on host or guest). Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent d606df5 commit 6dedfa5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/integration_tests/functional/test_rate_limiter.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_rx_rate_limiting_cpu_load(test_microvm_with_api, network_config):
154154
test_microvm.start()
155155

156156
# Start iperf server on guest.
157-
_start_iperf_on_guest(test_microvm, guest_ip)
157+
_start_iperf_server_on_guest(test_microvm, guest_ip)
158158

159159
# Run iperf client sending UDP traffic.
160160
iperf_cmd = "{} {} -u -c {} -b 1000000000 -t{} -f KBytes".format(
@@ -177,13 +177,13 @@ def test_rx_rate_limiting_cpu_load(test_microvm_with_api, network_config):
177177
threshold=20,
178178
)
179179
with cpu_load_monitor:
180-
_run_local_iperf(iperf_cmd)
180+
_run_iperf_on_host(iperf_cmd)
181181

182182

183183
def _check_tx_rate_limiting(test_microvm, guest_ips, host_ips):
184184
"""Check that the transmit rate is within expectations."""
185-
# Start iperf on the host as this is the tx rate limiting test.
186-
_start_local_iperf(test_microvm.jailer.netns_cmd_prefix())
185+
# Start iperf server on the host as this is the tx rate limiting test.
186+
_start_iperf_server_on_host(test_microvm.jailer.netns_cmd_prefix())
187187

188188
# First step: get the transfer rate when no rate limiting is enabled.
189189
# We are receiving the result in KBytes from iperf.
@@ -226,8 +226,8 @@ def _check_tx_rate_limiting(test_microvm, guest_ips, host_ips):
226226

227227
def _check_rx_rate_limiting(test_microvm, guest_ips):
228228
"""Check that the receiving rate is within expectations."""
229-
# Start iperf on guest.
230-
_start_iperf_on_guest(test_microvm, guest_ips[0])
229+
# Start iperf server on guest.
230+
_start_iperf_server_on_guest(test_microvm, guest_ips[0])
231231

232232
# First step: get the transfer rate when no rate limiting is enabled.
233233
# We are receiving the result in KBytes from iperf.
@@ -251,7 +251,7 @@ def _check_rx_rate_limiting(test_microvm, guest_ips):
251251

252252
# Third step: get the number of bytes when rate limiting is on and there is
253253
# an initial burst size from where to consume.
254-
print("Run guest TX iperf with exact burst size")
254+
print("Run guest RX iperf with exact burst size")
255255
# Use iperf to obtain the bandwidth when there is burst to consume from,
256256
# send exactly BURST_SIZE packets.
257257
iperf_cmd = "{} {} -c {} -n {} -f KBytes -w {} -N".format(
@@ -261,7 +261,7 @@ def _check_rx_rate_limiting(test_microvm, guest_ips):
261261
BURST_SIZE,
262262
IPERF_TCP_WINDOW,
263263
)
264-
iperf_out = _run_local_iperf(iperf_cmd)
264+
iperf_out = _run_iperf_on_host(iperf_cmd)
265265
print(iperf_out)
266266
_, burst_kbps = _process_iperf_output(iperf_out)
267267
print("RX burst_kbps: {}".format(burst_kbps))
@@ -395,7 +395,7 @@ def _get_rx_bandwidth_with_duration(test_microvm, guest_ip, duration):
395395
duration,
396396
IPERF_TCP_WINDOW,
397397
)
398-
iperf_out = _run_local_iperf(iperf_cmd)
398+
iperf_out = _run_iperf_on_host(iperf_cmd)
399399
print(iperf_out)
400400

401401
_, observed_kbps = _process_iperf_output(iperf_out)
@@ -420,7 +420,7 @@ def _patch_iface_bw(test_microvm, iface_id, rx_or_tx, new_bucket_size, new_refil
420420
assert test_microvm.api_session.is_status_no_content(resp.status_code)
421421

422422

423-
def _start_iperf_on_guest(test_microvm, hostname):
423+
def _start_iperf_server_on_guest(test_microvm, hostname):
424424
"""Start iperf in server mode through an SSH connection."""
425425
test_microvm.ssh_config["hostname"] = hostname
426426

@@ -441,7 +441,7 @@ def _run_iperf_on_guest(test_microvm, iperf_cmd, hostname):
441441
return out
442442

443443

444-
def _start_local_iperf(netns_cmd_prefix):
444+
def _start_iperf_server_on_host(netns_cmd_prefix):
445445
"""Start iperf in server mode after killing any leftover iperf daemon."""
446446
iperf_cmd = "pkill {}\n".format(IPERF_BINARY)
447447

@@ -457,7 +457,7 @@ def _start_local_iperf(netns_cmd_prefix):
457457
time.sleep(1)
458458

459459

460-
def _run_local_iperf(iperf_cmd):
460+
def _run_iperf_on_host(iperf_cmd):
461461
"""Execute a client related iperf command locally."""
462462
code, stdout, stderr = utils.run_cmd(iperf_cmd)
463463
assert code == 0, f"stdout: {stdout}\nstderr: {stderr}"

0 commit comments

Comments
 (0)