Skip to content

Commit

Permalink
tests: iperf with profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
choppsv1 committed Sep 13, 2023
1 parent 9c98571 commit ff3b3e7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
14 changes: 6 additions & 8 deletions tests/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def line_rate_to_pps(args, l1_rate, ipmtu, iptfs_mtu):
return pps


async def start_profile(unet, hostname, tval):
def start_profile(unet, hostname, tval):
perfargs = [
"perf",
"record",
Expand All @@ -298,24 +298,22 @@ async def start_profile(unet, hostname, tval):
tval,
]
host = unet.hosts[hostname]
await host.async_cmd_raises("sysctl -w kernel.perf_cpu_time_max_percent=75")
host.cmd_raises("sysctl -w kernel.perf_cpu_time_max_percent=75")
logging.info("Starting perf-profile on %s for %s", hostname, tval)

p = await host.async_popen(perfargs, use_pty=True, start_new_session=True)
p = host.popen(perfargs, use_pty=True, start_new_session=True)
p.host = host
return p


async def stop_profile(p, filebase="perf.data"):
def stop_profile(p, filebase="perf.data"):
try:
try:
# logging.info("signaling perf to exit")
# p.send_signal(signal.SIGTERM)
logging.info("waiting for perf to exit")
o, e = await asyncio.wait_for(p.communicate(), timeout=5.0)
o = o.decode("utf-8")
o, e = p.communicate(timeout=5.0)
o = "\nerror:\n" + o if o else ""
e = e.decode("utf-8")
e = "\nerror:\n" + e if e else ""
logging.info(
"perf rc: %s%s%s",
Expand All @@ -338,7 +336,7 @@ async def stop_profile(p, filebase="perf.data"):
logging.info("terminating perf")
p.terminate()
try:
_, e = await asyncio.wait_for(p.communicate(), timeout=2.0)
_, e = p.communicate(timeout=2.0)
logging.warning("perf rc: %s error: %s", p.returncode, e)
except TimeoutError:
logging.warning(
Expand Down
12 changes: 6 additions & 6 deletions tests/iperf/iperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ async def _test_iperf(

iperfs = h2.popen(sargs)

tracing = True
leakcheck = True
tracing = False
leakcheck = False
# watch "awk '/^kmalloc-128/{print \$2}'" /proc/slabinfo
# perfs = None
try:
Expand Down Expand Up @@ -187,7 +187,7 @@ async def _test_iperf(
if ipv6:
cargs.append("-V")

tval = 3
tval = 10

if use_iperf3:
args = [
Expand Down Expand Up @@ -227,7 +227,7 @@ async def _test_iperf(
]

# Start profiling if enabled
perfc = await start_profile(unet, "r1", tval + 1) if profile else None
perfc = start_profile(unet, "r1", tval + 1) if profile else None

logging.info("Starting iperf client on h1 for %s", tval)
# logging.info("Starting iperf3 client on h1 at %s for %s", brate, tval)
Expand Down Expand Up @@ -328,13 +328,13 @@ async def _test_iperf(
).strip(), f"leaks found on {rname}"

if perfc:
await stop_profile(perfc, filebase=f"perf-{profcount}.data")
stop_profile(perfc, filebase=f"perf-{profcount}.data")
perfc = None
# result = json.loads(o)
# logging.info("Results: %s", json.dumps(result, sort_keys=True, indent=2))
finally:
if perfc:
await stop_profile(perfc, filebase=f"perf-{profcount}.data")
stop_profile(perfc, filebase=f"perf-{profcount}.data")
perfc = None
if tracing:
# disable tracing
Expand Down
8 changes: 5 additions & 3 deletions tests/iperf/test_iperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ async def _unet(rundir_module, pytestconfig):
# pktsize == 2916 works, 2917+ doesn't


@pytest.mark.parametrize("iptfs_opts", ["", "dont-frag"])
@pytest.mark.parametrize("pktsize", [None, 64, 536, 1442])
# @pytest.mark.parametrize("iptfs_opts", ["init-delay 500"], scope="function")
@pytest.mark.parametrize("iptfs_opts", [""], scope="function")
@pytest.mark.parametrize("pktsize", [None, 88, 536, 1442])
@pytest.mark.parametrize("ipv6", [False, True])
@pytest.mark.parametrize("tun_ipv6", [False, True])
@pytest.mark.parametrize("routed", [False, True])
Expand Down Expand Up @@ -180,7 +181,8 @@ async def test_iperf(
)
assert result, "No result from test!"

fname = unet.rundir.joinpath("../speed.csv")
rundir = str(unet.rundir)
fname = rundir[: rundir.rindex("/")] + "/speed.csv"
fmode = "w+" if test_iperf.count == 0 else "a+"
tunstr = "routed" if routed else "policy"
vstr = "IPv6" if tun_ipv6 else "IPv4"
Expand Down
5 changes: 4 additions & 1 deletion tests/iperf/test_iperf_phy.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ async def test_tun_up(lcl_unet, astepf):
# @pytest.mark.parametrize("routed", [False, True], scope="function")


# @pytest.mark.parametrize("iptfs_opts", ["init-delay 1000"], scope="function")


@pytest.mark.parametrize("iptfs_opts", [""], scope="function")
@pytest.mark.parametrize("pktsize", [None, 88, 536, 1442], scope="function")
@pytest.mark.parametrize("ipv6", [False, True], scope="function")
Expand Down Expand Up @@ -153,7 +156,7 @@ async def test_iperf(
)
assert result, "No result from test!"

fname = os.path.join(rundir, "../speed-phy.csv")
fname = rundir[: rundir.rindex("/")] + "/speed-phy.csv"
fmode = "w+" if test_iperf.count == 0 else "a+"
tunstr = "routed" if routed else "policy"
vstr = "IPv6" if tun_ipv6 else "IPv4"
Expand Down

0 comments on commit ff3b3e7

Please sign in to comment.