From e53f3362be754df00d2d9ec57f87642500aa487b Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Fri, 17 May 2024 23:40:02 +0200 Subject: [PATCH] test: case: routing_basic: 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. --- test/case/ietf_interfaces/routing_basic.py | 31 +++++++--------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/test/case/ietf_interfaces/routing_basic.py b/test/case/ietf_interfaces/routing_basic.py index 2f43a625..61149046 100755 --- a/test/case/ietf_interfaces/routing_basic.py +++ b/test/case/ietf_interfaces/routing_basic.py @@ -52,44 +52,33 @@ with infamy.Test() as test: with test.step("Initialize"): env = infamy.Env(infamy.std_topology("1x3")) target = env.attach("target", "mgmt") - - with test.step("Configure target physical ports [enable routing]"): _, tport0 = env.ltop.xlate("target", "data0") _, tport1 = env.ltop.xlate("target", "data1") - config_target(target, tport0, tport1, True) - - with test.step("Test: Ip routing enabled"): _, hport0 = env.ltop.xlate("host", "data0") _, hport1 = env.ltop.xlate("host", "data1") - with infamy.IsolatedMacVlan(hport0) as ns0, \ - infamy.IsolatedMacVlan(hport1) as ns1 : + with infamy.IsolatedMacVlan(hport0) as ns0, \ + infamy.IsolatedMacVlan(hport1) as ns1 : + with test.step("Setup host"): ns0.addip("192.168.0.10") ns0.addroute("default", "192.168.0.1") ns1.addip("10.0.0.10") ns1.addroute("default", "10.0.0.1") + with test.step("Enable forwarding"): + config_target(target, tport0, tport1, True) + + with test.step("Traffic is forwarded"): ns0.must_reach("10.0.0.10") ns1.must_reach("192.168.0.10") - with test.step("Configure target physical ports [disable routing]"): - - config_target(target, tport0, tport1, False) - - with test.step("Test: Ip routing disabled"): - - with infamy.IsolatedMacVlan(hport0) as ns0, \ - infamy.IsolatedMacVlan(hport1) as ns1 : - - ns0.addip("192.168.0.10") - ns0.addroute("default", "192.168.0.1") - - ns1.addip("10.0.0.10") - ns1.addroute("default", "10.0.0.1") + with test.step("Disable forwarding"): + config_target(target, tport0, tport1, False) + with test.step("Traffic is not forwarded"): infamy.parallel(lambda: ns0.must_not_reach("10.0.0.10"), lambda: ns1.must_not_reach("192.168.0.10"))