From 7eb1817f2edfd1d4a8401cab34ad30b99da5a163 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 15 May 2024 07:05:53 +0000 Subject: [PATCH] test: case: static_routing: Restructure to reuse existing namespace Rather than setting up and tearing down two identical namespaces, create it once and use it for the duration of the test. (This is probably a documentation issue with Infamy: there is no requirement that test.steps are direct descendants of the test, but until this point there was no example of this in the source base) In the process of this, it was also discovered that no positive ping test was done over v6, so that has been added. --- test/case/ietf_routing/static_routing.py | 28 ++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/test/case/ietf_routing/static_routing.py b/test/case/ietf_routing/static_routing.py index 1e3bde60..54726772 100755 --- a/test/case/ietf_routing/static_routing.py +++ b/test/case/ietf_routing/static_routing.py @@ -214,31 +214,27 @@ with infamy.Test() as test: until(lambda: route.ipv6_route_exist(target1, "2001:db8:3c4d:200::1/128")) until(lambda: route.ipv6_route_exist(target2, "::/0")) - - with test.step("Ping from host to 192.168.200.1 and 2001:db8:3c4d:200::1 (dut2) through dut1"): - _, hport0 = env.ltop.xlate("host", "data1") - with infamy.IsolatedMacVlan(hport0) as ns0: + _, hport0 = env.ltop.xlate("host", "data1") + with infamy.IsolatedMacVlan(hport0) as ns0: + with test.step("Configure host addresses and routes"): ns0.addip("2001:db8:3c4d:10::2", prefix_length=64, proto="ipv6") ns0.addroute("2001:db8:3c4d:200::1/128", "2001:db8:3c4d:10::1", proto="ipv6") ns0.addip("192.168.10.2") ns0.addroute("192.168.200.1/32", "192.168.10.1") + + with test.step("Verify that dut2 is reachable from host over IPv4"): ns0.must_reach("192.168.200.1") - with test.step("Remove static routes on dut1"): - config_remove_routes(target1); - until(lambda: route.ipv4_route_exist(target1, "192.168.200.1/32") == False) - until(lambda: route.ipv6_route_exist(target1, "2001:db8:3c4d:200::1/128") == False) + with test.step("Verify that dut2 is reachable from host over IPv6"): + ns0.must_reach("2001:db8:3c4d:200::1") - with test.step("Ping from host to 192.168.200.1 and 2001:db8:3c4d:200::1 (dut2) through dut1 (should not be possible)"): - _, hport0 = env.ltop.xlate("host", "data1") - with infamy.IsolatedMacVlan(hport0) as ns0: - ns0.addip("2001:db8:3c4d:10::2", prefix_length=64, proto="ipv6") - ns0.addroute("2001:db8:3c4d:200::1/128", "2001:db8:3c4d:10::1", proto="ipv6") - ns0.addip("192.168.10.2") - ns0.addroute("192.168.200.1/32", "192.168.10.1") + with test.step("Remove static routes on dut1"): + config_remove_routes(target1); + until(lambda: route.ipv4_route_exist(target1, "192.168.200.1/32") == False) + until(lambda: route.ipv6_route_exist(target1, "2001:db8:3c4d:200::1/128") == False) + with test.step("Verify that dut2 is no longer reachable"): infamy.parallel(lambda: ns0.must_not_reach("192.168.200.1"), lambda: ns0.must_not_reach("2001:db8:3c4d:200::1")) - test.succeed()