diff options
author | Christian Hopps <chopps@labn.net> | 2021-08-27 20:28:29 +0200 |
---|---|---|
committer | Christian Hopps <chopps@labn.net> | 2021-09-04 15:04:46 +0200 |
commit | 8db751b853560377ebd640c729ecb4e155e6a6d7 (patch) | |
tree | 51a8419faf7cc64401f05b13c95a30895c5cd2f9 | |
parent | tests: micronet: update infra (diff) | |
download | frr-8db751b853560377ebd640c729ecb4e155e6a6d7.tar.xz frr-8db751b853560377ebd640c729ecb4e155e6a6d7.zip |
tests: micronet: adapt tests
Signed-off-by: Christian Hopps <chopps@labn.net>
194 files changed, 1171 insertions, 1493 deletions
diff --git a/tests/topotests/all_protocol_startup/test_all_protocol_startup.py b/tests/topotests/all_protocol_startup/test_all_protocol_startup.py index 2d75428f1..41597c449 100644 --- a/tests/topotests/all_protocol_startup/test_all_protocol_startup.py +++ b/tests/topotests/all_protocol_startup/test_all_protocol_startup.py @@ -34,12 +34,7 @@ import pytest import glob from time import sleep -from mininet.topo import Topo -from mininet.net import Mininet -from mininet.node import Node, OVSSwitch, Host -from mininet.log import setLogLevel, info -from mininet.cli import CLI -from mininet.link import Intf +from lib.micronet_compat import Mininet, Topo from functools import partial @@ -82,7 +77,7 @@ class NetworkTopo(Topo): switch = {} # for i in range(0, 10): - switch[i] = self.addSwitch("sw%s" % i, cls=topotest.LegacySwitch) + switch[i] = self.addSwitch("sw%s" % i) self.addLink(switch[i], router[1], intfName2="r1-eth%s" % i) @@ -765,7 +760,7 @@ def test_ospfv2_interfaces(): ) # Mask out Bandwidth portion. They may change.. actual = re.sub(r"BW [0-9]+ Mbit", "BW XX Mbit", actual) - actual = re.sub(r"ifindex [0-9]", "ifindex X", actual) + actual = re.sub(r"ifindex [0-9]+", "ifindex X", actual) # Drop time in next due actual = re.sub(r"Hello due in [0-9\.]+s", "Hello due in XX.XXXs", actual) @@ -1155,7 +1150,7 @@ def test_nht(): expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) actual = net["r%s" % i].cmd('vtysh -c "show ip nht" 2> /dev/null').rstrip() - actual = re.sub(r"fd [0-9][0-9]", "fd XX", actual) + actual = re.sub(r"fd [0-9]+", "fd XX", actual) actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) diff = topotest.get_textdiff( @@ -1175,7 +1170,7 @@ def test_nht(): expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1) actual = net["r%s" % i].cmd('vtysh -c "show ipv6 nht" 2> /dev/null').rstrip() - actual = re.sub(r"fd [0-9][0-9]", "fd XX", actual) + actual = re.sub(r"fd [0-9]+", "fd XX", actual) actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1) diff = topotest.get_textdiff( @@ -1418,7 +1413,7 @@ def test_nexthop_groups_with_route_maps(): net["r1"].cmd('vtysh -c "sharp remove routes %s 1"' % route_str) net["r1"].cmd('vtysh -c "c t" -c "no ip protocol sharp route-map NH-SRC"') net["r1"].cmd( - 'vtysh -c "c t" -c "no route-map NH-SRC permit 111" -c "set src %s"' % src_str + 'vtysh -c "c t" -c "no route-map NH-SRC permit 111" # -c "set src %s"' % src_str ) net["r1"].cmd('vtysh -c "c t" -c "no route-map NH-SRC"') @@ -1659,8 +1654,6 @@ def test_shutdown_check_memleak(): if __name__ == "__main__": - - setLogLevel("info") # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli # retval = pytest.main(["-s", "--tb=no"]) retval = pytest.main(["-s"]) diff --git a/tests/topotests/bfd_bgp_cbit_topo3/test_bfd_bgp_cbit_topo3.py b/tests/topotests/bfd_bgp_cbit_topo3/test_bfd_bgp_cbit_topo3.py index 560d6eebe..29c25bba2 100644 --- a/tests/topotests/bfd_bgp_cbit_topo3/test_bfd_bgp_cbit_topo3.py +++ b/tests/topotests/bfd_bgp_cbit_topo3/test_bfd_bgp_cbit_topo3.py @@ -41,35 +41,17 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo - pytestmark = [pytest.mark.bgpd, pytest.mark.bfdd] -class BFDTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # Create 4 routers. - for routern in range(1, 4): - tgen.add_router("r{}".format(routern)) - - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) - - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["r2"]) - switch.add_link(tgen.gears["r3"]) - - def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(BFDTopo, mod.__name__) + from collections import OrderedDict + topodef = { + "s1": ("r1", "r2"), + "s2": ("r2", "r3"), + } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py b/tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py index fcb5672dc..6a19b1ea4 100644 --- a/tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py +++ b/tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py @@ -87,52 +87,18 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo - pytestmark = [pytest.mark.bfdd, pytest.mark.isisd] - -class TemplateTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # - # Define FRR Routers - # - for router in ["rt1", "rt2", "rt3", "rt4", "rt5"]: - tgen.add_router(router) - - # - # Define connections - # - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1") - - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1") - - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt5") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt2") - - switch = tgen.add_switch("s4") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt4") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt3") - - switch = tgen.add_switch("s5") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4") - - def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(TemplateTopo, mod.__name__) + topodef = { + "s1": ("rt1:eth-rt2", "rt2:eth-rt1"), + "s2": ("rt1:eth-rt3", "rt3:eth-rt1"), + "s3": ("rt2:eth-rt5", "rt5:eth-rt2"), + "s4": ("rt3:eth-rt4", "rt4:eth-rt3"), + "s5": ("rt4:eth-rt5", "rt5:eth-rt4"), + } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/bfd_ospf_topo1/test_bfd_ospf_topo1.py b/tests/topotests/bfd_ospf_topo1/test_bfd_ospf_topo1.py index ae148f948..c82b4b590 100755 --- a/tests/topotests/bfd_ospf_topo1/test_bfd_ospf_topo1.py +++ b/tests/topotests/bfd_ospf_topo1/test_bfd_ospf_topo1.py @@ -84,61 +84,29 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib import topotest +from lib.micronet_compat import Topo from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo - pytestmark = [pytest.mark.bfdd, pytest.mark.ospfd] -class TemplateTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # - # Define FRR Routers - # - for router in ["rt1", "rt2", "rt3", "rt4", "rt5"]: - tgen.add_router(router) - - # - # Define connections - # - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1") - - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1") - - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt5") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt2") - - switch = tgen.add_switch("s4") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt4") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt3") - - switch = tgen.add_switch("s5") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4") - - def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(TemplateTopo, mod.__name__) + topodef = { + "s1": ("rt1:eth-rt2", "rt2:eth-rt1"), + "s2": ("rt1:eth-rt3", "rt3:eth-rt1"), + "s3": ("rt2:eth-rt5", "rt5:eth-rt2"), + "s4": ("rt3:eth-rt4", "rt4:eth-rt3"), + "s5": ("rt4:eth-rt5", "rt5:eth-rt4"), + } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() # For all registered routers, load the zebra configuration file - for rname, router in router_list.iteritems(): + for rname, router in router_list.items(): router.load_config( TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) ) diff --git a/tests/topotests/bfd_profiles_topo1/test_bfd_profiles_topo1.py b/tests/topotests/bfd_profiles_topo1/test_bfd_profiles_topo1.py index 4a2c8ee00..02e1d8a20 100644 --- a/tests/topotests/bfd_profiles_topo1/test_bfd_profiles_topo1.py +++ b/tests/topotests/bfd_profiles_topo1/test_bfd_profiles_topo1.py @@ -42,47 +42,19 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo - pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.ospfd] - -class BFDProfTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # Create 6 routers - for routern in range(1, 7): - tgen.add_router("r{}".format(routern)) - - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) - - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["r2"]) - switch.add_link(tgen.gears["r3"]) - - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["r3"]) - switch.add_link(tgen.gears["r4"]) - - switch = tgen.add_switch("s4") - switch.add_link(tgen.gears["r4"]) - switch.add_link(tgen.gears["r5"]) - - switch = tgen.add_switch("s5") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r6"]) - - def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(BFDProfTopo, mod.__name__) + + topodef = { + "s1": ("r1", "r2"), + "s2": ("r2", "r3"), + "s3": ("r3", "r4"), + "s4": ("r4", "r5"), + "s5": ("r1", "r6"), + } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/bfd_topo1/test_bfd_topo1.py b/tests/topotests/bfd_topo1/test_bfd_topo1.py index 86bdcfed0..adf02b02d 100644 --- a/tests/topotests/bfd_topo1/test_bfd_topo1.py +++ b/tests/topotests/bfd_topo1/test_bfd_topo1.py @@ -42,39 +42,17 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo - pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd] -class BFDTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # Create 4 routers - for routern in range(1, 5): - tgen.add_router("r{}".format(routern)) - - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) - - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["r2"]) - switch.add_link(tgen.gears["r3"]) - - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["r2"]) - switch.add_link(tgen.gears["r4"]) - - def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(BFDTopo, mod.__name__) + topodef = { + "s1": ("r1", "r2"), + "s2": ("r2", "r3"), + "s3": ("r2", "r4"), + } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/bfd_topo2/test_bfd_topo2.py b/tests/topotests/bfd_topo2/test_bfd_topo2.py index 2cc12bc7b..00431ea1f 100644 --- a/tests/topotests/bfd_topo2/test_bfd_topo2.py +++ b/tests/topotests/bfd_topo2/test_bfd_topo2.py @@ -43,39 +43,40 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo - pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.ospfd] -class BFDTopo(Topo): - "Test topology builder" +def build(self, *_args, **_opts): + "Build function" + tgen = get_topogen(self) - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) + # Create 4 routers. + for routern in range(1, 5): + tgen.add_router("r{}".format(routern)) - # Create 4 routers. - for routern in range(1, 5): - tgen.add_router("r{}".format(routern)) + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["r1"]) + switch.add_link(tgen.gears["r2"]) - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) + switch = tgen.add_switch("s2") + switch.add_link(tgen.gears["r2"]) + switch.add_link(tgen.gears["r3"]) - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["r2"]) - switch.add_link(tgen.gears["r3"]) + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["r2"]) + switch.add_link(tgen.gears["r4"]) - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["r2"]) - switch.add_link(tgen.gears["r4"]) def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(BFDTopo, mod.__name__) + topodef = { + "s1": ("r1", "r2"), + "s2": ("r2", "r3"), + "s3": ("r2", "r4"), + } + tgen = Topogen(topodef, mod.__name__) + # tgen = Topogen(build, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/bfd_topo3/test_bfd_topo3.py b/tests/topotests/bfd_topo3/test_bfd_topo3.py index 6bb223e20..9ed8f5fcb 100644 --- a/tests/topotests/bfd_topo3/test_bfd_topo3.py +++ b/tests/topotests/bfd_topo3/test_bfd_topo3.py @@ -39,42 +39,21 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib import topotest +from lib.micronet_compat import Topo from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo - pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd] -class BFDTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # Create 4 routers - for routern in range(1, 5): - tgen.add_router("r{}".format(routern)) - - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) - - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["r2"]) - switch.add_link(tgen.gears["r3"]) - - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["r3"]) - switch.add_link(tgen.gears["r4"]) - - def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(BFDTopo, mod.__name__) + topodef = { + "s1": ("r1", "r2"), + "s2": ("r2", "r3"), + "s3": ("r3", "r4"), + } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py b/tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py index 0e0dd4db4..125cc183c 100644 --- a/tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py +++ b/tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py @@ -44,7 +44,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd] @@ -94,24 +94,14 @@ def setup_module(mod): logger.info("Testing with VRF Namespace support") - cmds = [ - "if [ -e /var/run/netns/{0}-bfd-cust1 ] ; then ip netns del {0}-bfd-cust1 ; fi", - "ip netns add {0}-bfd-cust1", - "ip link set dev {0}-eth0 netns {0}-bfd-cust1 up", - ] - cmds2 = [ - "ip link set dev {0}-eth1 netns {0}-bfd-cust1", - "ip netns exec {0}-bfd-cust1 ip link set {0}-eth1 up", - "ip link set dev {0}-eth2 netns {0}-bfd-cust1 up", - ] - for rname, router in router_list.items(): # create VRF rx-bfd-cust1 and link rx-eth0 to rx-bfd-cust1 - for cmd in cmds: - output = tgen.net[rname].cmd_raises(cmd.format(rname)) + ns = "{}-bfd-cust1".format(rname) + router.net.add_netns(ns) + router.net.set_intf_netns(rname + "-eth0", ns, up=True) if rname == "r2": - for cmd in cmds2: - output = tgen.net[rname].cmd_raises(cmd.format(rname)) + router.net.set_intf_netns(rname + "-eth1", ns, up=True) + router.net.set_intf_netns(rname + "-eth2", ns, up=True) for rname, router in router_list.items(): router.load_config( @@ -133,24 +123,15 @@ def setup_module(mod): def teardown_module(_mod): "Teardown the pytest environment" tgen = get_topogen() - # move back rx-eth0 to default VRF - # delete rx-vrf - cmds = [ - "ip netns exec {0}-bfd-cust1 ip link set {0}-eth0 netns 1", - "ip netns delete {0}-bfd-cust1", - ] - cmds2 = [ - "ip netns exec {0}-bfd-cust1 ip link set {0}-eth1 netns 1", - "ip netns exec {0}-cust2 ip link set {0}-eth1 netns 1", - ] + # Move interfaces out of vrf namespace and delete the namespace router_list = tgen.routers() for rname, router in router_list.items(): if rname == "r2": - for cmd in cmds2: - tgen.net[rname].cmd(cmd.format(rname)) - for cmd in cmds: - tgen.net[rname].cmd(cmd.format(rname)) + router.net.reset_intf_netns(rname + "-eth2") + router.net.reset_intf_netns(rname + "-eth1") + router.net.reset_intf_netns(rname + "-eth0") + router.net.delete_netns("{}-bfd-cust1".format(rname)) tgen.stop_topology() diff --git a/tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py b/tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py index be07fab87..4fa6828ef 100644 --- a/tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py +++ b/tests/topotests/bgp_aggregate_address_origin/test_bgp_aggregate-address_origin.py @@ -45,7 +45,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py b/tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py index 484f40251..f4b988954 100644 --- a/tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py +++ b/tests/topotests/bgp_aggregate_address_route_map/test_bgp_aggregate-address_route-map.py @@ -48,7 +48,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py b/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py index 9f2697825..6566a860b 100644 --- a/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py +++ b/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py @@ -40,7 +40,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py b/tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py index c4bbdce2c..99c31a355 100644 --- a/tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py +++ b/tests/topotests/bgp_aggregator_zero/test_bgp_aggregator_zero.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py b/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py index 4d41c7a32..4c0142fd0 100644 --- a/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py +++ b/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py @@ -51,7 +51,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration @@ -251,9 +251,11 @@ def test_bgp_allowas_in_p0(request): protocol=protocol, expected=False, ) - assert result is not True, "Testcase {} : Failed \n" - "Expected behavior: routes should not present in rib \n" - "Error: {}".format(tc_name, result) + assert result is not True, ( + "Testcase {} : Failed \n".format(tc_name) + + "Expected behavior: routes should not present in rib \n" + + "Error: {}".format(result) + ) step("Configure allowas-in on R3 for R2.") step("We should see the prefix advertised from R1 in R3's BGP table.") @@ -396,9 +398,11 @@ def test_bgp_allowas_in_per_addr_family_p0(request): result = verify_rib( tgen, "ipv6", dut, static_route_ipv6, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "Expected behavior: routes are should not be present in ipv6 rib\n" - " Error: {}".format(tc_name, result) + assert result is not True, ( + "Testcase {} : Failed \n".format(tc_name) + + "Expected behavior: routes are should not be present in ipv6 rib\n" + + " Error: {}".format(result) + ) step("Repeat the same test for IPv6 AFI.") step("Configure allowas-in on R3 for R2 under IPv6 addr-family only") @@ -444,9 +448,11 @@ def test_bgp_allowas_in_per_addr_family_p0(request): result = verify_rib( tgen, "ipv4", dut, static_route_ipv4, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n" - "Expected behavior: routes should not be present in ipv4 rib\n" - " Error: {}".format(tc_name, result) + assert result is not True, ( + "Testcase {} : Failed \n".format(tc_name) + + "Expected behavior: routes should not be present in ipv4 rib\n" + + " Error: {}".format(result) + ) result = verify_rib(tgen, "ipv6", dut, static_route_ipv6, protocol=protocol) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) @@ -598,9 +604,11 @@ def test_bgp_allowas_in_no_of_occurrences_p0(request): result = verify_rib( tgen, addr_type, dut, static_routes, protocol=protocol, expected=False ) - assert result is not True, "Testcase {} : Failed \n " - "Expected behavior: routes are should not be present in rib\n" - "Error: {}".format(tc_name, result) + assert result is not True, ( + "Testcase {} : Failed \n ".format(tc_name) + + "Expected behavior: routes are should not be present in rib\n" + + "Error: {}".format(result) + ) for addr_type in ADDR_TYPES: step('Configure "allowas-in 5" on R3 for R2.') diff --git a/tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py b/tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py index a73646392..046f3f80a 100644 --- a/tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py +++ b/tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py @@ -43,7 +43,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py b/tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py index 903ab12a1..3c264a7da 100644 --- a/tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py +++ b/tests/topotests/bgp_aspath_zero/test_bgp_aspath_zero.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_auth/test_bgp_auth.py b/tests/topotests/bgp_auth/test_bgp_auth.py index b2cdef1c9..b13f3d6e2 100644 --- a/tests/topotests/bgp_auth/test_bgp_auth.py +++ b/tests/topotests/bgp_auth/test_bgp_auth.py @@ -63,7 +63,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import apply_raw_config diff --git a/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py b/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py index 3623e89dc..e3f07166f 100644 --- a/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py +++ b/tests/topotests/bgp_basic_functionality_topo1/test_bgp_basic_functionality.py @@ -55,41 +55,24 @@ sys.path.append(os.path.join(CWD, "../lib/")) # Required to instantiate the topology builder class. +from lib.bgp import (clear_bgp_and_verify, create_router_bgp, modify_as_number, + verify_as_numbers, verify_bgp_convergence, verify_bgp_rib, + verify_bgp_timers_and_functionality, verify_router_id) +from lib.common_config import (addKernelRoute, apply_raw_config, + check_address_types, create_prefix_lists, + create_route_maps, create_static_routes, + required_linux_kernel_version, + reset_config_on_routers, start_topology, step, + verify_admin_distance_for_static_routes, + verify_bgp_community, verify_fib_routes, + verify_rib, write_test_footer, + write_test_header) +from lib.micronet_compat import Topo # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo - -from lib.common_config import ( - step, - start_topology, - write_test_header, - write_test_footer, - reset_config_on_routers, - create_static_routes, - verify_rib, - verify_admin_distance_for_static_routes, - check_address_types, - apply_raw_config, - addKernelRoute, - verify_fib_routes, - create_prefix_lists, - create_route_maps, - verify_bgp_community, - required_linux_kernel_version, -) +from lib.topojson import build_config_from_json, build_topo_from_json from lib.topolog import logger -from lib.bgp import ( - verify_bgp_convergence, - create_router_bgp, - verify_router_id, - modify_as_number, - verify_as_numbers, - clear_bgp_and_verify, - verify_bgp_timers_and_functionality, - verify_bgp_rib, -) -from lib.topojson import build_topo_from_json, build_config_from_json pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] @@ -1158,10 +1141,12 @@ def test_bgp_with_loopback_with_same_subnet_p1(request): dut = "r1" protocol = "bgp" for addr_type in ADDR_TYPES: - result = verify_fib_routes(tgen, addr_type, dut, input_dict_r1) - assert result is not True, "Testcase {} : Failed \n" - "Expected behavior: routes should not present in fib \n" - "Error: {}".format(tc_name, result) + result = verify_fib_routes(tgen, addr_type, dut, input_dict_r1, expected=False) # pylint: disable=E1123 + assert result is not True, ( + "Testcase {} : Failed \n".format(tc_name) + + "Expected behavior: routes should not present in fib \n" + + "Error: {}".format(result) + ) step("Verify Ipv4 and Ipv6 network installed in r3 RIB but not in FIB") input_dict_r3 = { @@ -1175,10 +1160,12 @@ def test_bgp_with_loopback_with_same_subnet_p1(request): dut = "r3" protocol = "bgp" for addr_type in ADDR_TYPES: - result = verify_fib_routes(tgen, addr_type, dut, input_dict_r1) - assert result is not True, "Testcase {} : Failed \n" - "Expected behavior: routes should not present in fib \n" - "Error: {}".format(tc_name, result) + result = verify_fib_routes(tgen, addr_type, dut, input_dict_r1, expected=False) # pylint: disable=E1123 + assert result is not True, ( + "Testcase {} : Failed \n".format(tc_name) + + "Expected behavior: routes should not present in fib \n" + + "Error: {}".format(result) + ) write_test_footer(tc_name) diff --git a/tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py b/tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py index 6512e4d4c..7e78722da 100644 --- a/tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py +++ b/tests/topotests/bgp_blackhole_community/test_bgp_blackhole_community.py @@ -37,7 +37,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import step pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py b/tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py index 81bf8da31..2c1546a3b 100644 --- a/tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py +++ b/tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py @@ -43,7 +43,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_communities_topo1/test_bgp_communities.py b/tests/topotests/bgp_communities_topo1/test_bgp_communities.py index 6d4a7d82e..f52f539af 100644 --- a/tests/topotests/bgp_communities_topo1/test_bgp_communities.py +++ b/tests/topotests/bgp_communities_topo1/test_bgp_communities.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py b/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py index 341578906..24dc6bb48 100644 --- a/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py +++ b/tests/topotests/bgp_communities_topo1/test_bgp_communities_topo2.py @@ -40,7 +40,7 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/bgp_community_alias/test_bgp-community-alias.py b/tests/topotests/bgp_community_alias/test_bgp-community-alias.py index 26933a799..2ef30249e 100644 --- a/tests/topotests/bgp_community_alias/test_bgp-community-alias.py +++ b/tests/topotests/bgp_community_alias/test_bgp-community-alias.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py b/tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py index 9f449d797..eee9294df 100644 --- a/tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py +++ b/tests/topotests/bgp_community_change_update/test_bgp_community_change_update.py @@ -54,7 +54,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import step from time import sleep diff --git a/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py b/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py index 44f54c7b5..9e020ae86 100644 --- a/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py +++ b/tests/topotests/bgp_conditional_advertisement/test_bgp_conditional_advertisement.py @@ -137,7 +137,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py b/tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py index 6ed702304..a22cd9406 100644 --- a/tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py +++ b/tests/topotests/bgp_default_afi_safi/test_bgp-default-afi-safi.py @@ -44,7 +44,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import step pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_default_route/test_bgp_default-originate.py b/tests/topotests/bgp_default_route/test_bgp_default-originate.py index 6fbdfbe78..68d9c52f4 100644 --- a/tests/topotests/bgp_default_route/test_bgp_default-originate.py +++ b/tests/topotests/bgp_default_route/test_bgp_default-originate.py @@ -36,7 +36,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py b/tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py index e7e3512b1..11a26570f 100644 --- a/tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py +++ b/tests/topotests/bgp_default_route_route_map_match/test_bgp_default-originate_route-map_match.py @@ -36,7 +36,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py b/tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py index 5852ac268..f8c36f632 100644 --- a/tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py +++ b/tests/topotests/bgp_default_route_route_map_match2/test_bgp_default-originate_route-map_match2.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import step pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py b/tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py index e2fa89fcc..3735fcfb3 100644 --- a/tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py +++ b/tests/topotests/bgp_default_route_route_map_match_set/test_bgp_default-originate_route-map_match_set.py @@ -37,7 +37,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py b/tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py index be87dc61c..05f14f352 100644 --- a/tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py +++ b/tests/topotests/bgp_default_route_route_map_set/test_bgp_default-originate_route-map_set.py @@ -36,7 +36,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_distance_change/test_bgp_distance_change.py b/tests/topotests/bgp_distance_change/test_bgp_distance_change.py index bf2671408..2583db01e 100644 --- a/tests/topotests/bgp_distance_change/test_bgp_distance_change.py +++ b/tests/topotests/bgp_distance_change/test_bgp_distance_change.py @@ -47,7 +47,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_dont_capability_negogiate/test_bgp_dont_capability_negotiate.py b/tests/topotests/bgp_dont_capability_negogiate/test_bgp_dont_capability_negotiate.py index 398fa57ba..6025ad935 100644 --- a/tests/topotests/bgp_dont_capability_negogiate/test_bgp_dont_capability_negotiate.py +++ b/tests/topotests/bgp_dont_capability_negogiate/test_bgp_dont_capability_negotiate.py @@ -39,25 +39,13 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo pytestmark = [pytest.mark.bgpd] -class TemplateTopo(Topo): - def build(self, *_args, **_opts): - tgen = get_topogen(self) - - for routern in range(1, 3): - tgen.add_router("r{}".format(routern)) - - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) - - def setup_module(mod): - tgen = Topogen(TemplateTopo, mod.__name__) + topodef = { "s1": ("r1", "r2") } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py b/tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py index 6db2697e7..9460d6bae 100644 --- a/tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py +++ b/tests/topotests/bgp_ebgp_common_subnet_nexthop_unchanged/test_bgp-ebgp-common-subnet-nexthop-unchanged.py @@ -49,7 +49,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py b/tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py index 2731d37fb..390c8b290 100644 --- a/tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py +++ b/tests/topotests/bgp_ebgp_requires_policy/test_bgp_ebgp_requires_policy.py @@ -55,7 +55,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py b/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py index 75506d1a5..dea2ffbd8 100644 --- a/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py +++ b/tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py @@ -43,7 +43,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py b/tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py index fffcbbd0e..7bc3d2912 100644 --- a/tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py +++ b/tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py @@ -50,7 +50,7 @@ sys.path.append(os.path.join(CWD, "../../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, diff --git a/tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py b/tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py index 342a0a4b2..15982dad5 100644 --- a/tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py +++ b/tests/topotests/bgp_ecmp_topo2/test_ibgp_ecmp_topo2.py @@ -50,7 +50,7 @@ sys.path.append(os.path.join(CWD, "../../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, diff --git a/tests/topotests/bgp_evpn_mh/test_evpn_mh.py b/tests/topotests/bgp_evpn_mh/test_evpn_mh.py index 7c2787d55..8cdf3529d 100644 --- a/tests/topotests/bgp_evpn_mh/test_evpn_mh.py +++ b/tests/topotests/bgp_evpn_mh/test_evpn_mh.py @@ -47,15 +47,13 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib import topotest +# Required to instantiate the topology builder class. +from lib.micronet_compat import Topo from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo - pytestmark = [pytest.mark.bgpd, pytest.mark.pimd] - ##################################################### ## ## Network Topology Definition diff --git a/tests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py b/tests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py index a411f13d2..7a53173dc 100755 --- a/tests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py +++ b/tests/topotests/bgp_evpn_overlay_index_gateway/test_bgp_evpn_overlay_index_gateway.py @@ -75,7 +75,7 @@ from lib.common_config import ( ) # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] @@ -142,47 +142,58 @@ def setup_module(mod): tgen.start_topology() # Configure MAC address for hosts as these MACs are advertised with EVPN type-2 routes - for (name, host) in tgen.gears.items(): + for name in tgen.gears: if name not in HOSTS: continue + host = tgen.net[name] host_mac = "1a:2b:3c:4d:5e:6{}".format(HOST_SUFFIX[name]) - host.run("ip link set dev {}-eth0 down").format(name) - host.run("ip link set dev {0}-eth0 address {1}".format(name, host_mac)) - host.run("ip link set dev {}-eth0 up").format(name) + host.cmd_raises("ip link set dev {}-eth0 down".format(name)) + host.cmd_raises("ip link set dev {0}-eth0 address {1}".format(name, host_mac)) + host.cmd_raises("ip link set dev {}-eth0 up".format(name)) # Configure PE VxLAN and Bridge interfaces - for (name, pe) in tgen.gears.items(): + for name in tgen.gears: if name not in PES: continue + pe = tgen.net[name] + vtep_ip = "10.100.0.{}".format(PE_SUFFIX[name]) bridge_ip = "50.0.1.{}/24".format(PE_SUFFIX[name]) bridge_ipv6 = "50:0:1::{}/48".format(PE_SUFFIX[name]) - pe.run("ip link add vrf-blue type vrf table 10") - pe.run("ip link set dev vrf-blue up") - pe.run("ip link add vxlan100 type vxlan id 100 dstport 4789 local {}".format(vtep_ip)) - pe.run("ip link add name br100 type bridge stp_state 0") - pe.run("ip link set dev vxlan100 master br100") - pe.run("ip link set dev {}-eth1 master br100".format(name)) - pe.run("ip addr add {} dev br100".format(bridge_ip)) - pe.run("ip link set up dev br100") - pe.run("ip link set up dev vxlan100") - pe.run("ip link set up dev {}-eth1".format(name)) - pe.run("ip link set dev br100 master vrf-blue") - pe.run("ip -6 addr add {} dev br100".format(bridge_ipv6)) - - pe.run("ip link add vxlan1000 type vxlan id 1000 dstport 4789 local {}".format(vtep_ip)) - pe.run("ip link add name br1000 type bridge stp_state 0") - pe.run("ip link set dev vxlan1000 master br100") - pe.run("ip link set up dev br1000") - pe.run("ip link set up dev vxlan1000") - pe.run("ip link set dev br1000 master vrf-blue") - - pe.run("sysctl -w net.ipv4.ip_forward=1") - pe.run("sysctl -w net.ipv6.conf.all.forwarding=1") - pe.run("sysctl -w net.ipv4.udp_l3mdev_accept={}".format(l3mdev_accept)) - pe.run("sysctl -w net.ipv4.tcp_l3mdev_accept={}".format(l3mdev_accept)) + pe.cmd_raises("ip link add vrf-blue type vrf table 10") + pe.cmd_raises("ip link set dev vrf-blue up") + pe.cmd_raises( + "ip link add vxlan100 type vxlan id 100 dstport 4789 local {}".format( + vtep_ip + ) + ) + pe.cmd_raises("ip link add name br100 type bridge stp_state 0") + pe.cmd_raises("ip link set dev vxlan100 master br100") + pe.cmd_raises("ip link set dev {}-eth1 master br100".format(name)) + pe.cmd_raises("ip addr add {} dev br100".format(bridge_ip)) + pe.cmd_raises("ip link set up dev br100") + pe.cmd_raises("ip link set up dev vxlan100") + pe.cmd_raises("ip link set up dev {}-eth1".format(name)) + pe.cmd_raises("ip link set dev br100 master vrf-blue") + pe.cmd_raises("ip -6 addr add {} dev br100".format(bridge_ipv6)) + + pe.cmd_raises( + "ip link add vxlan1000 type vxlan id 1000 dstport 4789 local {}".format( + vtep_ip + ) + ) + pe.cmd_raises("ip link add name br1000 type bridge stp_state 0") + pe.cmd_raises("ip link set dev vxlan1000 master br100") + pe.cmd_raises("ip link set up dev br1000") + pe.cmd_raises("ip link set up dev vxlan1000") + pe.cmd_raises("ip link set dev br1000 master vrf-blue") + + pe.cmd_raises("sysctl -w net.ipv4.ip_forward=1") + pe.cmd_raises("sysctl -w net.ipv6.conf.all.forwarding=1") + pe.cmd_raises("sysctl -w net.ipv4.udp_l3mdev_accept={}".format(l3mdev_accept)) + pe.cmd_raises("sysctl -w net.ipv4.tcp_l3mdev_accept={}".format(l3mdev_accept)) # For all registred routers, load the zebra configuration file for (name, router) in tgen.routers().items(): @@ -353,9 +364,9 @@ def test_evpn_gateway_ip_flap_rt2(request): step("Shut down VxLAN interface at PE1 which results in withdraw of type-2 routes") - pe1 = tgen.gears['PE1'] + pe1 = tgen.net["PE1"] - pe1.run('ip link set dev vxlan100 down') + pe1.cmd_raises("ip link set dev vxlan100 down") result, assertmsg = evpn_gateway_ip_show_op_check("no_rt2") if result is not None: @@ -364,7 +375,7 @@ def test_evpn_gateway_ip_flap_rt2(request): step("Bring up VxLAN interface at PE1 and advertise type-2 routes again") - pe1.run('ip link set dev vxlan100 up') + pe1.cmd_raises("ip link set dev vxlan100 up") result, assertmsg = evpn_gateway_ip_show_op_check("base") if result is not None: diff --git a/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py b/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py index 59024f7b7..02e67b70c 100644 --- a/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py +++ b/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py @@ -44,7 +44,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] @@ -97,12 +97,6 @@ def setup_module(mod): "ip link set dev loop101 master {}-vrf-101", "ip link set dev loop101 up", ] - cmds_netns = [ - "ip netns add {}-vrf-101", - "ip link add loop101 type dummy", - "ip link set dev loop101 netns {}-vrf-101", - "ip netns exec {}-vrf-101 ip link set dev loop101 up", - ] cmds_r2 = [ # config routing 101 "ip link add name bridge-101 up type bridge stp_state 0", @@ -113,40 +107,41 @@ def setup_module(mod): "ip link set vxlan-101 up type bridge_slave learning off flood off mcast_flood off", ] - cmds_r1_netns_method3 = [ - "ip link add name vxlan-{1} type vxlan id {1} dstport 4789 dev {0}-eth0 local 192.168.100.21", - "ip link set dev vxlan-{1} netns {0}-vrf-{1}", - "ip netns exec {0}-vrf-{1} ip li set dev lo up", - "ip netns exec {0}-vrf-{1} ip link add name bridge-{1} up type bridge stp_state 0", - "ip netns exec {0}-vrf-{1} ip link set dev vxlan-{1} master bridge-{1}", - "ip netns exec {0}-vrf-{1} ip link set bridge-{1} up", - "ip netns exec {0}-vrf-{1} ip link set vxlan-{1} up", - ] + # cmds_r1_netns_method3 = [ + # "ip link add name vxlan-{1} type vxlan id {1} dstport 4789 dev {0}-eth0 local 192.168.100.21", + # "ip link set dev vxlan-{1} netns {0}-vrf-{1}", + # "ip netns exec {0}-vrf-{1} ip li set dev lo up", + # "ip netns exec {0}-vrf-{1} ip link add name bridge-{1} up type bridge stp_state 0", + # "ip netns exec {0}-vrf-{1} ip link set dev vxlan-{1} master bridge-{1}", + # "ip netns exec {0}-vrf-{1} ip link set bridge-{1} up", + # "ip netns exec {0}-vrf-{1} ip link set vxlan-{1} up", + # ] router = tgen.gears["r1"] - for cmd in cmds_netns: - logger.info("cmd to r1: " + cmd) - output = router.run(cmd.format("r1")) - logger.info("result: " + output) + + ns = "r1-vrf-101" + tgen.net["r1"].add_netns(ns) + tgen.net["r1"].cmd_raises("ip link add loop101 type dummy") + tgen.net["r1"].set_intf_netns("loop101", ns, up=True) router = tgen.gears["r2"] for cmd in cmds_vrflite: logger.info("cmd to r2: " + cmd.format("r2")) - output = router.run(cmd.format("r2")) + output = router.cmd_raises(cmd.format("r2")) logger.info("result: " + output) for cmd in cmds_r2: logger.info("cmd to r2: " + cmd.format("r2")) - output = router.run(cmd.format("r2")) + output = router.cmd_raises(cmd.format("r2")) logger.info("result: " + output) - router = tgen.gears["r1"] - bridge_id = "101" - for cmd in cmds_r1_netns_method3: - logger.info("cmd to r1: " + cmd.format("r1", bridge_id)) - output = router.run(cmd.format("r1", bridge_id)) - logger.info("result: " + output) - router = tgen.gears["r1"] + tgen.net["r1"].cmd_raises("ip link add name vxlan-101 type vxlan id 101 dstport 4789 dev r1-eth0 local 192.168.100.21") + tgen.net["r1"].set_intf_netns("vxlan-101", "r1-vrf-101", up=True) + tgen.net["r1"].cmd_raises("ip -n r1-vrf-101 link set lo up") + tgen.net["r1"].cmd_raises("ip -n r1-vrf-101 link add name bridge-101 up type bridge stp_state 0") + tgen.net["r1"].cmd_raises("ip -n r1-vrf-101 link set dev vxlan-101 master bridge-101") + tgen.net["r1"].cmd_raises("ip -n r1-vrf-101 link set bridge-101 up") + tgen.net["r1"].cmd_raises("ip -n r1-vrf-101 link set vxlan-101 up") for rname, router in router_list.items(): if rname == "r1": @@ -170,12 +165,8 @@ def setup_module(mod): def teardown_module(_mod): "Teardown the pytest environment" tgen = get_topogen() - cmds_rx_netns = ["ip netns del {}-vrf-101"] - router = tgen.gears["r1"] - for cmd in cmds_rx_netns: - logger.info("cmd to r1: " + cmd.format("r1")) - output = router.run(cmd.format("r1")) + tgen.net["r1"].delete_netns("r1-vrf-101") tgen.stop_topology() diff --git a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py index 763cf9c15..0380ac07d 100755 --- a/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py +++ b/tests/topotests/bgp_evpn_vxlan_topo1/test_bgp_evpn_vxlan.py @@ -44,7 +44,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd] diff --git a/tests/topotests/bgp_features/test_bgp_features.py b/tests/topotests/bgp_features/test_bgp_features.py index d19b7722d..54f61f92e 100644 --- a/tests/topotests/bgp_features/test_bgp_features.py +++ b/tests/topotests/bgp_features/test_bgp_features.py @@ -45,7 +45,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd] diff --git a/tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py b/tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py index fdd84fcd4..6a12ed80d 100644 --- a/tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py +++ b/tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py @@ -69,7 +69,7 @@ from lib.lutil import lUtil from lib.lutil import luCommand # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py index 330ae5e43..bd3f6209a 100644 --- a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py +++ b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py @@ -106,7 +106,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo # Import topoJson from lib, to create topology and initial configuration from lib.topojson import build_topo_from_json, build_config_from_json diff --git a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py index 83bf4fcc1..dd44cbf96 100644 --- a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py +++ b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py @@ -102,7 +102,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo # Import topoJson from lib, to create topology and initial configuration from lib.topojson import build_topo_from_json, build_config_from_json diff --git a/tests/topotests/bgp_gshut/test_bgp_gshut.py b/tests/topotests/bgp_gshut/test_bgp_gshut.py index 77f86a0bb..d32ba1c1f 100644 --- a/tests/topotests/bgp_gshut/test_bgp_gshut.py +++ b/tests/topotests/bgp_gshut/test_bgp_gshut.py @@ -73,7 +73,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py b/tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py index fcfeaab61..2595b2099 100644 --- a/tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py +++ b/tests/topotests/bgp_gshut_topo1/test_ebgp_gshut_topo1.py @@ -42,7 +42,7 @@ sys.path.append(os.path.join(CWD, "../../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from time import sleep from lib.common_config import ( diff --git a/tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py b/tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py index d83e9e25a..3f3354dc8 100644 --- a/tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py +++ b/tests/topotests/bgp_gshut_topo1/test_ibgp_gshut_topo1.py @@ -42,7 +42,7 @@ sys.path.append(os.path.join(CWD, "../../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from time import sleep from lib.common_config import ( diff --git a/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py b/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py index 0df2c9cb5..dc587cd70 100644 --- a/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py +++ b/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py @@ -43,7 +43,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py index 752e37f5f..6eaf8e07f 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py @@ -85,7 +85,7 @@ from lib.topolog import logger from lib.ltemplate import ltemplateRtrCmd # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo import shutil @@ -146,10 +146,6 @@ def ltemplatePreRouterStartHook(): if tgen.hasmpls != True: logger.info("MPLS not available, skipping setup") return False - # check for normal init - if len(tgen.net) == 1: - logger.info("Topology not configured, skipping setup") - return False # configure r2 mpls interfaces intfs = ["lo", "r2-eth0", "r2-eth1", "r2-eth2"] for intf in intfs: diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py index c2f85c68c..40009b9ba 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py @@ -86,7 +86,7 @@ from lib.topolog import logger from lib.ltemplate import ltemplateRtrCmd # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo import shutil @@ -155,10 +155,6 @@ def ltemplatePreRouterStartHook(): if tgen.hasmpls != True: logger.info("MPLS not available, skipping setup") return False - # check for normal init - if len(tgen.net) == 1: - logger.info("Topology not configured, skipping setup") - return False # trace errors/unexpected output cc.resetCounts() # configure r2 mpls interfaces diff --git a/tests/topotests/bgp_large_community/bgp_large_community_topo_2.json b/tests/topotests/bgp_large_community/bgp_large_community_topo_2.json index 6f1ca90af..36dee39a1 100644 --- a/tests/topotests/bgp_large_community/bgp_large_community_topo_2.json +++ b/tests/topotests/bgp_large_community/bgp_large_community_topo_2.json @@ -12,7 +12,7 @@ "lo_prefix": { "ipv4": "1.0.", "v4mask": 32, - "ipv6": "2001:DB8:F::", + "ipv6": "2001:db8:f::", "v6mask": 128 }, "routers": { diff --git a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py index 69eba23e0..d138a689e 100644 --- a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py +++ b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py @@ -54,7 +54,7 @@ from json import load as json_load # Required to instantiate the topology builder class. from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, diff --git a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py index b033c7e5c..c9115bf42 100644 --- a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py +++ b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py @@ -74,7 +74,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # Import topogen and topotest helpers # Import topoJson from lib, to create topology and initial configuration from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, diff --git a/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py b/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py index a9b4b6b03..4ad1dbcaa 100644 --- a/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py +++ b/tests/topotests/bgp_link_bw_ip/test_bgp_linkbw_ip.py @@ -44,7 +44,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py b/tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py index a7959fe61..fdbc5e553 100755 --- a/tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py +++ b/tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py @@ -53,7 +53,7 @@ from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import linux_intf_config_from_json from lib.common_config import start_topology from lib.topotest import router_json_cmp, run_and_expect -from mininet.topo import Topo +from lib.micronet_compat import Topo from functools import partial pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py b/tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py index 7c5ed87dd..ec4919650 100644 --- a/tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py +++ b/tests/topotests/bgp_local_as_private_remove/test_bgp_local_as_private_remove.py @@ -41,7 +41,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_lu_topo1/test_bgp_lu.py b/tests/topotests/bgp_lu_topo1/test_bgp_lu.py index d1745674f..258ddb148 100644 --- a/tests/topotests/bgp_lu_topo1/test_bgp_lu.py +++ b/tests/topotests/bgp_lu_topo1/test_bgp_lu.py @@ -43,7 +43,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py b/tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py index 0fde32a68..c80094684 100644 --- a/tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py +++ b/tests/topotests/bgp_maximum_prefix_invalid_update/test_bgp_maximum_prefix_invalid_update.py @@ -45,7 +45,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py b/tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py index 5c9391078..5b762bfe5 100644 --- a/tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py +++ b/tests/topotests/bgp_maximum_prefix_out/test_bgp_maximum_prefix_out.py @@ -41,7 +41,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py b/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py index 84e10af5b..9a20f7d45 100644 --- a/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py +++ b/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py @@ -114,7 +114,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topotest import iproute2_is_vrf_capable from lib.common_config import ( step, diff --git a/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py b/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py index 31569e69b..7fd9fac6e 100644 --- a/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py +++ b/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py @@ -70,7 +70,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topotest import iproute2_is_vrf_capable from lib.common_config import ( step, diff --git a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py index caaa81066..a949c5282 100644 --- a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py +++ b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py @@ -70,17 +70,12 @@ import glob import json from time import sleep -from mininet.topo import Topo -from mininet.net import Mininet -from mininet.node import Node, OVSSwitch, Host -from mininet.log import setLogLevel, info -from mininet.cli import CLI -from mininet.link import Intf - from functools import partial sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from lib import topotest +from lib.micronet_compat import Mininet +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] @@ -121,10 +116,10 @@ class NetworkTopo(Topo): # Setup Switches switch = {} # First switch is for a dummy interface (for local network) - switch[0] = self.addSwitch("sw0", cls=topotest.LegacySwitch) + switch[0] = self.addSwitch("sw0") self.addLink(switch[0], router[1], intfName2="r1-stub") # Second switch is for connection to all peering routers - switch[1] = self.addSwitch("sw1", cls=topotest.LegacySwitch) + switch[1] = self.addSwitch("sw1") self.addLink(switch[1], router[1], intfName2="r1-eth0") for j in range(1, 9): self.addLink(switch[1], peer[j], intfName2="peer%s-eth0" % j) @@ -353,8 +348,6 @@ def test_shutdown_check_memleak(): if __name__ == "__main__": - - setLogLevel("info") # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli # retval = pytest.main(["-s", "--tb=no"]) retval = pytest.main(["-s"]) diff --git a/tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py b/tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py index a591c2f3f..0fc9b7e02 100644 --- a/tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py +++ b/tests/topotests/bgp_path_attributes_topo1/test_bgp_path_attributes.py @@ -65,7 +65,7 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen diff --git a/tests/topotests/bgp_peer_group/test_bgp_peer-group.py b/tests/topotests/bgp_peer_group/test_bgp_peer-group.py index 21dc72579..70e49d5cd 100644 --- a/tests/topotests/bgp_peer_group/test_bgp_peer-group.py +++ b/tests/topotests/bgp_peer_group/test_bgp_peer-group.py @@ -36,7 +36,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py b/tests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py index 743fcf7b3..c5924c787 100755 --- a/tests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py +++ b/tests/topotests/bgp_peer_type_multipath_relax/test_bgp_peer-type_multipath-relax.py @@ -71,7 +71,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] diff --git a/tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py b/tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py index 10dee0f77..287ff87bf 100644 --- a/tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py +++ b/tests/topotests/bgp_prefix_list_topo1/test_prefix_lists.py @@ -55,7 +55,7 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py b/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py index fffe135b7..72df2eab6 100644 --- a/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py +++ b/tests/topotests/bgp_prefix_sid/test_bgp_prefix_sid.py @@ -39,7 +39,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py b/tests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py index 703dcd7e2..6da44faf5 100755 --- a/tests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py +++ b/tests/topotests/bgp_prefix_sid2/test_bgp_prefix_sid2.py @@ -39,7 +39,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py b/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py index 2fe80c77f..320c7eb78 100644 --- a/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py +++ b/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py @@ -52,7 +52,7 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib import topotest -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py b/tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py index c644d2104..f13b068d9 100644 --- a/tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py +++ b/tests/topotests/bgp_reject_as_sets/test_bgp_reject_as_sets.py @@ -48,7 +48,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_rfapi_basic_sanity/customize.py b/tests/topotests/bgp_rfapi_basic_sanity/customize.py index 2c85cf6e9..9166c57df 100644 --- a/tests/topotests/bgp_rfapi_basic_sanity/customize.py +++ b/tests/topotests/bgp_rfapi_basic_sanity/customize.py @@ -72,7 +72,7 @@ from lib.topolog import logger from lib.ltemplate import ltemplateRtrCmd # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo import shutil @@ -116,10 +116,6 @@ def ltemplatePreRouterStartHook(): cc = ltemplateRtrCmd() tgen = get_topogen() logger.info("pre router-start hook") - # check for normal init - if len(tgen.net) == 1: - logger.info("Topology not configured, skipping setup") - return False return True diff --git a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py index ecf1ed521..04a66d0e2 100644 --- a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py +++ b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py @@ -43,7 +43,7 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib import topotest -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/bgp_route_map/test_route_map_topo1.py b/tests/topotests/bgp_route_map/test_route_map_topo1.py index 7de56849c..17058d178 100644 --- a/tests/topotests/bgp_route_map/test_route_map_topo1.py +++ b/tests/topotests/bgp_route_map/test_route_map_topo1.py @@ -36,7 +36,7 @@ sys.path.append(os.path.join(CWD, "../")) # Import topogen and topotest helpers from lib import topotest from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo # Required to instantiate the topology builder class. from lib.topojson import * diff --git a/tests/topotests/bgp_route_map/test_route_map_topo2.py b/tests/topotests/bgp_route_map/test_route_map_topo2.py index 230a89ace..54b3340d6 100644 --- a/tests/topotests/bgp_route_map/test_route_map_topo2.py +++ b/tests/topotests/bgp_route_map/test_route_map_topo2.py @@ -118,7 +118,7 @@ sys.path.append(os.path.join(CWD, "../")) # Import topogen and topotest helpers from lib import topotest from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo # Required to instantiate the topology builder class. from lib.common_config import ( diff --git a/tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py b/tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py index 664c9dc91..72c25a3c6 100644 --- a/tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py +++ b/tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py @@ -47,7 +47,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py b/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py index dffe24f3a..526e1202d 100644 --- a/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py +++ b/tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py @@ -41,7 +41,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py b/tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py index b4af911d9..531e1814a 100644 --- a/tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py +++ b/tests/topotests/bgp_set_local_preference_add_subtract/test_bgp_set_local-preference_add_subtract.py @@ -42,7 +42,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/ce1/snmpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/ce1/snmpd.conf index 36218d353..4aff57aca 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/ce1/snmpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/ce1/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/ce2/snmpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/ce2/snmpd.conf index 714585cb9..29c2041d1 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/ce2/snmpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/ce2/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/ce3/snmpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/ce3/snmpd.conf index 36218d353..4aff57aca 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/ce3/snmpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/ce3/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/ce4/snmpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/ce4/snmpd.conf index 36218d353..4aff57aca 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/ce4/snmpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/ce4/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/r1/snmpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/r1/snmpd.conf index c903c1ad2..2ada53ced 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/r1/snmpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/r1/snmpd.conf @@ -14,4 +14,7 @@ rouser frr master agentx -noRangeCheck yes
\ No newline at end of file +noRangeCheck yes + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/r2/snmpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/r2/snmpd.conf index 0cfebc723..3db1ab7ac 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/r2/snmpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/r2/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/r3/snmpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/r3/snmpd.conf index b9eb00ea5..494df81ff 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/r3/snmpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/r3/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/r4/snmpd.conf b/tests/topotests/bgp_snmp_mplsl3vpn/r4/snmpd.conf index ec35f9f9c..f3809607e 100644 --- a/tests/topotests/bgp_snmp_mplsl3vpn/r4/snmpd.conf +++ b/tests/topotests/bgp_snmp_mplsl3vpn/r4/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py b/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py index b830e16b9..37486f1d7 100755 --- a/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py +++ b/tests/topotests/bgp_snmp_mplsl3vpn/test_bgp_snmp_mplsvpn.py @@ -45,7 +45,7 @@ from lib.topolog import logger from lib.snmptest import SnmpTester # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.snmp] @@ -255,7 +255,7 @@ def test_pe1_converge_evpn(): "Wait for protocol convergence" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") assertmsg = "BGP SNMP does not seem to be running" @@ -297,7 +297,7 @@ interfaces_down_test = { def test_r1_mplsvpn_scalars(): "check scalar values" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") for item in interfaces_up_test.keys(): @@ -310,12 +310,11 @@ def test_r1_mplsvpn_scalars(): def test_r1_mplsvpn_scalars_interface(): "check scalar interface changing values" tgen = get_topogen() - r1 = tgen.net.get("r1") - r1_cmd = tgen.gears["r1"] + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") - r1_cmd.vtysh_cmd("conf t\ninterface r1-eth3\nshutdown") - r1_cmd.vtysh_cmd("conf t\ninterface r1-eth4\nshutdown") + r1.vtysh_cmd("conf t\ninterface r1-eth3\nshutdown") + r1.vtysh_cmd("conf t\ninterface r1-eth4\nshutdown") for item in interfaces_up_test.keys(): assertmsg = "{} should be {}: value {}".format( @@ -323,8 +322,8 @@ def test_r1_mplsvpn_scalars_interface(): ) assert r1_snmp.test_oid(item, interfaces_down_test[item]), assertmsg - r1_cmd.vtysh_cmd("conf t\ninterface r1-eth3\nno shutdown") - r1_cmd.vtysh_cmd("conf t\ninterface r1-eth4\nno shutdown") + r1.vtysh_cmd("conf t\ninterface r1-eth3\nno shutdown") + r1.vtysh_cmd("conf t\ninterface r1-eth4\nno shutdown") for item in interfaces_up_test.keys(): assertmsg = "{} should be {}: value {}".format( @@ -378,15 +377,14 @@ def test_r1_mplsvpn_IfTable(): "mplsL3VpnIf table values" tgen = get_topogen() - r1 = tgen.net.get("r1") - r1r = tgen.gears["r1"] + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") # tgen.mininet_cli() - eth3_ifindex = router_interface_get_ifindex(r1r, "eth3") - eth4_ifindex = router_interface_get_ifindex(r1r, "eth4") - eth5_ifindex = router_interface_get_ifindex(r1r, "eth5") + eth3_ifindex = router_interface_get_ifindex(r1, "eth3") + eth4_ifindex = router_interface_get_ifindex(r1, "eth4") + eth5_ifindex = router_interface_get_ifindex(r1, "eth5") # get ifindex and make sure the oid is correct @@ -432,8 +430,7 @@ vrftable_test = { def test_r1_mplsvpn_VrfTable(): tgen = get_topogen() - r1 = tgen.net.get("r1") - r1r = tgen.gears["r1"] + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") @@ -476,7 +473,7 @@ def test_r1_mplsvpn_VrfTable(): "mplsL3VpnVrfConfLastChanged.{}".format(snmp_str_to_oid("VRF-a")) ) ts_val_last_1 = get_timetick_val(ts_last) - r1r.vtysh_cmd("conf t\ninterface r1-eth3\nshutdown") + r1.vtysh_cmd("conf t\ninterface r1-eth3\nshutdown") active_int = r1_snmp.get( "mplsL3VpnVrfActiveInterfaces.{}".format(snmp_str_to_oid("VRF-a")) ) @@ -491,7 +488,7 @@ def test_r1_mplsvpn_VrfTable(): ts_val_last_2 = get_timetick_val(ts_last) assertmsg = "mplsL3VpnVrfConfLastChanged does not update on interface change" assert ts_val_last_2 > ts_val_last_1, assertmsg - r1r.vtysh_cmd("conf t\ninterface r1-eth3\nno shutdown") + r1.vtysh_cmd("conf t\ninterface r1-eth3\nno shutdown") # take Last changed time, fiddle with associated interfaces, ensure # time changes and active interfaces change @@ -533,8 +530,7 @@ rt_table_test = { def test_r1_mplsvpn_VrfRT_table(): tgen = get_topogen() - r1 = tgen.net.get("r1") - r1r = tgen.gears["r1"] + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") @@ -554,8 +550,7 @@ def test_r1_mplsvpn_VrfRT_table(): def test_r1_mplsvpn_perf_table(): tgen = get_topogen() - r1 = tgen.net.get("r1") - r1r = tgen.gears["r1"] + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") @@ -682,8 +677,7 @@ rte_table_test = { def test_r1_mplsvpn_rte_table(): tgen = get_topogen() - r1 = tgen.net.get("r1") - r1r = tgen.gears["r1"] + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "10.1.1.1", "public", "2c") @@ -734,12 +728,12 @@ def test_r1_mplsvpn_rte_table(): # generate ifindex row grabbing ifindices from vtysh if passed: ifindex_row = [ - router_interface_get_ifindex(r1r, "eth3"), - router_interface_get_ifindex(r1r, "eth4"), - router_interface_get_ifindex(r1r, "eth2"), - router_interface_get_ifindex(r1r, "eth3"), + router_interface_get_ifindex(r1, "eth3"), + router_interface_get_ifindex(r1, "eth4"), + router_interface_get_ifindex(r1, "eth2"), + router_interface_get_ifindex(r1, "eth3"), "0", - router_interface_get_ifindex(r1r, "eth4"), + router_interface_get_ifindex(r1, "eth4"), "0", ] if not r1_snmp.test_oid_walk( diff --git a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py index 325148451..a50151ab2 100755 --- a/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py +++ b/tests/topotests/bgp_srv6l3vpn_to_bgp_vrf/test_bgp_srv6l3vpn_to_bgp_vrf.py @@ -37,7 +37,7 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger from lib.common_config import required_linux_kernel_version -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py b/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py index 476f6b556..3e421ad5c 100644 --- a/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py +++ b/tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py b/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py index cb1d28cc0..7ca30daf4 100644 --- a/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py +++ b/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py @@ -49,7 +49,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_update_delay/test_bgp_update_delay.py b/tests/topotests/bgp_update_delay/test_bgp_update_delay.py index 2972a25f3..a936d44d1 100644 --- a/tests/topotests/bgp_update_delay/test_bgp_update_delay.py +++ b/tests/topotests/bgp_update_delay/test_bgp_update_delay.py @@ -71,7 +71,7 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py index 1e371f219..55b4f1581 100644 --- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py +++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py @@ -49,7 +49,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen from lib.topotest import version_cmp -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py index f701529b5..18f048129 100644 --- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py +++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py @@ -47,7 +47,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen from lib.topotest import version_cmp -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, diff --git a/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py b/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py index 57ba87e88..b818816d9 100644 --- a/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py +++ b/tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py @@ -45,7 +45,7 @@ from lib.topolog import logger from lib.common_config import required_linux_kernel_version # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py b/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py index 60511aebd..9c4c78bf1 100644 --- a/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py +++ b/tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py @@ -42,7 +42,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] @@ -108,24 +108,11 @@ def setup_module(module): # create VRF r1-bgp-cust1 # move r1-eth0 to VRF r1-bgp-cust1 - cmds = [ - "if [ -e /var/run/netns/{0}-bgp-cust1 ] ; then ip netns del {0}-bgp-cust1 ; fi", - "ip netns add {0}-bgp-cust1", - "ip link set {0}-eth0 netns {0}-bgp-cust1 up", - ] - for cmd in cmds: - cmd = cmd.format("r1") - logger.info("cmd: " + cmd) - output = router.run(cmd.format("r1")) - if output != None and len(output) > 0: - logger.info( - 'Aborting due to unexpected output: cmd="{}" output=\n{}'.format( - cmd, output - ) - ) - return pytest.skip( - "Skipping BGP VRF NETNS Test. Unexpected output to command: " + cmd - ) + + ns = "{}-bgp-cust1".format("r1") + router.net.add_netns(ns) + router.net.set_intf_netns("r1-eth0", ns, up=True) + # run daemons router.load_config( TopoRouter.RD_ZEBRA, @@ -152,14 +139,10 @@ def setup_module(module): def teardown_module(module): tgen = get_topogen() - # move back r1-eth0 to default VRF - # delete VRF r1-bgp-cust1 - cmds = [ - "ip netns exec {0}-bgp-cust1 ip link set {0}-eth0 netns 1", - "ip netns delete {0}-bgp-cust1", - ] - for cmd in cmds: - tgen.net["r1"].cmd(cmd.format("r1")) + + # Move interfaces out of vrf namespace and delete the namespace + tgen.net["r1"].reset_intf_netns("r1-eth0") + tgen.net["r1"].delete_netns("r1-bgp-cust1") tgen.stop_topology() diff --git a/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py b/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py index fcec0c23a..7ab2c608b 100644 --- a/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py +++ b/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py @@ -39,7 +39,7 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd] diff --git a/tests/topotests/config_timing/test_config_timing.py b/tests/topotests/config_timing/test_config_timing.py index db8baa860..54dca32e1 100644 --- a/tests/topotests/config_timing/test_config_timing.py +++ b/tests/topotests/config_timing/test_config_timing.py @@ -45,7 +45,7 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.staticd] @@ -172,7 +172,7 @@ def test_static_timing(): do_config(prefix_count, bad_indices, base_delta, 2, True, ipv6, prefix_base[ipv6][0]) # Remove 1/2 of duplicate - do_config(prefix_count / 2, bad_indices, base_delta, 2, False, ipv6, prefix_base[ipv6][0]) + do_config(prefix_count // 2, bad_indices, base_delta, 2, False, ipv6, prefix_base[ipv6][0]) # Add all back in so 1/2 replicate 1/2 new do_config(prefix_count, bad_indices, base_delta, 2, True, ipv6, prefix_base[ipv6][0]) diff --git a/tests/topotests/eigrp_topo1/test_eigrp_topo1.py b/tests/topotests/eigrp_topo1/test_eigrp_topo1.py index 6993bc53e..982d3f0fa 100644 --- a/tests/topotests/eigrp_topo1/test_eigrp_topo1.py +++ b/tests/topotests/eigrp_topo1/test_eigrp_topo1.py @@ -46,7 +46,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo ##################################################### ## diff --git a/tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py b/tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py index b1f5daef1..e549d1acb 100644 --- a/tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py +++ b/tests/topotests/evpn_pim_1/test_evpn_pim_topo1.py @@ -47,7 +47,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.bgpd] diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py index 09d66baa7..86253acc4 100644 --- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py +++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py @@ -51,7 +51,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # Import topogen and topotest helpers from lib.topotest import version_cmp from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, @@ -99,7 +99,6 @@ except IOError: # Reading the data from JSON File for topology creation # Global variables TCPDUMP_FILE = "evpn_log.txt" -LOGDIR = "/tmp/topotests/" NETWORK1_1 = {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"} NETWORK1_2 = {"ipv4": "40.1.1.1/32", "ipv6": "40::1/128"} NETWORK1_3 = {"ipv4": "40.1.1.2/32", "ipv6": "40::2/128"} diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py index 521f2335b..4f2aef17c 100644 --- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py +++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py @@ -55,7 +55,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # Import topogen and topotest helpers from lib.topotest import version_cmp from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, diff --git a/tests/topotests/example_test/test_template.py b/tests/topotests/example_test/test_template.py index 0265dbe79..534dd998d 100644 --- a/tests/topotests/example_test/test_template.py +++ b/tests/topotests/example_test/test_template.py @@ -41,7 +41,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo # TODO: select markers based on daemons used during test @@ -87,7 +87,7 @@ def setup_module(mod): "Sets up the pytest environment" # This function initiates the topology build with Topogen... tgen = Topogen(TemplateTopo, mod.__name__) - # ... and here it calls Mininet initialization functions. + # ... and here it calls initialization functions. tgen.start_topology() # This is a sample of configuration loading. @@ -113,15 +113,15 @@ def teardown_module(mod): tgen.stop_topology() -def test_call_mininet_cli(): - "Dummy test that just calls mininet CLI so we can interact with the build." +def test_call_cli(): + "Dummy test that just calls tgen.cli() so we can interact with the build." tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) - logger.info("calling mininet CLI") - tgen.mininet_cli() + # logger.info("calling CLI") + # tgen.cli() # Memory leak test template diff --git a/tests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py b/tests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py index 09ac9f2fa..b08861637 100755 --- a/tests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py +++ b/tests/topotests/example_topojson_test/test_topo_json_multiple_links/test_example_topojson_multiple_links.py @@ -40,7 +40,7 @@ sys.path.append(os.path.join(CWD, "../../")) from lib.topogen import Topogen, get_topogen # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo # Import topoJson from lib, to create topology and initial configuration from lib.common_config import ( diff --git a/tests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py b/tests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py index 26336d5de..4b13dce7d 100755 --- a/tests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py +++ b/tests/topotests/example_topojson_test/test_topo_json_single_link/test_example_topojson.py @@ -39,7 +39,7 @@ sys.path.append(os.path.join(CWD, "../../")) from lib.topogen import Topogen, get_topogen # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo # Import topoJson from lib, to create topology and initial configuration from lib.common_config import ( diff --git a/tests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py b/tests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py index 012b05d37..07d13cb71 100755 --- a/tests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py +++ b/tests/topotests/example_topojson_test/test_topo_json_single_link_loopback/test_example_topojson.py @@ -41,7 +41,7 @@ sys.path.append(os.path.join(CWD, "../../")) from lib.topogen import Topogen, get_topogen # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo # Import topoJson from lib, to create topology and initial configuration from lib.common_config import ( diff --git a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py index dcfcd1143..a253b11c0 100755 --- a/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py +++ b/tests/topotests/isis_lfa_topo1/test_isis_lfa_topo1.py @@ -71,7 +71,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd] @@ -79,91 +79,87 @@ pytestmark = [pytest.mark.isisd] outputs = {} -class TemplateTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # - # Define FRR Routers - # - for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "rt7"]: - tgen.add_router(router) - - # - # Define connections - # - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1") - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt3") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt2") - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1") - switch = tgen.add_switch("s4") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt4") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt1") - switch = tgen.add_switch("s5") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt5") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt1") - switch = tgen.add_switch("s6") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt6") - switch.add_link(tgen.gears["rt6"], nodeif="eth-rt1") - switch = tgen.add_switch("s7") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt7") - switch.add_link(tgen.gears["rt7"], nodeif="eth-rt2") - switch = tgen.add_switch("s8") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt7") - switch.add_link(tgen.gears["rt7"], nodeif="eth-rt3") - switch = tgen.add_switch("s9") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt7") - switch.add_link(tgen.gears["rt7"], nodeif="eth-rt4") - switch = tgen.add_switch("s10") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt7") - switch.add_link(tgen.gears["rt7"], nodeif="eth-rt5") - switch = tgen.add_switch("s11") - switch.add_link(tgen.gears["rt6"], nodeif="eth-rt7") - switch.add_link(tgen.gears["rt7"], nodeif="eth-rt6") - - # - # Populate multi-dimensional dictionary containing all expected outputs - # - files = ["show_ipv6_route.ref", "show_yang_interface_isis_adjacencies.ref"] - for rname in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "rt7"]: - outputs[rname] = {} - for step in range(1, 13 + 1): - outputs[rname][step] = {} - for file in files: - if step == 1: - # Get snapshots relative to the expected initial network convergence - filename = "{}/{}/step{}/{}".format(CWD, rname, step, file) - outputs[rname][step][file] = open(filename).read() - else: - if rname != "rt1": - continue - if file == "show_yang_interface_isis_adjacencies.ref": - continue - - # Get diff relative to the previous step - filename = "{}/{}/step{}/{}.diff".format(CWD, rname, step, file) - - # Create temporary files in order to apply the diff - f_in = tempfile.NamedTemporaryFile() - f_in.write(outputs[rname][step - 1][file]) - f_in.flush() - f_out = tempfile.NamedTemporaryFile() - os.system( - "patch -s -o %s %s %s" % (f_out.name, f_in.name, filename) - ) - - # Store the updated snapshot and remove the temporary files - outputs[rname][step][file] = open(f_out.name).read() - f_in.close() - f_out.close() +def build_topo(tgen): + "Build function" + + # + # Define FRR Routers + # + for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "rt7"]: + tgen.add_router(router) + + # + # Define connections + # + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1") + switch = tgen.add_switch("s2") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt3") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt2") + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1") + switch = tgen.add_switch("s4") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt4") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt1") + switch = tgen.add_switch("s5") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt5") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt1") + switch = tgen.add_switch("s6") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt6") + switch.add_link(tgen.gears["rt6"], nodeif="eth-rt1") + switch = tgen.add_switch("s7") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt7") + switch.add_link(tgen.gears["rt7"], nodeif="eth-rt2") + switch = tgen.add_switch("s8") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt7") + switch.add_link(tgen.gears["rt7"], nodeif="eth-rt3") + switch = tgen.add_switch("s9") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt7") + switch.add_link(tgen.gears["rt7"], nodeif="eth-rt4") + switch = tgen.add_switch("s10") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt7") + switch.add_link(tgen.gears["rt7"], nodeif="eth-rt5") + switch = tgen.add_switch("s11") + switch.add_link(tgen.gears["rt6"], nodeif="eth-rt7") + switch.add_link(tgen.gears["rt7"], nodeif="eth-rt6") + + # + # Populate multi-dimensional dictionary containing all expected outputs + # + files = ["show_ipv6_route.ref", "show_yang_interface_isis_adjacencies.ref"] + for rname in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "rt7"]: + outputs[rname] = {} + for step in range(1, 13 + 1): + outputs[rname][step] = {} + for file in files: + if step == 1: + # Get snapshots relative to the expected initial network convergence + filename = "{}/{}/step{}/{}".format(CWD, rname, step, file) + outputs[rname][step][file] = open(filename).read() + else: + if rname != "rt1": + continue + if file == "show_yang_interface_isis_adjacencies.ref": + continue + + # Get diff relative to the previous step + filename = "{}/{}/step{}/{}.diff".format(CWD, rname, step, file) + + # Create temporary files in order to apply the diff + f_in = tempfile.NamedTemporaryFile(mode="w") + f_in.write(outputs[rname][step - 1][file]) + f_in.flush() + f_out = tempfile.NamedTemporaryFile(mode="r") + os.system( + "patch -s -o %s %s %s" % (f_out.name, f_in.name, filename) + ) + + # Store the updated snapshot and remove the temporary files + outputs[rname][step][file] = open(f_out.name).read() + f_in.close() + f_out.close() def setup_module(mod): diff --git a/tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py b/tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py index 70dcff035..df174e953 100755 --- a/tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py +++ b/tests/topotests/isis_lsp_bits_topo1/test_isis_lsp_bits_topo1.py @@ -82,7 +82,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd] diff --git a/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py b/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py index ded1a4cc2..325638a47 100755 --- a/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py +++ b/tests/topotests/isis_rlfa_topo1/test_isis_rlfa_topo1.py @@ -80,7 +80,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd, pytest.mark.ldpd] @@ -88,84 +88,80 @@ pytestmark = [pytest.mark.isisd, pytest.mark.ldpd] outputs = {} -class TemplateTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # - # Define FRR Routers - # - for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "rt7", "rt8"]: - tgen.add_router(router) - - # - # Define connections - # - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1") - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1") - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2") - switch = tgen.add_switch("s4") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3") - switch = tgen.add_switch("s5") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6") - switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4") - switch = tgen.add_switch("s6") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt7") - switch.add_link(tgen.gears["rt7"], nodeif="eth-rt5") - switch = tgen.add_switch("s7") - switch.add_link(tgen.gears["rt6"], nodeif="eth-rt8") - switch.add_link(tgen.gears["rt8"], nodeif="eth-rt6") - switch = tgen.add_switch("s8") - switch.add_link(tgen.gears["rt7"], nodeif="eth-rt8") - switch.add_link(tgen.gears["rt8"], nodeif="eth-rt7") - - # - # Populate multi-dimensional dictionary containing all expected outputs - # - files = [ - "show_ip_route.ref", - "show_ipv6_route.ref", - "show_yang_interface_isis_adjacencies.ref", - ] - for rname in ["rt1"]: - outputs[rname] = {} - for step in range(1, 10 + 1): - outputs[rname][step] = {} - for file in files: - if step == 1: - # Get snapshots relative to the expected initial network convergence - filename = "{}/{}/step{}/{}".format(CWD, rname, step, file) - outputs[rname][step][file] = open(filename).read() - else: - if file == "show_yang_interface_isis_adjacencies.ref": - continue - - # Get diff relative to the previous step - filename = "{}/{}/step{}/{}.diff".format(CWD, rname, step, file) - - # Create temporary files in order to apply the diff - f_in = tempfile.NamedTemporaryFile() - f_in.write(outputs[rname][step - 1][file]) - f_in.flush() - f_out = tempfile.NamedTemporaryFile() - os.system( - "patch -s -o %s %s %s" % (f_out.name, f_in.name, filename) - ) - - # Store the updated snapshot and remove the temporary files - outputs[rname][step][file] = open(f_out.name).read() - f_in.close() - f_out.close() +def build_topo(tgen): + "Build function" + + # + # Define FRR Routers + # + for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6", "rt7", "rt8"]: + tgen.add_router(router) + + # + # Define connections + # + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1") + switch = tgen.add_switch("s2") + switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1") + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2") + switch = tgen.add_switch("s4") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3") + switch = tgen.add_switch("s5") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6") + switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4") + switch = tgen.add_switch("s6") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt7") + switch.add_link(tgen.gears["rt7"], nodeif="eth-rt5") + switch = tgen.add_switch("s7") + switch.add_link(tgen.gears["rt6"], nodeif="eth-rt8") + switch.add_link(tgen.gears["rt8"], nodeif="eth-rt6") + switch = tgen.add_switch("s8") + switch.add_link(tgen.gears["rt7"], nodeif="eth-rt8") + switch.add_link(tgen.gears["rt8"], nodeif="eth-rt7") + + # + # Populate multi-dimensional dictionary containing all expected outputs + # + files = [ + "show_ip_route.ref", + "show_ipv6_route.ref", + "show_yang_interface_isis_adjacencies.ref", + ] + for rname in ["rt1"]: + outputs[rname] = {} + for step in range(1, 10 + 1): + outputs[rname][step] = {} + for file in files: + if step == 1: + # Get snapshots relative to the expected initial network convergence + filename = "{}/{}/step{}/{}".format(CWD, rname, step, file) + outputs[rname][step][file] = open(filename).read() + else: + if file == "show_yang_interface_isis_adjacencies.ref": + continue + + # Get diff relative to the previous step + filename = "{}/{}/step{}/{}.diff".format(CWD, rname, step, file) + + # Create temporary files in order to apply the diff + f_in = tempfile.NamedTemporaryFile(mode="w") + f_in.write(outputs[rname][step - 1][file]) + f_in.flush() + f_out = tempfile.NamedTemporaryFile(mode="r") + os.system( + "patch -s -o %s %s %s" % (f_out.name, f_in.name, filename) + ) + + # Store the updated snapshot and remove the temporary files + outputs[rname][step][file] = open(f_out.name).read() + f_in.close() + f_out.close() def setup_module(mod): diff --git a/tests/topotests/isis_snmp/r1/snmpd.conf b/tests/topotests/isis_snmp/r1/snmpd.conf index b37911da3..3fd5e982e 100644 --- a/tests/topotests/isis_snmp/r1/snmpd.conf +++ b/tests/topotests/isis_snmp/r1/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/isis_snmp/r2/snmpd.conf b/tests/topotests/isis_snmp/r2/snmpd.conf index 0f779b8b9..fc648057a 100644 --- a/tests/topotests/isis_snmp/r2/snmpd.conf +++ b/tests/topotests/isis_snmp/r2/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/isis_snmp/r3/snmpd.conf b/tests/topotests/isis_snmp/r3/snmpd.conf index 3f3501a6f..20af65e43 100644 --- a/tests/topotests/isis_snmp/r3/snmpd.conf +++ b/tests/topotests/isis_snmp/r3/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/isis_snmp/r4/snmpd.conf b/tests/topotests/isis_snmp/r4/snmpd.conf index e5e336d88..76e4b7906 100644 --- a/tests/topotests/isis_snmp/r4/snmpd.conf +++ b/tests/topotests/isis_snmp/r4/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/isis_snmp/r5/snmpd.conf b/tests/topotests/isis_snmp/r5/snmpd.conf index 5bebbdebd..af59194bc 100644 --- a/tests/topotests/isis_snmp/r5/snmpd.conf +++ b/tests/topotests/isis_snmp/r5/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/isis_snmp/test_isis_snmp.py b/tests/topotests/isis_snmp/test_isis_snmp.py index 2cd07299b..c6fc69800 100755 --- a/tests/topotests/isis_snmp/test_isis_snmp.py +++ b/tests/topotests/isis_snmp/test_isis_snmp.py @@ -80,7 +80,7 @@ from lib.topolog import logger from lib.snmptest import SnmpTester # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd, pytest.mark.ldpd, pytest.mark.snmp] @@ -219,7 +219,7 @@ def test_r1_scalar_snmp(): if tgen.routers_have_failure(): pytest.skip(tgen.errors) - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid("isisSysVersion", "one(1)") @@ -231,7 +231,7 @@ def test_r1_scalar_snmp(): assert r1_snmp.test_oid("isisSysMaxAge", "1200 seconds") assert r1_snmp.test_oid("isisSysProtSupported", "07 5 6 7") - r2 = tgen.net.get("r2") + r2 = tgen.gears["r2"] r2_snmp = SnmpTester(r2, "2.2.2.2", "public", "2c") assert r2_snmp.test_oid("isisSysVersion", "one(1)") @@ -260,9 +260,7 @@ circtable_test = { def test_r1_isisCircTable(): tgen = get_topogen() - r1 = tgen.net.get("r1") - r1r = tgen.gears["r1"] - + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") oids = [] @@ -296,9 +294,7 @@ circleveltable_test = { def test_r1_isislevelCircTable(): tgen = get_topogen() - r1 = tgen.net.get("r1") - r1r = tgen.gears["r1"] - + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") oids = [] @@ -335,8 +331,7 @@ adjtable_down_test = { def test_r1_isisAdjTable(): "check ISIS Adjacency Table" tgen = get_topogen() - r1 = tgen.net.get("r1") - r1_cmd = tgen.gears["r1"] + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") oids = [] @@ -355,7 +350,7 @@ def test_r1_isisAdjTable(): # shutdown interface and one adjacency should be removed "check ISIS adjacency is removed when interface is shutdown" - r1_cmd.vtysh_cmd("conf t\ninterface r1-eth1\nshutdown") + r1.vtysh_cmd("conf t\ninterface r1-eth1\nshutdown") r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") for item in adjtable_down_test.keys(): @@ -367,7 +362,7 @@ def test_r1_isisAdjTable(): ), assertmsg # no shutdown interface and adjacency should be restored - r1_cmd.vtysh_cmd("conf t\ninterface r1-eth1\nno shutdown") + r1.vtysh_cmd("conf t\ninterface r1-eth1\nno shutdown") # Memory leak test template diff --git a/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py b/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py index 6bbb57026..06d15afe6 100755 --- a/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py +++ b/tests/topotests/isis_sr_te_topo1/test_isis_sr_te_topo1.py @@ -94,7 +94,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.pathd] diff --git a/tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py b/tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py index c22bd65d2..8aa187871 100644 --- a/tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py +++ b/tests/topotests/isis_sr_topo1/test_isis_sr_topo1.py @@ -82,7 +82,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd] diff --git a/tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py b/tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py index 00cb62399..351bce99e 100755 --- a/tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py +++ b/tests/topotests/isis_tilfa_topo1/test_isis_tilfa_topo1.py @@ -83,7 +83,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd] @@ -91,93 +91,89 @@ pytestmark = [pytest.mark.isisd] outputs = {} -class TemplateTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # - # Define FRR Routers - # - for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]: - tgen.add_router(router) - - # - # Define connections - # - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1") - switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1") - switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1") - - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1") - - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2") - - switch = tgen.add_switch("s4") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1") - - switch = tgen.add_switch("s5") - switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2") - - switch = tgen.add_switch("s6") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4") - - switch = tgen.add_switch("s7") - switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6") - switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4") - - switch = tgen.add_switch("s8") - switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6") - switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5") - - # - # Populate multi-dimensional dictionary containing all expected outputs - # - files = [ - "show_ip_route.ref", - "show_ipv6_route.ref", - "show_mpls_table.ref", - "show_yang_interface_isis_adjacencies.ref", - ] - for rname in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]: - outputs[rname] = {} - for step in range(1, 9 + 1): - outputs[rname][step] = {} - for file in files: - if step == 1: - # Get snapshots relative to the expected initial network convergence - filename = "{}/{}/step{}/{}".format(CWD, rname, step, file) - outputs[rname][step][file] = open(filename).read() - else: - if file == "show_yang_interface_isis_adjacencies.ref": - continue - - # Get diff relative to the previous step - filename = "{}/{}/step{}/{}.diff".format(CWD, rname, step, file) - - # Create temporary files in order to apply the diff - f_in = tempfile.NamedTemporaryFile() - f_in.write(outputs[rname][step - 1][file]) - f_in.flush() - f_out = tempfile.NamedTemporaryFile() - os.system( - "patch -s -o %s %s %s" % (f_out.name, f_in.name, filename) - ) - - # Store the updated snapshot and remove the temporary files - outputs[rname][step][file] = open(f_out.name).read() - f_in.close() - f_out.close() +def build_topo(tgen): + "Build function" + + # + # Define FRR Routers + # + for router in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]: + tgen.add_router(router) + + # + # Define connections + # + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["rt1"], nodeif="eth-sw1") + switch.add_link(tgen.gears["rt2"], nodeif="eth-sw1") + switch.add_link(tgen.gears["rt3"], nodeif="eth-sw1") + + switch = tgen.add_switch("s2") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-1") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-1") + + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["rt2"], nodeif="eth-rt4-2") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt2-2") + + switch = tgen.add_switch("s4") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-1") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-1") + + switch = tgen.add_switch("s5") + switch.add_link(tgen.gears["rt3"], nodeif="eth-rt5-2") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt3-2") + + switch = tgen.add_switch("s6") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4") + + switch = tgen.add_switch("s7") + switch.add_link(tgen.gears["rt4"], nodeif="eth-rt6") + switch.add_link(tgen.gears["rt6"], nodeif="eth-rt4") + + switch = tgen.add_switch("s8") + switch.add_link(tgen.gears["rt5"], nodeif="eth-rt6") + switch.add_link(tgen.gears["rt6"], nodeif="eth-rt5") + + # + # Populate multi-dimensional dictionary containing all expected outputs + # + files = [ + "show_ip_route.ref", + "show_ipv6_route.ref", + "show_mpls_table.ref", + "show_yang_interface_isis_adjacencies.ref", + ] + for rname in ["rt1", "rt2", "rt3", "rt4", "rt5", "rt6"]: + outputs[rname] = {} + for step in range(1, 9 + 1): + outputs[rname][step] = {} + for file in files: + if step == 1: + # Get snapshots relative to the expected initial network convergence + filename = "{}/{}/step{}/{}".format(CWD, rname, step, file) + outputs[rname][step][file] = open(filename).read() + else: + if file == "show_yang_interface_isis_adjacencies.ref": + continue + + # Get diff relative to the previous step + filename = "{}/{}/step{}/{}.diff".format(CWD, rname, step, file) + + # Create temporary files in order to apply the diff + f_in = tempfile.NamedTemporaryFile(mode="w") + f_in.write(outputs[rname][step - 1][file]) + f_in.flush() + f_out = tempfile.NamedTemporaryFile(mode="r") + os.system( + "patch -s -o %s %s %s" % (f_out.name, f_in.name, filename) + ) + + # Store the updated snapshot and remove the temporary files + outputs[rname][step][file] = open(f_out.name).read() + f_in.close() + f_out.close() def setup_module(mod): diff --git a/tests/topotests/isis_topo1/test_isis_topo1.py b/tests/topotests/isis_topo1/test_isis_topo1.py index 083a8b1e8..392722255 100644 --- a/tests/topotests/isis_topo1/test_isis_topo1.py +++ b/tests/topotests/isis_topo1/test_isis_topo1.py @@ -43,7 +43,7 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd] diff --git a/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py b/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py index ff1544e4a..67c60c729 100644 --- a/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py +++ b/tests/topotests/isis_topo1_vrf/test_isis_topo1_vrf.py @@ -43,7 +43,7 @@ from lib.topolog import logger from lib.topotest import iproute2_is_vrf_capable from lib.common_config import required_linux_kernel_version -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd] diff --git a/tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py b/tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py index 9aa402459..f26c56e54 100644 --- a/tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py +++ b/tests/topotests/ldp_oc_acl_topo1/test_ldp_oc_acl_topo1.py @@ -76,7 +76,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] diff --git a/tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py b/tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py index aef22c395..5208728a9 100644 --- a/tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py +++ b/tests/topotests/ldp_oc_topo1/test_ldp_oc_topo1.py @@ -76,7 +76,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] diff --git a/tests/topotests/ldp_snmp/r1/snmpd.conf b/tests/topotests/ldp_snmp/r1/snmpd.conf index b37911da3..3fd5e982e 100644 --- a/tests/topotests/ldp_snmp/r1/snmpd.conf +++ b/tests/topotests/ldp_snmp/r1/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/ldp_snmp/r2/snmpd.conf b/tests/topotests/ldp_snmp/r2/snmpd.conf index 0f779b8b9..fc648057a 100644 --- a/tests/topotests/ldp_snmp/r2/snmpd.conf +++ b/tests/topotests/ldp_snmp/r2/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr
\ No newline at end of file diff --git a/tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py b/tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py index 8052316d7..f0473257c 100644 --- a/tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py +++ b/tests/topotests/ldp_snmp/test_ldp_snmp_topo1.py @@ -79,7 +79,7 @@ from lib.topolog import logger from lib.snmptest import SnmpTester # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ldpd, pytest.mark.isisd, pytest.mark.snmp] @@ -241,7 +241,7 @@ def test_r1_ldp_lsr_objects(): "Test mplsLdpLsrObjects objects" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid("mplsLdpLsrId", "01 01 01 01") @@ -252,7 +252,7 @@ def test_r1_ldp_entity_table(): "Test mplsLdpEntityTable" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid_walk("mplsLdpEntityLdpId", ["1.1.1.1:0"]) @@ -286,7 +286,7 @@ def test_r1_ldp_entity_stats_table(): "Test mplsLdpEntityStatsTable" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid_walk("mplsLdpEntityStatsSessionAttempts", ["0"]) @@ -312,7 +312,7 @@ def test_r1_ldp_peer_table(): "Test mplsLdpPeerTable" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid_walk("mplsLdpPeerLdpId", ["2.2.2.2:0", "3.3.3.3:0"]) @@ -331,7 +331,7 @@ def test_r1_ldp_session_table(): "Test mplsLdpSessionTable" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid_walk( @@ -354,7 +354,7 @@ def test_r1_ldp_session_stats_table(): "Test mplsLdpSessionStatsTable" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid_walk("mplsLdpSessionStatsUnknownMesTypeErrors", ["0", "0"]) @@ -365,7 +365,7 @@ def test_r1_ldp_hello_adjacency_table(): "Test mplsLdpHelloAdjacencyTable" tgen = get_topogen() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid_walk("mplsLdpHelloAdjacencyIndex", ["1", "2", "1"]) diff --git a/tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py b/tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py index 44b34c485..3c26bd5ba 100644 --- a/tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py +++ b/tests/topotests/ldp_sync_isis_topo1/test_ldp_sync_isis_topo1.py @@ -78,7 +78,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.isisd, pytest.mark.ldpd] @@ -466,20 +466,20 @@ def parse_show_isis_ldp_sync(lines, rname): interface = {} interface_name = None - line = it.next() + line = next(it) if line.startswith(rname + "-eth"): interface_name = line - line = it.next() + line = next(it) if line.startswith(" LDP-IGP Synchronization enabled: "): interface["ldpIgpSyncEnabled"] = line.endswith("yes") - line = it.next() + line = next(it) if line.startswith(" holddown timer in seconds: "): interface["holdDownTimeInSec"] = int(line.split(": ")[-1]) - line = it.next() + line = next(it) if line.startswith(" State: "): interface["ldpIgpSyncState"] = line.split(": ")[-1] @@ -539,7 +539,7 @@ def parse_show_isis_interface_detail(lines, rname): while True: try: - line = it.next() + line = next(it) area_match = re.match(r"Area (.+):", line) if not area_match: @@ -548,7 +548,7 @@ def parse_show_isis_interface_detail(lines, rname): area_id = area_match.group(1) area = {} - line = it.next() + line = next(it) while line.startswith(" Interface: "): interface_name = re.split(":|,", line)[1].lstrip() @@ -557,7 +557,7 @@ def parse_show_isis_interface_detail(lines, rname): # Look for keyword: Level-1 or Level-2 while not line.startswith(" Level-"): - line = it.next() + line = next(it) while line.startswith(" Level-"): @@ -566,7 +566,7 @@ def parse_show_isis_interface_detail(lines, rname): level_name = line.split()[0] level["level"] = level_name - line = it.next() + line = next(it) if line.startswith(" Metric:"): level["metric"] = re.split(":|,", line)[1].lstrip() @@ -577,7 +577,7 @@ def parse_show_isis_interface_detail(lines, rname): while not line.startswith(" Level-") and not line.startswith( " Interface: " ): - line = it.next() + line = next(it) if line.startswith(" Level-"): continue diff --git a/tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py b/tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py index 57b45e5fd..c5bd97edf 100644 --- a/tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py +++ b/tests/topotests/ldp_sync_ospf_topo1/test_ldp_sync_ospf_topo1.py @@ -77,7 +77,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] diff --git a/tests/topotests/ldp_topo1/test_ldp_topo1.py b/tests/topotests/ldp_topo1/test_ldp_topo1.py index 06e773409..c0f869f82 100644 --- a/tests/topotests/ldp_topo1/test_ldp_topo1.py +++ b/tests/topotests/ldp_topo1/test_ldp_topo1.py @@ -65,15 +65,10 @@ import sys import pytest from time import sleep -from mininet.topo import Topo -from mininet.net import Mininet -from mininet.node import Node, OVSSwitch, Host -from mininet.log import setLogLevel, info -from mininet.cli import CLI -from mininet.link import Intf - sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from lib import topotest +from lib.micronet_compat import Topo +from lib.micronet_compat import Mininet fatal_error = "" @@ -99,7 +94,7 @@ class NetworkTopo(Topo): # Setup Switches, add Interfaces and Connections switch = {} # First switch - switch[0] = self.addSwitch("sw0", cls=topotest.LegacySwitch) + switch[0] = self.addSwitch("sw0") self.addLink( switch[0], router[1], @@ -115,7 +110,7 @@ class NetworkTopo(Topo): addr2="00:11:00:02:00:00", ) # Second switch - switch[1] = self.addSwitch("sw1", cls=topotest.LegacySwitch) + switch[1] = self.addSwitch("sw1") self.addLink( switch[1], router[2], @@ -138,7 +133,7 @@ class NetworkTopo(Topo): addr2="00:11:00:04:00:00", ) # Third switch - switch[2] = self.addSwitch("sw2", cls=topotest.LegacySwitch) + switch[2] = self.addSwitch("sw2") self.addLink( switch[2], router[2], @@ -885,7 +880,6 @@ def test_shutdown_check_memleak(): if __name__ == "__main__": - setLogLevel("info") # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli # retval = pytest.main(["-s", "--tb=no"]) retval = pytest.main(["-s"]) diff --git a/tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py b/tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py index 0ea7aca3e..8dc8039c9 100644 --- a/tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py +++ b/tests/topotests/ldp_vpls_topo1/test_ldp_vpls_topo1.py @@ -78,7 +78,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd] diff --git a/tests/topotests/lib/ltemplate.py b/tests/topotests/lib/ltemplate.py index 56eca4be0..1ea033a12 100644 --- a/tests/topotests/lib/ltemplate.py +++ b/tests/topotests/lib/ltemplate.py @@ -39,7 +39,7 @@ from lib.topolog import logger from lib.lutil import * # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo customize = None diff --git a/tests/topotests/lib/lutil.py b/tests/topotests/lib/lutil.py index f8f580632..7248ce267 100644 --- a/tests/topotests/lib/lutil.py +++ b/tests/topotests/lib/lutil.py @@ -26,7 +26,7 @@ import math import time from lib.topolog import logger from lib.topotest import json_cmp -from mininet.net import Mininet +from lib.micronet_compat import Mininet # L utility functions diff --git a/tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py b/tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py index 222fb28ad..a10477d28 100644 --- a/tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py +++ b/tests/topotests/msdp_mesh_topo1/test_msdp_mesh_topo1.py @@ -40,11 +40,11 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib import topotest +# Required to instantiate the topology builder class. +from lib.micronet_compat import Topo from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd, pytest.mark.pimd] @@ -52,21 +52,28 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd, pytest.mark.pimd] # Test global variables: # They are used to handle communicating with external application. # -APP_SOCK_PATH = '/tmp/topotests/apps.sock' HELPER_APP_PATH = os.path.join(CWD, "../lib/mcast-tester.py") app_listener = None app_clients = {} +app_procs = [] + + +def get_app_sock_path(): + tgen = get_topogen() + return os.path.join(tgen.logdir, "apps.sock") + def listen_to_applications(): "Start listening socket to connect with applications." # Remove old socket. + app_sock_path = get_app_sock_path() try: - os.unlink(APP_SOCK_PATH) + os.unlink(app_sock_path) except OSError: pass sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) - sock.bind(APP_SOCK_PATH) + sock.bind(app_sock_path) sock.listen(10) global app_listener app_listener = sock @@ -87,9 +94,11 @@ def close_applications(): # Close listening socket. app_listener.close() + app_sock_path = get_app_sock_path() + # Remove old socket. try: - os.unlink(APP_SOCK_PATH) + os.unlink(app_sock_path) except OSError: pass @@ -99,6 +108,10 @@ def close_applications(): continue app_clients["h1"]["fd"].close() + for p in app_procs: + p.terminate() + p.wait() + class MSDPMeshTopo1(Topo): "Test topology builder" @@ -120,12 +133,12 @@ class MSDPMeshTopo1(Topo): switch.add_link(tgen.gears["r3"]) # Create stub networks for multicast traffic. - tgen.add_host("h1", "192.168.10.2/24", "192.168.10.1") + tgen.add_host("h1", "192.168.10.2/24", "via 192.168.10.1") switch = tgen.add_switch("s3") switch.add_link(tgen.gears["r1"]) switch.add_link(tgen.gears["h1"]) - tgen.add_host("h2", "192.168.30.2/24", "192.168.30.1") + tgen.add_host("h2", "192.168.30.2/24", "via 192.168.30.1") switch = tgen.add_switch("s4") switch.add_link(tgen.gears["r3"]) switch.add_link(tgen.gears["h2"]) @@ -206,14 +219,6 @@ def test_wait_msdp_convergence(): logger.info("test MSDP convergence") - tgen.gears["h1"].run("{} --send='0.7' '{}' '{}' '{}' &".format( - HELPER_APP_PATH, APP_SOCK_PATH, '229.0.1.10', 'h1-eth0')) - accept_host("h1") - - tgen.gears["h2"].run("{} '{}' '{}' '{}' &".format( - HELPER_APP_PATH, APP_SOCK_PATH, '229.0.1.10', 'h2-eth0')) - accept_host("h2") - def expect_msdp_peer(router, peer, sa_count=0): "Expect MSDP peer connection to be established with SA amount." logger.info("waiting MSDP connection from peer {} on router {}".format(peer, router)) @@ -227,6 +232,22 @@ def test_wait_msdp_convergence(): assertmsg = '"{}" MSDP connection failure'.format(router) assert result is None, assertmsg + app_sock_path = get_app_sock_path() + + + python3_path = tgen.net.get_exec_path(["python3", "python"]) + ph_base = [python3_path, HELPER_APP_PATH, app_sock_path] + + ph1_cmd = ph_base + ["--send=0.7", "229.0.1.10", "h1-eth0"] + ph1 = tgen.gears["h1"].popen(ph1_cmd) + app_procs.append(ph1) + accept_host("h1") + + ph2_cmd = ph_base + ["229.0.1.10", "h2-eth0"] + ph2 = tgen.gears["h2"].popen(ph2_cmd) + app_procs.append(ph2) + accept_host("h2") + # R1 peers. expect_msdp_peer("r1", "10.254.254.2") expect_msdp_peer("r1", "10.254.254.3") diff --git a/tests/topotests/msdp_topo1/test_msdp_topo1.py b/tests/topotests/msdp_topo1/test_msdp_topo1.py index b860c04fa..796706a2e 100755 --- a/tests/topotests/msdp_topo1/test_msdp_topo1.py +++ b/tests/topotests/msdp_topo1/test_msdp_topo1.py @@ -41,11 +41,11 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib import topotest +# Required to instantiate the topology builder class. +from lib.micronet_compat import Topo from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -# Required to instantiate the topology builder class. -from mininet.topo import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.pimd] @@ -53,22 +53,30 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.pimd] # Test global variables: # They are used to handle communicating with external application. # -APP_SOCK_PATH = '/tmp/topotests/apps.sock' HELPER_APP_PATH = os.path.join(CWD, "../lib/mcast-tester.py") app_listener = None app_clients = {} +def get_app_sock_path(): + tgen = get_topogen() + return os.path.join(tgen.logdir, "apps.sock") + + def listen_to_applications(): "Start listening socket to connect with applications." + + app_sock_path = get_app_sock_path() # Remove old socket. try: - os.unlink(APP_SOCK_PATH) + os.unlink(app_sock_path) except OSError: pass sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) - sock.bind(APP_SOCK_PATH) + # Do not block forever + sock.settimeout(10) + sock.bind(app_sock_path) sock.listen(10) global app_listener app_listener = sock @@ -91,9 +99,10 @@ def close_applications(): # Close listening socket. app_listener.close() + app_sock_path = get_app_sock_path() # Remove old socket. try: - os.unlink(APP_SOCK_PATH) + os.unlink(app_sock_path) except OSError: pass @@ -135,12 +144,12 @@ class MSDPTopo1(Topo): switch.add_link(tgen.gears["r4"]) # Create a host connected and direct at r4: - tgen.add_host("h1", "192.168.4.100/24", "192.168.4.1") + tgen.add_host("h1", "192.168.4.100/24", "via 192.168.4.1") switch.add_link(tgen.gears["h1"]) # Create a host connected and direct at r1: switch = tgen.add_switch("s6") - tgen.add_host("h2", "192.168.10.100/24", "192.168.10.1") + tgen.add_host("h2", "192.168.10.100/24", "via 192.168.10.1") switch.add_link(tgen.gears["r1"]) switch.add_link(tgen.gears["h2"]) @@ -219,21 +228,12 @@ def test_bgp_convergence(): expect_loopback_route("r4", "ip", "10.254.254.2/32", "bgp") expect_loopback_route("r4", "ip", "10.254.254.3/32", "bgp") - -def test_mroute_install(): +def _test_mroute_install(): "Test that multicast routes propagated and installed" tgen = get_topogen() if tgen.routers_have_failure(): pytest.skip(tgen.errors) - tgen.gears["h1"].run("{} '{}' '{}' '{}' &".format( - HELPER_APP_PATH, APP_SOCK_PATH, '229.1.2.3', 'h1-eth0')) - accept_host("h1") - - tgen.gears["h2"].run("{} --send='0.7' '{}' '{}' '{}' &".format( - HELPER_APP_PATH, APP_SOCK_PATH, '229.1.2.3', 'h2-eth0')) - accept_host("h2") - # # Test R1 mroute # @@ -366,6 +366,40 @@ def test_mroute_install(): _, val = topotest.run_and_expect(test_func, None, count=55, wait=2) assert val is None, 'multicast route convergence failure' +def test_mroute_install(): + tgen = get_topogen() + # pytest.skip("FOO") + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + ph1 = ph2 = None + + app_sock_path = get_app_sock_path() + try: + logger.info("Starting helper1") + ph1 = tgen.gears["h1"].popen( + "{} '{}' '{}' '{}'".format( + HELPER_APP_PATH, app_sock_path, "229.1.2.3", "h1-eth0" + ) + ) + logger.info("Accepting helper1") + accept_host("h1") + + logger.info("Starting helper2") + ph2 = tgen.gears["h2"].popen( + "{} --send='0.7' '{}' '{}' '{}'".format( + HELPER_APP_PATH, app_sock_path, "229.1.2.3", "h2-eth0" + ) + ) + accept_host("h2") + + _test_mroute_install() + finally: + if ph1: + ph1.terminate() + ph1.wait() + ph2.terminate() + ph2.wait() def test_msdp(): """ diff --git a/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py b/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py index 827dde69e..60a883b28 100644 --- a/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py +++ b/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py @@ -66,7 +66,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, @@ -213,6 +213,9 @@ def teardown_module(): tgen = get_topogen() + # Kill any iperfs we left running. + kill_iperf(tgen) + # Stop toplogy and Remove tmp files tgen.stop_topology() @@ -401,15 +404,15 @@ def test_BSR_higher_prefer_ip_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) step("pre-configure BSM packet") step("Configure cisco-1 as BSR1 1.1.2.7") @@ -607,15 +610,15 @@ def test_BSR_CRP_with_blackhole_address_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) step("pre-configure BSM packet") step("Configure cisco-1 as BSR1 1.1.2.7") @@ -782,15 +785,15 @@ def test_new_router_fwd_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( @@ -919,15 +922,15 @@ def test_int_bsm_config_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( @@ -1080,15 +1083,15 @@ def test_static_rp_override_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( @@ -1231,15 +1234,15 @@ def test_bsmp_stress_add_del_restart_p2(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( @@ -1400,15 +1403,15 @@ def test_BSM_timeout_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - result = pre_config_to_bsm( tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" ) @@ -1557,15 +1560,15 @@ def test_iif_join_state_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( diff --git a/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py b/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py index 894326f19..115d0bff0 100644 --- a/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py +++ b/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py @@ -57,7 +57,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, @@ -204,6 +204,9 @@ def teardown_module(): tgen = get_topogen() + # Kill any iperfs we left running. + kill_iperf(tgen) + # Stop toplogy and Remove tmp files tgen.stop_topology() @@ -354,15 +357,15 @@ def test_starg_mroute_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( @@ -506,15 +509,15 @@ def test_overlapping_group_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( @@ -612,15 +615,15 @@ def test_RP_priority_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( @@ -861,15 +864,15 @@ def test_RP_hash_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - reset_config_on_routers(tgen) result = pre_config_to_bsm( @@ -954,6 +957,10 @@ def test_BSM_fragmentation_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) @@ -961,10 +968,6 @@ def test_BSM_fragmentation_p1(request): reset_config_on_routers(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - result = pre_config_to_bsm( tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" ) @@ -1072,14 +1075,15 @@ def test_RP_with_all_ip_octet_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) step("pre-configure BSM packet") result = pre_config_to_bsm( tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" diff --git a/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py b/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py index 36a3103c9..487ec924e 100755 --- a/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py +++ b/tests/topotests/multicast_pim_sm_topo1/test_multicast_pim_sm_topo1.py @@ -69,7 +69,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, @@ -133,8 +133,8 @@ TOPOLOGY = """ Description: i1, i2, i3. i4, i5, i6, i7, i8 - FRR running iperf to send IGMP join and traffic - l1 - LHR - f1 - FHR + l1 - LHR (last hop router) + f1 - FHR (first hop router) r2 - FRR router c1 - FRR router c2 - FRR router @@ -219,7 +219,7 @@ def setup_module(mod): pytest.skip(tgen.errors) # Creating configuration from JSON - build_config_from_json(tgen, topo) + build_config_from_json(tgen, tgen.json_topo) logger.info("Running setup_module() done") @@ -231,6 +231,9 @@ def teardown_module(): tgen = get_topogen() + # Kill any iperfs we left running. + kill_iperf(tgen) + # Stop toplogy and Remove tmp files tgen.stop_topology() @@ -276,13 +279,8 @@ def config_to_send_igmp_join_and_traffic( result = addKernelRoute(tgen, iperf, iperf_intf, GROUP_RANGE) assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result) - router_list = tgen.routers() - for router in router_list.keys(): - if router == iperf: - continue - - rnode = router_list[router] - rnode.run("echo 2 > /proc/sys/net/ipv4/conf/all/rp_filter") + rnode = tgen.gears[iperf] + rnode.run("echo 2 > /proc/sys/net/ipv4/conf/all/rp_filter") return True @@ -333,6 +331,7 @@ def test_multicast_data_traffic_static_RP_send_join_then_traffic_p0(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) @@ -342,10 +341,6 @@ def test_multicast_data_traffic_static_RP_send_join_then_traffic_p0(request): step("Enable IGMP on FRR1 interface and send IGMP join (225.1.1.1)") intf_i1_l1 = topo["routers"]["i1"]["links"]["l1"]["interface"] - result = config_to_send_igmp_join_and_traffic( - tgen, topo, tc_name, "i1", intf_i1_l1, GROUP_RANGE, join=True - ) - assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result) step("joinRx value before join sent") intf_r2_l1 = topo["routers"]["r2"]["links"]["l1"]["interface"] @@ -356,7 +351,7 @@ def test_multicast_data_traffic_static_RP_send_join_then_traffic_p0(request): ), "Testcase {} : Failed \n state_before is not dictionary \n " "Error: {}".format(tc_name, result) - result = iperfSendIGMPJoin(tgen, "i1", IGMP_JOIN, join_interval=1) + result = iperfSendIGMPJoin(tgen, "i1", ["{}%{}".format(IGMP_JOIN, intf_i1_l1)], join_interval=1) assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result) step("Send the IGMP join first and then start the traffic") @@ -382,13 +377,7 @@ def test_multicast_data_traffic_static_RP_send_join_then_traffic_p0(request): assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) step("Send multicast traffic from FRR3 to 225.1.1.1 receiver") - intf_i2_f1 = topo["routers"]["i2"]["links"]["f1"]["interface"] - result = config_to_send_igmp_join_and_traffic( - tgen, topo, tc_name, "i2", intf_i2_f1, GROUP_RANGE, traffic=True - ) - assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result) - - result = iperfSendTraffic(tgen, "i2", IGMP_JOIN, 32, 2500) + result = iperfSendTraffic(tgen, "i2", IGMP_JOIN, 32, 2500, bindToIntf="f1") assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) step( @@ -456,19 +445,20 @@ def test_multicast_data_traffic_static_RP_send_traffic_then_join_p0(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure RP on R2 (loopback interface) for the" " group range 225.0.0.0/8") input_dict = { @@ -580,19 +570,20 @@ def test_clear_pim_neighbors_and_mroute_p0(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP on c1 for group (225.1.1.1-5)") input_dict = { "c1": { @@ -673,19 +664,20 @@ def test_verify_mroute_when_same_receiver_in_FHR_LHR_and_RP_p0(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure RP on R2 (loopback interface) for the" " group range 225.0.0.0/8") input_dict = { @@ -738,7 +730,7 @@ def test_verify_mroute_when_same_receiver_in_FHR_LHR_and_RP_p0(request): step("IGMP is received on FRR1 , FRR2 , FRR3, using " "'show ip igmp groups'") igmp_groups = {"l1": "l1-i1-eth1", "r2": "r2-i3-eth1", "f1": "f1-i8-eth2"} for dut, interface in igmp_groups.items(): - result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN) + result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN, retry_timeout=80) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) step("(*,G) present on all the node with correct OIL" " using 'show ip mroute'") @@ -768,19 +760,20 @@ def test_verify_mroute_when_same_receiver_joining_5_diff_sources_p0(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for (226.1.1.1-5) and (232.1.1.1-5)" " in c1") _GROUP_RANGE = GROUP_RANGE_2 + GROUP_RANGE_3 @@ -1088,19 +1081,20 @@ def test_verify_mroute_when_frr_is_transit_router_p2(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for (226.1.1.1-5) in c2") input_dict = { "c2": { @@ -1197,19 +1191,20 @@ def test_verify_mroute_when_RP_unreachable_p1(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure RP on FRR2 (loopback interface) for " "the group range 225.0.0.0/8") input_dict = { @@ -1317,19 +1312,20 @@ def test_modify_igmp_query_timer_p0(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Enable IGMP on FRR1 interface and send IGMP join (225.1.1.1)") result = config_to_send_igmp_join_and_traffic( tgen, topo, tc_name, "i1", "i1-l1-eth0", GROUP_RANGE, join=True @@ -1455,19 +1451,20 @@ def test_modify_igmp_max_query_response_timer_p0(request): """ tgen = get_topogen() + topo = tgen.json_topo tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Enable IGMP on FRR1 interface and send IGMP join (225.1.1.1)") result = config_to_send_igmp_join_and_traffic( tgen, topo, tc_name, "i1", "i1-l1-eth0", GROUP_RANGE, join=True @@ -1477,7 +1474,7 @@ def test_modify_igmp_max_query_response_timer_p0(request): result = iperfSendIGMPJoin(tgen, "i1", IGMP_JOIN, join_interval=1) assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result) - step("Configure IGMP query response time to 10 sec on FRR1") + step("Configure IGMP query response time to 10 deci-sec on FRR1") input_dict_1 = { "l1": { "igmp": { diff --git a/tests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py b/tests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py index f30902c1b..0b6894220 100755 --- a/tests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py +++ b/tests/topotests/multicast_pim_sm_topo2/test_multicast_pim_sm_topo2.py @@ -65,7 +65,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, @@ -225,6 +225,9 @@ def teardown_module(): tgen = get_topogen() + # Kill any iperfs we left running. + kill_iperf(tgen) + # Stop toplogy and Remove tmp files tgen.stop_topology() @@ -330,16 +333,16 @@ def test_verify_mroute_and_traffic_when_pimd_restarted_p2(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for (226.1.1.1-5) in c1") step("Configure static RP for (232.1.1.1-5) in c2") @@ -542,16 +545,16 @@ def test_verify_mroute_and_traffic_when_frr_restarted_p2(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for (226.1.1.1-5) in c1") step("Configure static RP for (232.1.1.1-5) in c2") @@ -753,16 +756,16 @@ def test_verify_SPT_switchover_when_RPT_and_SPT_path_is_different_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for (226.1.1.1-5) and " "(232.1.1.1-5) in c2") _GROUP_RANGE = GROUP_RANGE_2 + GROUP_RANGE_3 @@ -915,16 +918,16 @@ def test_verify_mroute_after_shut_noshut_of_upstream_interface_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for (226.1.1.1-5) in c1") step("Configure static RP for (232.1.1.1-5) in c2") @@ -1131,21 +1134,11 @@ def test_verify_mroute_after_shut_noshut_of_upstream_interface_p1(request): intf_l1_c1 = "l1-c1-eth0" shutdown_bringup_interface(tgen, dut, intf_l1_c1, False) - done_flag = False - for retry in range(1, 11): - result = verify_upstream_iif( - tgen, "l1", "Unknown", source, IGMP_JOIN_RANGE_2, expected=False - ) - if result is not True: - done_flag = True - else: - continue - if done_flag: - logger.info("Expected Behavior: {}".format(result)) - break - - assert done_flag is True, ( + result = verify_upstream_iif( + tgen, "l1", "Unknown", source, IGMP_JOIN_RANGE_2, expected=False + ) + assert result is not True, ( "Testcase {} : Failed Error: \n " "mroutes are still present, after waiting for 10 mins".format(tc_name) ) @@ -1198,16 +1191,16 @@ def test_verify_mroute_when_receiver_is_outside_frr_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP on c1 for group range " "(226.1.1.1-5) and (232.1.1.1-5)") _GROUP_RANGE = GROUP_RANGE_2 + GROUP_RANGE_3 @@ -1338,16 +1331,16 @@ def test_verify_mroute_when_FRR_is_FHR_and_LHR_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for group range (226.1.1.1-5) and " "(232.1.1.1-5) on c1") _GROUP_RANGE = GROUP_RANGE_2 + GROUP_RANGE_3 _IGMP_JOIN_RANGE = IGMP_JOIN_RANGE_2 + IGMP_JOIN_RANGE_3 @@ -1484,31 +1477,18 @@ def test_verify_mroute_when_FRR_is_FHR_and_LHR_p0(request): {"dut": "f1", "src_address": "*", "iif": "f1-c2-eth0", "oil": "f1-i8-eth2"}, {"dut": "l1", "src_address": "*", "iif": "l1-c1-eth0", "oil": "l1-i1-eth1"}, ] - - done_flag = False - for retry in range(1, 11): - for data in input_dict: - result = verify_ip_mroutes( - tgen, - data["dut"], - data["src_address"], - _IGMP_JOIN_RANGE, - data["iif"], - data["oil"], - ) - - if result is True: - done_flag = True - else: - continue - - if done_flag: - break - - assert done_flag is True, ( - "Testcase {} : Failed Error: \n " - "mroutes are still present, after waiting for 10 mins".format(tc_name) - ) + for data in input_dict: + result = verify_ip_mroutes( + tgen, + data["dut"], + data["src_address"], + _IGMP_JOIN_RANGE, + data["iif"], + data["oil"], + ) + assert result is True, ( + "Testcase {} : Failed Error mroutes were flushed.".format(tc_name) + ) step( "After traffic stopped , verify (S,G) entries are flushed out" @@ -1520,31 +1500,19 @@ def test_verify_mroute_when_FRR_is_FHR_and_LHR_p0(request): {"dut": "f1", "src_address": source, "iif": "i2-f1-eth0", "oil": "f1-r2-eth3"}, ] - done_flag = False - for retry in range(1, 11): - for data in input_dict: - result = verify_ip_mroutes( - tgen, - data["dut"], - data["src_address"], - _IGMP_JOIN_RANGE, - data["iif"], - data["oil"], - expected=False, - ) - if result is not True: - done_flag = True - else: - continue - - if done_flag: - logger.info("Expected Behavior: {}".format(result)) - break - - assert done_flag is True, ( - "Testcase {} : Failed Error: \n " - "mroutes are still present, after waiting for 10 mins".format(tc_name) - ) + for data in input_dict: + result = verify_ip_mroutes( + tgen, + data["dut"], + data["src_address"], + _IGMP_JOIN_RANGE, + data["iif"], + data["oil"], + expected=False, + ) + assert result is not True, ( + "Testcase {} : Failed Error: \nmroutes are still present".format(tc_name) + ) write_test_footer(tc_name) @@ -1559,16 +1527,16 @@ def test_verify_mroute_when_5_different_receiver_joining_same_sources_p0(request tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for (226.1.1.1-5) in c1") step("Configure static RP for (232.1.1.1-5) in c2") @@ -1790,16 +1758,16 @@ def test_verify_oil_iif_for_mroute_after_shut_noshut_source_interface_p1(request tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure static RP for (226.1.1.1-5) in c1") step("Configure static RP for (232.1.1.1-5) in c2") diff --git a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py index 033c76081..f3688e2f5 100755 --- a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py +++ b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py @@ -68,7 +68,6 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo from lib.common_config import ( start_topology, @@ -178,7 +177,6 @@ SAME_VLAN_IP_1 = {"ip": "10.1.1.1", "subnet": "255.255.255.0", "cidr": "24"} SAME_VLAN_IP_2 = {"ip": "10.1.1.2", "subnet": "255.255.255.0", "cidr": "24"} SAME_VLAN_IP_3 = {"ip": "10.1.1.3", "subnet": "255.255.255.0", "cidr": "24"} SAME_VLAN_IP_4 = {"ip": "10.1.1.4", "subnet": "255.255.255.0", "cidr": "24"} -TCPDUMP_FILE = "{}/{}".format(LOGDIR, "v2query.txt") class CreateTopo(Topo): @@ -242,6 +240,9 @@ def teardown_module(): tgen = get_topogen() + # Kill any iperfs we left running. + kill_iperf(tgen) + # Stop toplogy and Remove tmp files tgen.stop_topology() @@ -351,31 +352,27 @@ def verify_state_incremented(state_before, state_after): * `state_after` : State dictionary for any particular instance """ - for router, state_data in state_before.items(): - for state, value in state_data.items(): - if state_before[router][state] >= state_after[router][state]: - errormsg = ( - "[DUT: %s]: state %s value has not" - " incremented, Initial value: %s, " - "Current value: %s [FAILED!!]" - % ( - router, - state, - state_before[router][state], - state_after[router][state], + for ttype, v1 in state_before.items(): + for intf, v2 in v1.items(): + for state, value in v2.items(): + if value >= state_after[ttype][intf][state]: + errormsg = ( + "[DUT: %s]: state %s value has not incremented, Initial value: %s, Current value: %s [FAILED!!]" % ( + intf, + state, + value, + state_after[ttype][intf][state], + ) ) + return errormsg + + logger.info( + "[DUT: %s]: State %s value is incremented, Initial value: %s, Current value: %s [PASSED!!]", + intf, + state, + value, + state_after[ttype][intf][state], ) - return errormsg - - logger.info( - "[DUT: %s]: State %s value is " - "incremented, Initial value: %s, Current value: %s" - " [PASSED!!]", - router, - state, - state_before[router][state], - state_after[router][state], - ) return True @@ -392,7 +389,7 @@ def find_v2_query_msg_in_tcpdump(tgen, router, message, count, cap_file): """ - filepath = os.path.join(LOGDIR, tgen.modname, router, cap_file) + filepath = os.path.join(tgen.logdir, router, cap_file) with open(filepath) as f: if len(re.findall("{}".format(message), f.read())) < count: errormsg = "[DUT: %s]: Verify Message: %s in tcpdump" " [FAILED!!]" % ( @@ -422,7 +419,7 @@ def find_tos_in_tcpdump(tgen, router, message, cap_file): """ - filepath = os.path.join(LOGDIR, tgen.modname, router, cap_file) + filepath = os.path.join(tgen.logdir, router, cap_file) with open(filepath) as f: if len(re.findall(message, f.read())) < 1: @@ -449,6 +446,10 @@ def test_verify_oil_when_join_prune_sent_scenario_1_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -456,10 +457,6 @@ def test_verify_oil_when_join_prune_sent_scenario_1_p1(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3") step( "Enable IGMP of FRR1 interface and send IGMP joins " @@ -824,6 +821,10 @@ def test_verify_oil_when_join_prune_sent_scenario_2_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -831,10 +832,6 @@ def test_verify_oil_when_join_prune_sent_scenario_2_p1(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Removing FRR3 to simulate topo " "FHR(FRR1)---LHR(FRR2)") intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"] @@ -1066,6 +1063,10 @@ def test_shut_noshut_source_interface_when_upstream_cleared_from_LHR_p1(request) tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -1073,10 +1074,6 @@ def test_shut_noshut_source_interface_when_upstream_cleared_from_LHR_p1(request) clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Enable the PIM on all the interfaces of FRR1, R2 and FRR3" " routers") step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)") @@ -1211,22 +1208,11 @@ def test_shut_noshut_source_interface_when_upstream_cleared_from_LHR_p1(request) " 'show ip pim upstream' 'show ip mroute' " ) - done_flag = False - for retry in range(1, 11): - result = verify_upstream_iif( - tgen, "l1", "Unknown", source_i2, IGMP_JOIN_RANGE_1, expected=False - ) - if result is not True: - done_flag = True - else: - continue - if done_flag: - logger.info("Expected Behavior: {}".format(result)) - break - - assert done_flag is True, ( - "Testcase {} : Failed Error: \n " - "mroutes are still present, after waiting for 10 mins".format(tc_name) + result = verify_upstream_iif( + tgen, "l1", "Unknown", source_i2, IGMP_JOIN_RANGE_1, expected=False + ) + assert result is not True, ( + "Testcase {} : Failed Error: \n mroutes are still present".format(tc_name) ) step("No shut the Source interface just after the upstream is expired" " from FRR1") @@ -1294,6 +1280,10 @@ def test_shut_noshut_receiver_interface_when_upstream_cleared_from_LHR_p1(reques tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -1301,10 +1291,6 @@ def test_shut_noshut_receiver_interface_when_upstream_cleared_from_LHR_p1(reques clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Enable the PIM on all the interfaces of FRR1, R2 and FRR3" " routers") step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)") @@ -1425,22 +1411,11 @@ def test_shut_noshut_receiver_interface_when_upstream_cleared_from_LHR_p1(reques " 'show ip pim upstream' 'show ip mroute' " ) - done_flag = False - for retry in range(1, 11): - result = verify_upstream_iif( - tgen, "l1", "Unknown", source_i2, IGMP_JOIN_RANGE_1, expected=False - ) - if result is not True: - done_flag = True - else: - continue - if done_flag: - logger.info("Expected Behavior: {}".format(result)) - break - - assert done_flag is True, ( - "Testcase {} : Failed Error: \n " - "mroutes are still present, after waiting for 10 mins".format(tc_name) + result = verify_upstream_iif( + tgen, "l1", "Unknown", source_i2, IGMP_JOIN_RANGE_1, expected=False + ) + assert result is not True, ( + "Testcase {} : Failed Error: \nmroutes are still present".format(tc_name) ) step("No shut the Source interface just after the upstream is expired" " from FRR1") @@ -1507,6 +1482,10 @@ def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -1514,10 +1493,6 @@ def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Enable PIM on all routers") step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)") @@ -1883,6 +1858,10 @@ def test_verify_remove_add_igmp_commands_when_pim_configured_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -1890,10 +1869,6 @@ def test_verify_remove_add_igmp_commands_when_pim_configured_p0(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Enable PIM on all routers") step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)") @@ -2182,6 +2157,10 @@ def test_verify_remove_add_pim_commands_when_igmp_configured_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -2189,10 +2168,6 @@ def test_verify_remove_add_pim_commands_when_igmp_configured_p1(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure 'ip pim' on receiver interface on FRR1") step("Enable PIM on all routers") step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)") @@ -2377,6 +2352,10 @@ def test_pim_dr_priority_p0(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -2384,10 +2363,6 @@ def test_pim_dr_priority_p0(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure 'ip pim' on receiver interface on FRR1") step("Enable PIM on all routers") step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)") @@ -2660,6 +2635,10 @@ def test_pim_hello_timer_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -2667,10 +2646,6 @@ def test_pim_hello_timer_p1(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure 'ip pim' on receiver interface on FRR1") step("Enable PIM on all routers") step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)") @@ -2780,6 +2755,10 @@ def test_mroute_after_removing_RP_sending_IGMP_prune_p2(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -2787,9 +2766,6 @@ def test_mroute_after_removing_RP_sending_IGMP_prune_p2(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) step( "Remove cisco connected link to simulate topo " "LHR(FRR1(f1))----RP(cisco(f1)---FHR(FRR3(l1))" @@ -3097,6 +3073,10 @@ def test_prune_sent_to_LHR_and_FHR_when_PIMnbr_down_p2(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -3104,9 +3084,6 @@ def test_prune_sent_to_LHR_and_FHR_when_PIMnbr_down_p2(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) step( "Remove cisco connected link to simulate topo " "LHR(FRR1(f1))----RP(cisco(f1)---FHR(FRR3(l1))" @@ -3738,6 +3715,10 @@ def test_mroute_flags_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -3745,9 +3726,6 @@ def test_mroute_flags_p1(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) step( "Remove cisco connected link to simulate topo " "LHR(FRR1(f1))----RP(cisco(f1)---FHR(FRR3(l1))" @@ -3900,6 +3878,10 @@ def test_verify_multicast_traffic_when_LHR_connected_to_RP_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -3907,10 +3889,6 @@ def test_verify_multicast_traffic_when_LHR_connected_to_RP_p1(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step( "Remove FRR3 to cisco connected link to simulate topo " "FHR(FRR3(l1))---LHR(FRR1(r2)----RP(FRR2(f1))" @@ -4362,6 +4340,10 @@ def test_verify_multicast_traffic_when_FHR_connected_to_RP_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) @@ -4369,10 +4351,6 @@ def test_verify_multicast_traffic_when_FHR_connected_to_RP_p1(request): clear_ip_pim_interface_traffic(tgen, topo) check_router_status(tgen) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step( "Remove FRR3 to FRR2 connected link to simulate topo " "FHR(FRR3)---LHR(FRR1)----RP(FFR2)" diff --git a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py index 1081b764a..0b9c216c6 100755 --- a/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py +++ b/tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo4.py @@ -61,7 +61,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.common_config import ( start_topology, @@ -210,6 +210,9 @@ def teardown_module(): tgen = get_topogen() + # Kill any iperfs we left running. + kill_iperf(tgen) + # Stop toplogy and Remove tmp files tgen.stop_topology() @@ -323,15 +326,16 @@ def test_mroute_when_RP_reachable_default_route_p2(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) step( "Remove c1-c2 connected link to simulate topo " "c1(FHR)---l1(RP)----r2---f1-----c2(LHR)" @@ -621,15 +625,16 @@ def test_mroute_with_RP_default_route_all_nodes_p2(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) step( "Remove c1-c2 connected link to simulate topo " "c1(LHR)---l1(RP)----r2---f1-----c2(FHR)" @@ -908,15 +913,16 @@ def test_PIM_hello_tx_rx_p1(request): tc_name = request.node.name write_test_header(tc_name) + # Don"t run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) - # Don"t run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) step( "Remove c1-c2 connected link to simulate topo " "c1(LHR)---l1(RP)----r2---f1-----c2(FHR)" diff --git a/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py b/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py index 7c2d13f39..ba8ea0be6 100755 --- a/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py +++ b/tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py @@ -114,7 +114,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen from lib.topolog import logger @@ -268,6 +268,9 @@ def teardown_module(): tgen = get_topogen() + # Kill any iperfs we left running. + kill_iperf(tgen) + # Stop toplogy and Remove tmp files tgen.stop_topology() diff --git a/tests/topotests/nhrp_topo/test_nhrp_topo.py b/tests/topotests/nhrp_topo/test_nhrp_topo.py index f59e3ae1b..081c63a18 100644 --- a/tests/topotests/nhrp_topo/test_nhrp_topo.py +++ b/tests/topotests/nhrp_topo/test_nhrp_topo.py @@ -43,7 +43,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.nhrpd] diff --git a/tests/topotests/ospf6_topo1/test_ospf6_topo1.py b/tests/topotests/ospf6_topo1/test_ospf6_topo1.py index 8a6544734..4a4ae3d5b 100644 --- a/tests/topotests/ospf6_topo1/test_ospf6_topo1.py +++ b/tests/topotests/ospf6_topo1/test_ospf6_topo1.py @@ -78,7 +78,7 @@ from time import sleep from functools import partial -from mininet.topo import Topo +from lib.micronet_compat import Topo # Save the Current Working Directory to find configuration files later. CWD = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py b/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py index 61a80cc9e..fc1a472a1 100755 --- a/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py +++ b/tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py @@ -80,7 +80,7 @@ from time import sleep from functools import partial -from mininet.topo import Topo +from lib.micronet_compat import Topo # Save the Current Working Directory to find configuration files later. CWD = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py index 8c5f1e6f6..e64000b07 100644 --- a/tests/topotests/ospf6_topo2/test_ospf6_topo2.py +++ b/tests/topotests/ospf6_topo2/test_ospf6_topo2.py @@ -42,7 +42,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ospf6d] @@ -346,7 +346,7 @@ def test_nssa_lsa_type7(): def dont_expect_route(unexpected_route): "Specialized test function to expect route go missing" output = tgen.gears["r4"].vtysh_cmd("show ipv6 ospf6 route json", isjson=True) - if output["routes"].has_key(unexpected_route): + if unexpected_route in output["routes"]: return output["routes"][unexpected_route] return None diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py index a3f1bc76f..392cca3a1 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py @@ -35,7 +35,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen import ipaddress from time import sleep diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py index db177360b..3bd4f8b59 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_type7_lsa.py @@ -35,7 +35,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen import ipaddress from time import sleep diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py b/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py index bdba8fd8e..6d1b8d9e9 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_authentication.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py b/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py index c117fc6a7..d946cca89 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_chaos.py @@ -36,7 +36,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py index 5c57f8be2..4c5510ca6 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp.py @@ -37,7 +37,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen from ipaddress import IPv4Address diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py index 96f781c15..eb1c3a914 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_ecmp_lan.py @@ -35,7 +35,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_lan.py b/tests/topotests/ospf_basic_functionality/test_ospf_lan.py index c89a66338..e7a002fb8 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_lan.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_lan.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py b/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py index 0af83548b..5cb4bd33d 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_nssa.py @@ -49,7 +49,7 @@ from lib.common_config import ( ) from ipaddress import IPv4Address from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo import os import sys import time diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py b/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py index 0172f589c..553313645 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_p2mp.py @@ -37,7 +37,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen import ipaddress @@ -57,6 +57,7 @@ from lib.common_config import ( ) from lib.topolog import logger from lib.topojson import build_topo_from_json, build_config_from_json +from lib.topotest import frr_unicode from lib.ospf import ( verify_ospf_neighbor, diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py b/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py index 066f53aa5..34abd0dc4 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py @@ -36,7 +36,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py b/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py index 0e2fef4a2..9f05f396a 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py @@ -36,7 +36,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py b/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py index 0d0668a93..2773c01ff 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_single_area.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen import ipaddress diff --git a/tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py b/tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py index b5f535cd0..f4d98fddb 100644 --- a/tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py +++ b/tests/topotests/ospf_dual_stack/test_ospf_dual_stack.py @@ -10,7 +10,7 @@ CWD = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen from lib.common_config import ( diff --git a/tests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py b/tests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py index 0507c2d51..3520cdf24 100755 --- a/tests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py +++ b/tests/topotests/ospf_gr_topo1/test_ospf_gr_topo1.py @@ -92,7 +92,7 @@ from lib.common_config import ( ) # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ospfd] diff --git a/tests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py b/tests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py index 6c1122ab7..6146178d8 100755 --- a/tests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py +++ b/tests/topotests/ospf_sr_te_topo1/test_ospf_sr_te_topo1.py @@ -93,7 +93,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd, pytest.mark.pathd] diff --git a/tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py b/tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py index 8b7e3b778..3f448d4bf 100644 --- a/tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py +++ b/tests/topotests/ospf_sr_topo1/test_ospf_sr_topo1.py @@ -82,7 +82,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ospfd] diff --git a/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py b/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py index a22fbf458..2975e5864 100644 --- a/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py +++ b/tests/topotests/ospf_suppress_fa/test_ospf_suppress_fa.py @@ -48,7 +48,7 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ospfd] diff --git a/tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py b/tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py index 32f9b3453..1678287bb 100644 --- a/tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py +++ b/tests/topotests/ospf_te_topo1/test_ospf_te_topo1.py @@ -67,7 +67,7 @@ sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo # Import topogen and topotest helpers from lib import topotest @@ -83,7 +83,7 @@ pytestmark = [pytest.mark.ospfd] class OspfTeTopo(Topo): "Test topology builder" - def build(self): + def build(self, *args, **kwargs): "Build function" tgen = get_topogen(self) diff --git a/tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py b/tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py index b3da6e2a1..956e2ab0a 100644 --- a/tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py +++ b/tests/topotests/ospf_tilfa_topo1/test_ospf_tilfa_topo1.py @@ -69,7 +69,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ospfd] diff --git a/tests/topotests/ospf_topo1/test_ospf_topo1.py b/tests/topotests/ospf_topo1/test_ospf_topo1.py index 42634ce90..50992503e 100644 --- a/tests/topotests/ospf_topo1/test_ospf_topo1.py +++ b/tests/topotests/ospf_topo1/test_ospf_topo1.py @@ -43,7 +43,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ospfd] diff --git a/tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py b/tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py index 713a65a81..711f76c5c 100644 --- a/tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py +++ b/tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py @@ -43,7 +43,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ospfd] @@ -99,20 +99,12 @@ def setup_module(mod): logger.info("Testing with VRF Namespace support") - cmds = [ - "if [ -e /var/run/netns/{0}-ospf-cust1 ] ; then ip netns del {0}-ospf-cust1 ; fi", - "ip netns add {0}-ospf-cust1", - "ip link set dev {0}-eth0 netns {0}-ospf-cust1", - "ip netns exec {0}-ospf-cust1 ip link set {0}-eth0 up", - "ip link set dev {0}-eth1 netns {0}-ospf-cust1", - "ip netns exec {0}-ospf-cust1 ip link set {0}-eth1 up", - ] - for rname, router in router_list.items(): - - # create VRF rx-ospf-cust1 and link rx-eth0 to rx-ospf-cust1 - for cmd in cmds: - output = tgen.net[rname].cmd(cmd.format(rname)) + # create VRF rx-ospf-cust1 and link rx-eth{0,1} to rx-ospf-cust1 + ns = "{}-ospf-cust1".format(rname) + router.net.add_netns(ns) + router.net.set_intf_netns(rname + "-eth0", ns, up=True) + router.net.set_intf_netns(rname + "-eth1", ns, up=True) router.load_config( TopoRouter.RD_ZEBRA, @@ -134,18 +126,12 @@ def teardown_module(mod): "Teardown the pytest environment" tgen = get_topogen() - # move back rx-eth0 to default VRF - # delete rx-vrf - cmds = [ - "ip netns exec {0}-ospf-cust1 ip link set {0}-eth0 netns 1", - "ip netns exec {0}-ospf-cust1 ip link set {0}-eth1 netns 1", - "ip netns delete {0}-ospf-cust1", - ] - + # Move interfaces out of vrf namespace and delete the namespace router_list = tgen.routers() for rname, router in router_list.items(): - for cmd in cmds: - tgen.net[rname].cmd(cmd.format(rname)) + tgen.net[rname].reset_intf_netns(rname + "-eth0") + tgen.net[rname].reset_intf_netns(rname + "-eth1") + tgen.net[rname].delete_netns(rname + "-ospf-cust1") tgen.stop_topology() diff --git a/tests/topotests/ospf_topo2/test_ospf_topo2.py b/tests/topotests/ospf_topo2/test_ospf_topo2.py index 8b8d5d6e9..38d424c90 100644 --- a/tests/topotests/ospf_topo2/test_ospf_topo2.py +++ b/tests/topotests/ospf_topo2/test_ospf_topo2.py @@ -44,7 +44,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.ospfd] @@ -95,10 +95,10 @@ def setup_module(mod): # the rp_filter. Setting it to '0' allows the OS to pass # up the mcast packet not destined for the local routers # network. - topotest.set_sysctl(tgen.net["r1"], "net.ipv4.conf.r1-eth1.rp_filter", 0) - topotest.set_sysctl(tgen.net["r1"], "net.ipv4.conf.all.rp_filter", 0) - topotest.set_sysctl(tgen.net["r2"], "net.ipv4.conf.r2-eth1.rp_filter", 0) - topotest.set_sysctl(tgen.net["r2"], "net.ipv4.conf.all.rp_filter", 0) + topotest.sysctl_assure(tgen.net["r1"], "net.ipv4.conf.r1-eth1.rp_filter", 0) + topotest.sysctl_assure(tgen.net["r1"], "net.ipv4.conf.all.rp_filter", 0) + topotest.sysctl_assure(tgen.net["r2"], "net.ipv4.conf.r2-eth1.rp_filter", 0) + topotest.sysctl_assure(tgen.net["r2"], "net.ipv4.conf.all.rp_filter", 0) # Initialize all routers. tgen.start_router() diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py index 6a4b60fbe..c76da39ca 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py @@ -38,7 +38,6 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo from lib.topogen import Topogen, get_topogen import ipaddress from time import sleep diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py index 50c5144b3..6bfe4f199 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_ecmp.py @@ -38,7 +38,6 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo from lib.topogen import Topogen, get_topogen import ipaddress diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py index d8cf3bd02..af1017c6b 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py @@ -38,7 +38,6 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo from lib.topogen import Topogen, get_topogen import ipaddress diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py index 860f17ba6..d16cbb76f 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_rte_calc.py @@ -37,7 +37,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen import ipaddress from lib.bgp import verify_bgp_convergence, create_router_bgp diff --git a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py index 0c1c51c78..22593baba 100644 --- a/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py +++ b/tests/topotests/ospfv3_basic_functionality/test_ospfv3_single_area.py @@ -38,7 +38,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen import ipaddress diff --git a/tests/topotests/pbr_topo1/test_pbr_topo1.py b/tests/topotests/pbr_topo1/test_pbr_topo1.py index 1a024063b..494e27a2a 100644 --- a/tests/topotests/pbr_topo1/test_pbr_topo1.py +++ b/tests/topotests/pbr_topo1/test_pbr_topo1.py @@ -47,7 +47,7 @@ from lib.topolog import logger from lib.common_config import shutdown_bringup_interface # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.pbrd] diff --git a/tests/topotests/pim_acl/test_pim_acl.py b/tests/topotests/pim_acl/test_pim_acl.py index 77917a023..0f172d3d9 100755 --- a/tests/topotests/pim_acl/test_pim_acl.py +++ b/tests/topotests/pim_acl/test_pim_acl.py @@ -119,7 +119,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.pim import McastTesterHelper pytestmark = [pytest.mark.pimd, pytest.mark.ospfd] diff --git a/tests/topotests/pim_basic/test_pim.py b/tests/topotests/pim_basic/test_pim.py index 4debbeb85..e921b37b6 100644 --- a/tests/topotests/pim_basic/test_pim.py +++ b/tests/topotests/pim_basic/test_pim.py @@ -41,7 +41,7 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.pimd] @@ -208,22 +208,29 @@ def test_pim_igmp_report(): r1 = tgen.gears["r1"] # Let's send a igmp report from r2->r1 - CWD = os.path.dirname(os.path.realpath(__file__)) - r2.run("{}/mcast-rx.py 229.1.1.2 r2-eth0 &".format(CWD)) - - out = r1.vtysh_cmd("show ip pim upstream json", isjson=True) - expected = { - "229.1.1.2": { - "*": { - "sourceIgmp": 1, - "joinState": "Joined", - "regState": "RegNoInfo", - "sptBit": 0, + cmd = [ os.path.join(CWD, "mcast-rx.py"), "229.1.1.2", "r2-eth0" ] + p = r2.popen(cmd) + try: + expected = { + "229.1.1.2": { + "*": { + "sourceIgmp": 1, + "joinState": "Joined", + "regState": "RegNoInfo", + "sptBit": 0, + } } } - } - - assert topotest.json_cmp(out, expected) is None, "failed to converge pim" + test_func = partial( + topotest.router_json_cmp, r1, "show ip pim upstream json", expected + ) + _, result = topotest.run_and_expect(test_func, None, count=5, wait=.5) + assertmsg = '"{}" JSON output mismatches'.format(r1.name) + assert result is None, assertmsg + finally: + if p: + p.terminate() + p.wait() def test_memory_leak(): diff --git a/tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py b/tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py index 883125cfc..2bed11c54 100644 --- a/tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py +++ b/tests/topotests/pim_basic_topo2/test_pim_basic_topo2.py @@ -43,7 +43,7 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger # Required to instantiate the topology builder class. -from mininet.topo import Topo +from lib.micronet_compat import Topo pytestmark = [pytest.mark.bfdd, pytest.mark.pimd] diff --git a/tests/topotests/rip_topo1/test_rip_topo1.py b/tests/topotests/rip_topo1/test_rip_topo1.py index 78672ac87..91b4278cd 100644 --- a/tests/topotests/rip_topo1/test_rip_topo1.py +++ b/tests/topotests/rip_topo1/test_rip_topo1.py @@ -33,17 +33,13 @@ import sys import pytest from time import sleep -from mininet.topo import Topo -from mininet.net import Mininet -from mininet.node import Node, OVSSwitch, Host -from mininet.log import setLogLevel, info -from mininet.cli import CLI -from mininet.link import Intf from functools import partial sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from lib import topotest +from lib.micronet_compat import Topo +from lib.micronet_compat import Mininet fatal_error = "" @@ -76,26 +72,26 @@ class NetworkTopo(Topo): # # On main router # First switch is for a dummy interface (for local network) - switch[1] = self.addSwitch("sw1", cls=topotest.LegacySwitch) + switch[1] = self.addSwitch("sw1") self.addLink(switch[1], router[1], intfName2="r1-eth0") # # Switches for RIP # switch 2 switch is for connection to RIP router - switch[2] = self.addSwitch("sw2", cls=topotest.LegacySwitch) + switch[2] = self.addSwitch("sw2") self.addLink(switch[2], router[1], intfName2="r1-eth1") self.addLink(switch[2], router[2], intfName2="r2-eth0") # switch 3 is between RIP routers - switch[3] = self.addSwitch("sw3", cls=topotest.LegacySwitch) + switch[3] = self.addSwitch("sw3") self.addLink(switch[3], router[2], intfName2="r2-eth1") self.addLink(switch[3], router[3], intfName2="r3-eth1") # switch 4 is stub on remote RIP router - switch[4] = self.addSwitch("sw4", cls=topotest.LegacySwitch) + switch[4] = self.addSwitch("sw4") self.addLink(switch[4], router[3], intfName2="r3-eth0") - switch[5] = self.addSwitch("sw5", cls=topotest.LegacySwitch) + switch[5] = self.addSwitch("sw5") self.addLink(switch[5], router[1], intfName2="r1-eth2") - switch[6] = self.addSwitch("sw6", cls=topotest.LegacySwitch) + switch[6] = self.addSwitch("sw6") self.addLink(switch[6], router[1], intfName2="r1-eth3") @@ -397,7 +393,6 @@ def test_shutdown_check_stderr(): if __name__ == "__main__": - setLogLevel("info") # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli # retval = pytest.main(["-s", "--tb=no"]) retval = pytest.main(["-s"]) diff --git a/tests/topotests/ripng_topo1/test_ripng_topo1.py b/tests/topotests/ripng_topo1/test_ripng_topo1.py index 4a5a59cd7..9b3f66111 100644 --- a/tests/topotests/ripng_topo1/test_ripng_topo1.py +++ b/tests/topotests/ripng_topo1/test_ripng_topo1.py @@ -34,17 +34,12 @@ import pytest import unicodedata from time import sleep -from mininet.topo import Topo -from mininet.net import Mininet -from mininet.node import Node, OVSSwitch, Host -from mininet.log import setLogLevel, info -from mininet.cli import CLI -from mininet.link import Intf - from functools import partial sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from lib import topotest +from lib.micronet_compat import Topo +from lib.micronet_compat import Mininet fatal_error = "" @@ -77,25 +72,25 @@ class NetworkTopo(Topo): # # On main router # First switch is for a dummy interface (for local network) - switch[1] = self.addSwitch("sw1", cls=topotest.LegacySwitch) + switch[1] = self.addSwitch("sw1") self.addLink(switch[1], router[1], intfName2="r1-eth0") # # Switches for RIPng # switch 2 switch is for connection to RIP router - switch[2] = self.addSwitch("sw2", cls=topotest.LegacySwitch) + switch[2] = self.addSwitch("sw2") self.addLink(switch[2], router[1], intfName2="r1-eth1") self.addLink(switch[2], router[2], intfName2="r2-eth0") # switch 3 is between RIP routers - switch[3] = self.addSwitch("sw3", cls=topotest.LegacySwitch) + switch[3] = self.addSwitch("sw3") self.addLink(switch[3], router[2], intfName2="r2-eth1") self.addLink(switch[3], router[3], intfName2="r3-eth1") # switch 4 is stub on remote RIP router - switch[4] = self.addSwitch("sw4", cls=topotest.LegacySwitch) + switch[4] = self.addSwitch("sw4") self.addLink(switch[4], router[3], intfName2="r3-eth0") - switch[5] = self.addSwitch("sw5", cls=topotest.LegacySwitch) + switch[5] = self.addSwitch("sw5") self.addLink(switch[5], router[1], intfName2="r1-eth2") - switch[6] = self.addSwitch("sw6", cls=topotest.LegacySwitch) + switch[6] = self.addSwitch("sw6") self.addLink(switch[6], router[1], intfName2="r1-eth3") @@ -443,7 +438,6 @@ def test_shutdown_check_memleak(): if __name__ == "__main__": - setLogLevel("info") # To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli # retval = pytest.main(["-s", "--tb=no"]) retval = pytest.main(["-s"]) diff --git a/tests/topotests/route_scale/test_route_scale.py b/tests/topotests/route_scale/test_route_scale.py index 469ad42d6..d48996720 100644 --- a/tests/topotests/route_scale/test_route_scale.py +++ b/tests/topotests/route_scale/test_route_scale.py @@ -45,8 +45,6 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger from lib.common_config import shutdown_bringup_interface -# Required to instantiate the topology builder class. -from mininet.topo import Topo pytestmark = [pytest.mark.sharpd] @@ -58,22 +56,17 @@ pytestmark = [pytest.mark.sharpd] ##################################################### -class NetworkTopo(Topo): - "Route Scale Topology" +def build(tgen): + "Build function" - def build(self, **_opts): - "Build function" + # Populate routers + for routern in range(1, 2): + tgen.add_router("r{}".format(routern)) - tgen = get_topogen(self) - - # Populate routers - for routern in range(1, 2): - tgen.add_router("r{}".format(routern)) - - # Populate switches - for switchn in range(1, 33): - switch = tgen.add_switch("sw{}".format(switchn)) - switch.add_link(tgen.gears["r1"]) + # Populate switches + for switchn in range(1, 33): + switch = tgen.add_switch("sw{}".format(switchn)) + switch.add_link(tgen.gears["r1"]) ##################################################### @@ -85,7 +78,7 @@ class NetworkTopo(Topo): def setup_module(module): "Setup topology" - tgen = Topogen(NetworkTopo, module.__name__) + tgen = Topogen(build, module.__name__) tgen.start_topology() router_list = tgen.routers() @@ -213,11 +206,11 @@ def test_route_install(): scale_setups.append(d) # Avoid top ecmp case for runs with < 4G memory - p = os.popen("free") - l = p.readlines()[1].split() - mem = int(l[1]) - if mem < 4000000: - logger.info("Limited memory available: {}, skipping x32 testcase".format(mem)) + output = tgen.net.cmd_raises("free") + m = re.search("Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)", output) + total_mem = int(m.group(2)) + if total_mem < 4000000: + logger.info("Limited memory available: {}, skipping x32 testcase".format(total_mem)) scale_setups = scale_setups[0:-1] # Run each step using the dicts we've built diff --git a/tests/topotests/simple_snmp_test/r1/snmpd.conf b/tests/topotests/simple_snmp_test/r1/snmpd.conf index b37911da3..740574cb8 100644 --- a/tests/topotests/simple_snmp_test/r1/snmpd.conf +++ b/tests/topotests/simple_snmp_test/r1/snmpd.conf @@ -13,3 +13,6 @@ iquerySecName frr rouser frr master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr diff --git a/tests/topotests/simple_snmp_test/test_simple_snmp.py b/tests/topotests/simple_snmp_test/test_simple_snmp.py index bdb44816b..c96bddf18 100755 --- a/tests/topotests/simple_snmp_test/test_simple_snmp.py +++ b/tests/topotests/simple_snmp_test/test_simple_snmp.py @@ -43,39 +43,10 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger from lib.snmptest import SnmpTester -# Required to instantiate the topology builder class. -from mininet.topo import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.snmp] -class TemplateTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # This function only purpose is to define allocation and relationship - # between routers, switches and hosts. - # - # - # Create routers - tgen.add_router("r1") - - # r1-eth0 - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - - # r1-eth1 - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["r1"]) - - # r1-eth2 - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["r1"]) - - def setup_module(mod): "Sets up the pytest environment" @@ -84,7 +55,12 @@ def setup_module(mod): error_msg = "SNMP not installed - skipping" pytest.skip(error_msg) # This function initiates the topology build with Topogen... - tgen = Topogen(TemplateTopo, mod.__name__) + topodef = { + "s1": "r1", + "s2": "r1", + "s3": "r1" + } + tgen = Topogen(topodef, mod.__name__) # ... and here it calls Mininet initialization functions. tgen.start_topology() @@ -142,7 +118,7 @@ def test_r1_bgp_version(): pytest.skip(tgen.errors) # tgen.mininet_cli() - r1 = tgen.net.get("r1") + r1 = tgen.gears["r1"] r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") assert r1_snmp.test_oid("bgpVersin", None) assert r1_snmp.test_oid("bgpVersion", "10") diff --git a/tests/topotests/srv6_locator/test_srv6_locator.py b/tests/topotests/srv6_locator/test_srv6_locator.py index 04b0d8db9..7b571a0a8 100755 --- a/tests/topotests/srv6_locator/test_srv6_locator.py +++ b/tests/topotests/srv6_locator/test_srv6_locator.py @@ -41,7 +41,6 @@ sys.path.append(os.path.join(CWD, '../')) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo pytestmark = [pytest.mark.bgpd, pytest.mark.sharpd] @@ -54,16 +53,11 @@ def open_json_file(filename): assert False, "Could not read file {}".format(filename) -class TemplateTopo(Topo): - def build(self, *_args, **_opts): - tgen = get_topogen(self) - tgen.add_router('r1') def setup_module(mod): - tgen = Topogen(TemplateTopo, mod.__name__) + tgen = Topogen({None: "r1"}, mod.__name__) tgen.start_topology() - router_list = tgen.routers() for rname, router in tgen.routers().items(): router.run("/bin/bash {}/{}/setup.sh".format(CWD, rname)) router.load_config(TopoRouter.RD_ZEBRA, os.path.join(CWD, '{}/zebra.conf'.format(rname))) diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py index a16c4ae29..7b9b61fd9 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py @@ -44,7 +44,7 @@ sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers from lib.topogen import Topogen, get_topogen -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topotest import version_cmp # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py index 2c44ec235..c0edfef5d 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py @@ -52,7 +52,7 @@ sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py index 8525e3655..f088fd618 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py @@ -45,7 +45,7 @@ sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen from lib.common_config import ( diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py index 626de6b42..217f8467d 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py @@ -44,7 +44,7 @@ sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen from lib.topotest import version_cmp diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py index 4e23a7242..ea888c137 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py @@ -43,7 +43,7 @@ sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen from lib.topotest import version_cmp diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py index 85b9e8b54..b58543cc9 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py @@ -52,7 +52,7 @@ sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen # Import topoJson from lib, to create topology and initial configuration diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py index c84c88ac3..8e769ea66 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py @@ -47,7 +47,7 @@ sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen from lib.topotest import version_cmp diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py index a82ee6453..eb828ea03 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py @@ -43,7 +43,7 @@ sys.path.append(os.path.join(CWD, "../")) sys.path.append(os.path.join(CWD, "../lib/")) # pylint: disable=C0413 # Import topogen and topotest helpers -from mininet.topo import Topo +from lib.micronet_compat import Topo from lib.topogen import Topogen, get_topogen from lib.common_config import ( diff --git a/tests/topotests/zebra_netlink/test_zebra_netlink.py b/tests/topotests/zebra_netlink/test_zebra_netlink.py index cf08ee963..8c258a9da 100644 --- a/tests/topotests/zebra_netlink/test_zebra_netlink.py +++ b/tests/topotests/zebra_netlink/test_zebra_netlink.py @@ -44,35 +44,12 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger from lib.common_config import shutdown_bringup_interface -# Required to instantiate the topology builder class. -from mininet.topo import Topo pytestmark = [pytest.mark.sharpd] ##################################################### ## -## Network Topology Definition -## -##################################################### - - -class ZebraTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - tgen.add_router("r1") - - # Create a empty network for router 1 - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - - -##################################################### -## ## Tests starting ## ##################################################### @@ -80,7 +57,9 @@ class ZebraTopo(Topo): def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(ZebraTopo, mod.__name__) + + topodef = { "s1": ("r1") } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/zebra_opaque/test_zebra_opaque.py b/tests/topotests/zebra_opaque/test_zebra_opaque.py index 2339b0f5b..05911a9de 100644 --- a/tests/topotests/zebra_opaque/test_zebra_opaque.py +++ b/tests/topotests/zebra_opaque/test_zebra_opaque.py @@ -36,25 +36,15 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger -from mininet.topo import Topo pytestmark = [pytest.mark.bgpd] -class TemplateTopo(Topo): - def build(self, *_args, **_opts): - tgen = get_topogen(self) - - for routern in range(1, 3): - tgen.add_router("r{}".format(routern)) - - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) - - def setup_module(mod): - tgen = Topogen(TemplateTopo, mod.__name__) + topodef = { + "s1": ("r1", "r2") + } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/zebra_rib/test_zebra_rib.py b/tests/topotests/zebra_rib/test_zebra_rib.py index 778a710ee..cc12189fd 100644 --- a/tests/topotests/zebra_rib/test_zebra_rib.py +++ b/tests/topotests/zebra_rib/test_zebra_rib.py @@ -43,36 +43,17 @@ from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger from time import sleep -# Required to instantiate the topology builder class. -from mininet.topo import Topo pytestmark = [pytest.mark.sharpd] -class ZebraTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - tgen.add_router("r1") - - # Create a empty network for router 1 - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r1"]) - def setup_module(mod): "Sets up the pytest environment" - tgen = Topogen(ZebraTopo, mod.__name__) + topodef = { + "s1": ("r1", "r1", "r1", "r1", "r1", "r1", "r1", "r1") + } + tgen = Topogen(topodef, mod.__name__) tgen.start_topology() router_list = tgen.routers() diff --git a/tests/topotests/zebra_seg6_route/test_zebra_seg6_route.py b/tests/topotests/zebra_seg6_route/test_zebra_seg6_route.py index a83c6d6ec..6ac6569fa 100755 --- a/tests/topotests/zebra_seg6_route/test_zebra_seg6_route.py +++ b/tests/topotests/zebra_seg6_route/test_zebra_seg6_route.py @@ -41,7 +41,6 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger from lib.common_config import shutdown_bringup_interface -from mininet.topo import Topo pytestmark = [pytest.mark.sharpd] @@ -54,14 +53,8 @@ def open_json_file(filename): assert False, "Could not read file {}".format(filename) -class TemplateTopo(Topo): - def build(self, **_opts): - tgen = get_topogen(self) - tgen.add_router("r1") - - def setup_module(mod): - tgen = Topogen(TemplateTopo, mod.__name__) + tgen = Topogen({None: "r1"}, mod.__name__) tgen.start_topology() router_list = tgen.routers() for rname, router in tgen.routers().items(): diff --git a/tests/topotests/zebra_seg6local_route/test_zebra_seg6local_route.py b/tests/topotests/zebra_seg6local_route/test_zebra_seg6local_route.py index 6cdb77b94..3311fbe0b 100755 --- a/tests/topotests/zebra_seg6local_route/test_zebra_seg6local_route.py +++ b/tests/topotests/zebra_seg6local_route/test_zebra_seg6local_route.py @@ -41,7 +41,6 @@ from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topolog import logger from lib.common_config import shutdown_bringup_interface -from mininet.topo import Topo pytestmark = [pytest.mark.sharpd] @@ -54,14 +53,8 @@ def open_json_file(filename): assert False, "Could not read file {}".format(filename) -class TemplateTopo(Topo): - def build(self, **_opts): - tgen = get_topogen(self) - tgen.add_router("r1") - - def setup_module(mod): - tgen = Topogen(TemplateTopo, mod.__name__) + tgen = Topogen({None: "r1"}, mod.__name__) tgen.start_topology() router_list = tgen.routers() for rname, router in tgen.routers().items(): |