Skip to content

Commit

Permalink
tests: more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
choppsv1 committed Aug 30, 2023
1 parent 6b435ee commit 272c336
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 18 deletions.
35 changes: 26 additions & 9 deletions tests/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ async def _network_up3(unet, ipv4=True, ipv6=False, trex=False, minimal=False):

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

if h1:
if ipv4:
Expand Down Expand Up @@ -332,8 +333,8 @@ async def cleanup_config3(unet, ipv4=True, ipv6=False):
# The route used by the tunnel packets
r2con.cmd_nostatus("ip route del 10.0.1.2/32 via 10.0.2.3")

r2con.cmd_nostatus("ip route del 10.0.0.0/24 dev ipsec0")
r2con.cmd_nostatus("ip route del 10.0.1.0/24 dev ipsec0")
r2con.cmd_nostatus("ip route del 10.0.0.0/24 dev ipsec0")
r2con.cmd_nostatus("ip route del 11.0.0.0/24 dev ipsec0")
r2con.cmd_nostatus("ip route del 16.0.0.0/8 dev ipsec0")

Expand All @@ -346,13 +347,13 @@ async def cleanup_config3(unet, ipv4=True, ipv6=False):
# The route used by the tunnel packets
r2con.cmd_nostatus("ip route del fc00:0:0:1::2/128 via fc00:0:0:2::3")

r2con.cmd_nostatus("ip route del fc00:0:0:0::/64 dev ipsec0")
r2con.cmd_nostatus("ip route del fc00:0:0:1::/64 dev ipsec0")
r2con.cmd_nostatus("ip route del fc00:0:0:0::/64 dev ipsec0")
r2con.cmd_nostatus("ip route del 2011::/64 dev ipsec0")
r2con.cmd_nostatus("ip route del 2016::/16 dev ipsec0")

r2con.cmd_nostatus("ip -6 route del fc00:0:0:0::/64 via fc00:0:0:2::3")
r2con.cmd_nostatus("ip -6 route del fc00:0:0:1::/64 via fc00:0:0:2::3")
r2con.cmd_nostatus("ip -6 route del fc00:0:0:0::/64 via fc00:0:0:2::3")
r2con.cmd_nostatus("ip -6 route del 2011::/64 via fc00:0:0:2::3")
r2con.cmd_nostatus("ip -6 route del 2016::/16 via fc00:0:0:2::3")

Expand All @@ -372,6 +373,19 @@ async def toggle_forward_pmtu(unet, enable=False):
node.cmd_raises("sysctl -w net.ipv4.ip_forward_use_pmtu=0")


