Skip to content

Commit

Permalink
tests: add --tracing and --duration flags
Browse files Browse the repository at this point in the history
  • Loading branch information
choppsv1 committed Sep 19, 2023
1 parent f0a5099 commit 3541ec5
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 deletions.
21 changes: 17 additions & 4 deletions tests/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

g_offloads = [
# These are both required on my machine to get rid of GSO
# "generic-receive-offload",
# "rx-gro-hw",
"generic-receive-offload",
"rx-gro-hw",
# # These are not required to get rid of GSO in iptfs path
# # "generic-segmentation-offload",
# # "tcp-segmentation-offload",
Expand Down Expand Up @@ -64,11 +64,10 @@ async def _network_up(
await ethtool_disable_offloads(r2, g_offloads)

await toggle_ipv6(unet, enable=ipv6)
await toggle_ecn(unet, enable=True)
await toggle_forward_pmtu(unet, enable=False)
await toggle_forwarding(unet, enable=True)

await toggle_ipv6(unet, enable=ipv6)

if ipv4:
if h1:
h1.cmd_raises("ip route add 10.0.2.0/24 via 10.0.0.2")
Expand Down Expand Up @@ -205,6 +204,7 @@ async def _network_up3(unet, ipv4=True, ipv6=False, trex=False, minimal=False):
await ethtool_disable_offloads(r2, g_offloads)

await toggle_ipv6(unet, enable=ipv6)
await toggle_ecn(unet, enable=True)
await toggle_forward_pmtu(unet, enable=False)
await toggle_forwarding(unet, enable=True)

Expand Down Expand Up @@ -366,6 +366,19 @@ async def cleanup_config3(unet, ipv4=True, ipv6=False):
r2con.cmd_nostatus("ip x p deleteall")


async def toggle_ecn(unet, enable=False):
nodes = list(unet.hosts.values())
if unet.isolated:
nodes.append(unet)
for node in nodes:
if enable:
node.cmd_raises("sysctl -w net.ipv4.tcp_ecn=1")
node.cmd_raises("sysctl -w net.ipv4.tcp_ecn_fallback=0")
else:
node.cmd_raises("sysctl -w net.ipv4.tcp_ecn=0")
node.cmd_raises("sysctl -w net.ipv4.tcp_ecn_fallback=1")


async def toggle_forward_pmtu(unet, enable=False):
nodes = list(unet.hosts.values())
if unet.isolated:
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@


def pytest_addoption(parser): # pylint: disable=E0102
parser.addoption(
"--duration",
default=10.0,
type=float,
help="Enable tracing if supported by test",
)

parser.addoption(
"--enable-ipv6",
action="store_true",
Expand Down
8 changes: 6 additions & 2 deletions tests/iperf/iperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ async def _test_iperf(
profile=False,
profcount=0,
tracing=False,
duration=10,
):
h1 = unet.hosts["h1"]
h2 = unet.hosts["h2"]
Expand Down Expand Up @@ -187,7 +188,7 @@ async def _test_iperf(
if ipv6:
cargs.append("-V")

tval = 3
tval = duration

if use_iperf3:
args = [
Expand Down Expand Up @@ -249,7 +250,10 @@ async def _test_iperf(
# timeout = True
# o, e = await iperfc.communicate()
try:
rc = iperfc.wait(timeout=tval + 5)
if tval > 60:
rc = iperfc.wait(timeout=tval + 20)
else:
rc = iperfc.wait(timeout=tval + 5)
timeout = False
except subprocess.TimeoutExpired:
logging.error("Timeout expired!")
Expand Down
16 changes: 8 additions & 8 deletions tests/iperf/munet_phy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ topology:
hostintf: "enp27s0f0v0"
ip: 10.0.0.1/24
ipv6: "fc00:0:0:0::1/64"
# mtu: 9000
mtu: 1400
mtu: 9000
# mtu: 1400
- name: r1
kind: linux
connections:
Expand All @@ -30,8 +30,8 @@ topology:
physical: "0000:d8:02.0"
ip: 10.0.0.2/24
ipv6: "fc00:0:0:0::2/64"
# mtu: 9000
mtu: 1400
mtu: 9000
# mtu: 1400
- name: r2
kind: linux
connections:
Expand All @@ -45,17 +45,17 @@ topology:
physical: "0000:d8:0a.0"
ip: 10.0.2.3/24
ipv6: "fc00:0:0:2::3/64"
# mtu: 9000
mtu: 1400
mtu: 9000
# mtu: 1400
- name: h2
connections:
- to: mgmt0
- to: r2
hostintf: "enp27s0f1v0"
ip: 10.0.2.4/24
ipv6: "fc00:0:0:2::4/64"
# mtu: 9000
mtu: 1400
mtu: 9000
# mtu: 1400

kinds:
- name: linux
Expand Down
11 changes: 11 additions & 0 deletions tests/iperf/test_iperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ async def _unet(rundir_module, pytestconfig):


# @pytest.mark.parametrize("iptfs_opts", ["init-delay 500"], scope="function")
# @pytest.mark.parametrize("pktsize", [None, 88, 536, 8000])
# @pytest.mark.parametrize("ipv6", [False, True])
# @pytest.mark.parametrize("tun_ipv6", [False, True])
# @pytest.mark.parametrize("routed", [False, True])

# @pytest.mark.parametrize(
# "iptfs_opts", ["pkt-size 256 max-queue-size 100000"], scope="function"
# )


@pytest.mark.parametrize("iptfs_opts", [""], scope="function")
@pytest.mark.parametrize("pktsize", [None, 88, 536, 1442])
@pytest.mark.parametrize("ipv6", [False, True])
Expand Down Expand Up @@ -179,6 +189,7 @@ async def test_iperf(
profile=pytestconfig.getoption("--profile", False),
profcount=test_iperf.count,
tracing=pytestconfig.getoption("--tracing", False),
duration=pytestconfig.getoption("--duration", 10.0),
)
assert result, "No result from test!"

Expand Down
15 changes: 14 additions & 1 deletion tests/iperf/test_iperf_phy.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,19 @@ async def test_tun_up(lcl_unet, astepf):
check_logs(unet)


# overrun the queue setup
# @pytest.mark.parametrize(
# "iptfs_opts", ["pkt-size 256 max-queue-size 100000"], scope="function"
# )
# @pytest.mark.parametrize("pktsize", [8000])
# @pytest.mark.parametrize("ipv6", [False])
# @pytest.mark.parametrize("tun_ipv6", [False])
# @pytest.mark.parametrize("routed", [False])

# @pytest.mark.parametrize("iptfs_opts", ["", "dont-frag"], 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")
# @pytest.mark.parametrize("tun_ipv6", [False, True], scope="function")
Expand All @@ -127,7 +139,7 @@ async def test_iperf(

if not unet.ipv6_enable and tun_ipv6:
pytest.skip("skipping ipv6 as --enable-ipv6 not specified")
if tun_ipv6 and pktsize and pktsize < 536:
if ipv6 and pktsize and pktsize < 536:
pytest.skip("Can't run IPv6 iperf with MSS < 536")
return

Expand All @@ -154,6 +166,7 @@ async def test_iperf(
profile=pytestconfig.getoption("--profile", False),
profcount=test_iperf.count,
tracing=pytestconfig.getoption("--tracing", False),
duration=pytestconfig.getoption("--duration", 10.0),
)
assert result, "No result from test!"

Expand Down

0 comments on commit 3541ec5

Please sign in to comment.