Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions tests/integration_tests/performance/test_rate_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
# The iperf version to run this tests with
IPERF_BINARY = "iperf3"

# iperf server side log path inside guest
GUEST_IPERF_SERVER_LOG = "/tmp/iperf-server.log"

# Interval used by iperf to get maximum bandwidth
IPERF_TRANSMIT_TIME = 4

Expand Down Expand Up @@ -127,7 +130,7 @@ def test_rx_rate_limiting_cpu_load(uvm_plain):
threshold=20,
)
with cpu_load_monitor:
_run_iperf_on_host(iperf_cmd)
_run_iperf_on_host(iperf_cmd, test_microvm)


def _check_tx_rate_limiting(test_microvm):
Expand Down Expand Up @@ -219,8 +222,7 @@ def _check_rx_rate_limiting(test_microvm):
BURST_SIZE,
IPERF_TCP_WINDOW,
)
iperf_out = _run_iperf_on_host(iperf_cmd)
print(iperf_out)
iperf_out = _run_iperf_on_host(iperf_cmd, test_microvm)
_, burst_kbps = _process_iperf_output(iperf_out)
print("RX burst_kbps: {}".format(burst_kbps))
# Test that the burst bandwidth is at least as two times the rate limit.
Expand Down Expand Up @@ -357,9 +359,7 @@ def _get_rx_bandwidth_with_duration(test_microvm, guest_ip, duration):
duration,
IPERF_TCP_WINDOW,
)
iperf_out = _run_iperf_on_host(iperf_cmd)
print(iperf_out)

iperf_out = _run_iperf_on_host(iperf_cmd, test_microvm)
_, observed_kbps = _process_iperf_output(iperf_out)
print("RX observed_kbps: {}".format(observed_kbps))
return observed_kbps
Expand All @@ -383,7 +383,7 @@ def _patch_iface_bw(test_microvm, iface_id, rx_or_tx, new_bucket_size, new_refil

def _start_iperf_server_on_guest(test_microvm):
"""Start iperf in server mode through an SSH connection."""
iperf_cmd = "{} -sD -f KBytes\n".format(IPERF_BINARY)
iperf_cmd = f"{IPERF_BINARY} -sD -f KBytes --logfile {GUEST_IPERF_SERVER_LOG}"
test_microvm.ssh.run(iperf_cmd)

# Wait for the iperf daemon to start.
Expand Down Expand Up @@ -411,10 +411,15 @@ def _start_iperf_server_on_host(netns_cmd_prefix):
time.sleep(1)


def _run_iperf_on_host(iperf_cmd):
def _run_iperf_on_host(iperf_cmd, test_microvm):
"""Execute a client related iperf command locally."""
code, stdout, stderr = utils.check_output(iperf_cmd)
assert code == 0, f"stdout: {stdout}\nstderr: {stderr}"
rc, stdout, stderr = utils.run_cmd(iperf_cmd)
assert rc == 0, "stdout:\n{}\nstderr:\n{}\niperf server log:\n{}\n".format(
stdout,
stderr,
test_microvm.ssh.check_output(f"cat {GUEST_IPERF_SERVER_LOG}").stdout,
)
print(f"iperf log:\n{stdout}")

return stdout

Expand Down