async def toggle_forwarding(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.ip_forward=1")
node.cmd_raises("sysctl -w net.ipv6.conf.all.forwarding=1")
else:
node.cmd_raises("sysctl -w net.ipv4.ip_forward=0")
node.cmd_raises("sysctl -w net.ipv6.conf.all.forwarding=0")


async def toggle_ipv6(unet, enable=False):
nodes = list(unet.hosts.values())
if unet.isolated:
Expand Down Expand Up @@ -859,12 +873,14 @@ async def setup_routed_tun(
if ipv4:
if not trex:
if r1con:
r1con.cmd_raises(f"ip route add 10.0.2.0/24 dev ipsec0 {r1srcip}")
if network3:
r1con.cmd_raises(f"ip route add 10.0.3.0/24 dev ipsec0 {r1srcip}")
else:
r1con.cmd_raises(f"ip route add 10.0.2.0/24 dev ipsec0 {r1srcip}")
if r2con:
r2con.cmd_raises(f"ip route add 10.0.0.0/24 dev ipsec0 {r2srcip}")
if network3:
r2con.cmd_raises(f"ip route add 10.0.1.0/24 dev ipsec0 {r2srcip}")

else:
if r1con:
r1con.cmd_raises(f"ip route add 12.0.0.0/24 dev ipsec0 {r1srcip}")
Expand All @@ -877,16 +893,17 @@ async def setup_routed_tun(
if ipv6:
if not trex:
if r1con:
r1con.cmd_raises(f"ip route add fc00:0:0:2::/64 dev ipsec0 {r1srcip6}")
if network3:
r1con.cmd_raises(
f"ip route add fc00:0:0:3::/64 dev ipsec0 {r1srcip6}"
)
else:
r1con.cmd_raises(
f"ip route add fc00:0:0:2::/64 dev ipsec0 {r1srcip6}"
)
if r2con:
r2con.cmd_raises(f"ip route add fc00:0:0:0::/64 dev ipsec0 {r2srcip6}")
if network3:
r2con.cmd_raises(
f"ip route add fc00:0:0:1::/64 dev ipsec0 {r2srcip6}"
)
else:
if r1con:
r1con.cmd_raises(f"ip route add 2012::/64 dev ipsec0 {r1srcip6}")
Expand Down
80 changes: 76 additions & 4 deletions tests/common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,28 @@ async def _test_net_up3(unet, mgmt0=True, ipv4=True, ipv6=False, minimal=False):
logging.debug(h1.cmd_nostatus("ping -c1 10.0.0.2"))
logging.debug(h1.cmd_raises("ping -c1 10.0.0.2"))

logging.debug(h1.cmd_nostatus("ping -c1 10.0.1.2"))
logging.debug(h1.cmd_raises("ping -c1 10.0.1.2"))
logging.debug(r1con.cmd_nostatus("ping -c1 10.0.1.3"))
logging.debug(r1con.cmd_raises("ping -c1 10.0.1.3"))

# logging.debug(r1con.cmd_nostatus("ping -c1 10.0.2.4"))
# logging.debug(r1con.cmd_raises("ping -c1 10.0.2.4"))

# logging.debug(r2con.cmd_nostatus("ping -c1 10.0.1.3"))
# logging.debug(r2con.cmd_raises("ping -c1 10.0.1.3"))

logging.debug(r2con.cmd_nostatus("ping -c1 10.0.2.4"))
logging.debug(r2con.cmd_raises("ping -c1 10.0.2.4"))

logging.debug(h2.cmd_nostatus("ping -c1 10.0.3.4"))
logging.debug(h2.cmd_raises("ping -c1 10.0.3.4"))

if not minimal:
logging.debug(h1.cmd_nostatus("ping -c1 10.0.1.2"))
logging.debug(h1.cmd_raises("ping -c1 10.0.1.2"))

logging.debug(h1.cmd_nostatus("ping -c1 10.0.1.3"))
logging.debug(h1.cmd_raises("ping -c1 10.0.1.3"))

logging.debug(h1.cmd_nostatus("ping -c1 10.0.2.3"))
logging.debug(h1.cmd_raises("ping -c1 10.0.2.3"))

Expand All @@ -187,6 +205,24 @@ async def _test_net_up3(unet, mgmt0=True, ipv4=True, ipv6=False, minimal=False):
logging.debug(h1.cmd_nostatus("ping -c1 10.0.3.5"))
logging.debug(h1.cmd_raises("ping -c1 10.0.3.5"))

logging.debug(h2.cmd_nostatus("ping -c1 10.0.2.4"))
logging.debug(h2.cmd_raises("ping -c1 10.0.2.4"))

logging.debug(h2.cmd_nostatus("ping -c1 10.0.2.3"))
logging.debug(h2.cmd_raises("ping -c1 10.0.2.3"))

logging.debug(h2.cmd_nostatus("ping -c1 10.0.1.3"))
logging.debug(h2.cmd_raises("ping -c1 10.0.1.3"))

logging.debug(h2.cmd_nostatus("ping -c1 10.0.1.2"))
logging.debug(h2.cmd_raises("ping -c1 10.0.1.2"))

logging.debug(h2.cmd_nostatus("ping -c1 10.0.0.2"))
logging.debug(h2.cmd_raises("ping -c1 10.0.0.2"))

logging.debug(h2.cmd_nostatus("ping -c1 10.0.0.1"))
logging.debug(h2.cmd_raises("ping -c1 10.0.0.1"))

if ipv6:
# Don't use short deadlines NDisc requires more time than arp.
if mgmt0:
Expand All @@ -205,10 +241,28 @@ async def _test_net_up3(unet, mgmt0=True, ipv4=True, ipv6=False, minimal=False):
logging.debug(h1.cmd_nostatus("ping -c1 fc00:0:0:0::2"))
logging.debug(h1.cmd_raises("ping -c1 fc00:0:0:0::2"))

logging.debug(h1.cmd_nostatus("ping -c1 fc00:0:0:1::2"))
logging.debug(h1.cmd_raises("ping -c1 fc00:0:0:1::2"))
logging.debug(r1con.cmd_nostatus("ping -c1 fc00:0:0:1::3"))
logging.debug(r1con.cmd_raises("ping -c1 fc00:0:0:1::3"))

# logging.debug(r1con.cmd_nostatus("ping -c1 fc00:0:0:2::4"))
# logging.debug(r1con.cmd_raises("ping -c1 fc00:0:0:2::4"))

# logging.debug(r2con.cmd_nostatus("ping -c1 fc00:0:0:1::3"))
# logging.debug(r2con.cmd_raises("ping -c1 fc00:0:0:1::3"))

logging.debug(r2con.cmd_nostatus("ping -c1 fc00:0:0:2::4"))
logging.debug(r2con.cmd_raises("ping -c1 fc00:0:0:2::4"))

logging.debug(h2.cmd_nostatus("ping -c1 fc00:0:0:3::4"))
logging.debug(h2.cmd_raises("ping -c1 fc00:0:0:3::4"))

if not minimal:
logging.debug(h1.cmd_nostatus("ping -c1 fc00:0:0:1::2"))
logging.debug(h1.cmd_raises("ping -c1 fc00:0:0:1::2"))

logging.debug(h1.cmd_nostatus("ping -c1 fc00:0:0:1::3"))
logging.debug(h1.cmd_raises("ping -c1 fc00:0:0:1::3"))

logging.debug(h1.cmd_nostatus("ping -c1 fc00:0:0:2::3"))
logging.debug(h1.cmd_raises("ping -c1 fc00:0:0:2::3"))

Expand All @@ -220,3 +274,21 @@ async def _test_net_up3(unet, mgmt0=True, ipv4=True, ipv6=False, minimal=False):

logging.debug(h1.cmd_nostatus("ping -c1 fc00:0:0:3::5"))
logging.debug(h1.cmd_raises("ping -c1 fc00:0:0:3::5"))

logging.debug(h2.cmd_nostatus("ping -c1 fc00:0:0:2::4"))
logging.debug(h2.cmd_raises("ping -c1 fc00:0:0:2::4"))

logging.debug(h2.cmd_nostatus("ping -c1 fc00:0:0:1::3"))
logging.debug(h2.cmd_raises("ping -c1 fc00:0:0:1::3"))

logging.debug(h2.cmd_nostatus("ping -c1 fc00:0:0:2::3"))
logging.debug(h2.cmd_raises("ping -c1 fc00:0:0:2::3"))

logging.debug(h2.cmd_nostatus("ping -c1 fc00:0:0:1::2"))
logging.debug(h2.cmd_raises("ping -c1 fc00:0:0:1::2"))

logging.debug(h2.cmd_nostatus("ping -c1 fc00:0:0:0::2"))
logging.debug(h2.cmd_raises("ping -c1 fc00:0:0:0::2"))

logging.debug(h2.cmd_nostatus("ping -c1 fc00:0:0:0::1"))
logging.debug(h2.cmd_raises("ping -c1 fc00:0:0:0::1"))
18 changes: 13 additions & 5 deletions tests/mtu/test_mtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ async def test_routed_mtu(unet, astepf, pytestconfig):
unet, iptfs_opts=opts, tun_ipv6=ipv6, network3=True, tun_route_mtu=65535
)

await astepf("Send normal ping")
h1.cmd_nostatus("ping -W1 -c1 10.0.3.5", warn=False)
h1.cmd_raises("ping -c1 10.0.3.5")

await astepf("Send big ping")
# get the PTMU reply
h1.cmd_nostatus("ping -w1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_nostatus("ping -W1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_raises("ping -Mdo -s 5000 -c1 10.0.3.5")

await astepf("Test complete")
Expand All @@ -94,9 +98,13 @@ async def test_policy_with_routes_mtu(unet, astepf, pytestconfig):
tun_route_mtu=65535,
)

await astepf("Send normal ping")
h1.cmd_nostatus("ping -W1 -c1 10.0.3.5", warn=False)
h1.cmd_raises("ping -c1 10.0.3.5")

await astepf("Send big ping")
# get the PTMU reply
h1.cmd_nostatus("ping -w1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_nostatus("ping -W1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_raises("ping -Mdo -s 5000 -c1 10.0.3.5")


Expand Down Expand Up @@ -134,7 +142,7 @@ async def test_policy_with_table_routes_mtu(unet, astepf, pytestconfig):

await astepf("Send big ping")
# get the PTMU reply
h1.cmd_nostatus("ping -w1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_nostatus("ping -W1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_raises("ping -Mdo -s 5000 -c1 10.0.3.5")

await astepf("Test complete")
Expand Down Expand Up @@ -170,7 +178,7 @@ async def test_policy_with_default_route_mtu(unet, astepf, pytestconfig):

await astepf("Send big ping")
# get the PTMU reply
h1.cmd_nostatus("ping -w1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_nostatus("ping -W1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_raises("ping -Mdo -s 5000 -c1 10.0.3.5")

await astepf("Test complete")
Expand Down Expand Up @@ -216,7 +224,7 @@ async def test_policy_with_dummy_mtu(unet, astepf, pytestconfig):

await astepf("Send big ping")
# get the PTMU reply
h1.cmd_nostatus("ping -w1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_nostatus("ping -W1 -Mdo -s 5000 -c1 10.0.3.5", warn=False)
h1.cmd_raises("ping -Mdo -s 5000 -c1 10.0.3.5")

await astepf("Test complete")
Expand Down

0 comments on commit 272c336

Please sign in to comment.