tests: remove legacy Topo class (fixes many pylint errors)

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2021-07-29 09:38:55 +00:00
parent d7d21c3a19
commit e82b531df9
174 changed files with 2392 additions and 4245 deletions

View File

@ -34,8 +34,6 @@ import pytest
import glob import glob
from time import sleep from time import sleep
from lib.micronet_compat import Mininet, Topo
from functools import partial from functools import partial
pytestmark = [ pytestmark = [
@ -50,6 +48,7 @@ pytestmark = [
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest from lib import topotest
from lib.topogen import Topogen, get_topogen
fatal_error = "" fatal_error = ""
@ -61,24 +60,10 @@ fatal_error = ""
##################################################### #####################################################
class NetworkTopo(Topo): def build_topo(tgen):
"All Protocol Startup Test" router = tgen.add_router("r1")
def build(self, **_opts):
# Setup Routers
router = {}
#
# Setup Main Router
router[1] = topotest.addRouter(self, "r1")
#
# Setup Switches
switch = {}
#
for i in range(0, 10): for i in range(0, 10):
switch[i] = self.addSwitch("sw%s" % i) tgen.add_switch("sw%d" % i).add_link(router)
self.addLink(switch[i], router[1], intfName2="r1-eth%s" % i)
##################################################### #####################################################
@ -89,21 +74,16 @@ class NetworkTopo(Topo):
def setup_module(module): def setup_module(module):
global topo, net
global fatal_error global fatal_error
print("\n\n** %s: Setup Topology" % module.__name__) print("\n\n** %s: Setup Topology" % module.__name__)
print("******************************************\n") print("******************************************\n")
print("Cleanup old Mininet runs")
os.system("sudo mn -c > /dev/null 2>&1")
os.system("sudo rm /tmp/r* > /dev/null 2>&1")
thisDir = os.path.dirname(os.path.realpath(__file__)) thisDir = os.path.dirname(os.path.realpath(__file__))
topo = NetworkTopo() tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
net = Mininet(controller=None, topo=topo) net = tgen.net
net.start()
if net["r1"].get_routertype() != "frr": if net["r1"].get_routertype() != "frr":
fatal_error = "Test is only implemented for FRR" fatal_error = "Test is only implemented for FRR"
@ -133,25 +113,22 @@ def setup_module(module):
net["r%s" % i].loadConf("nhrpd", "%s/r%s/nhrpd.conf" % (thisDir, i)) net["r%s" % i].loadConf("nhrpd", "%s/r%s/nhrpd.conf" % (thisDir, i))
net["r%s" % i].loadConf("babeld", "%s/r%s/babeld.conf" % (thisDir, i)) net["r%s" % i].loadConf("babeld", "%s/r%s/babeld.conf" % (thisDir, i))
net["r%s" % i].loadConf("pbrd", "%s/r%s/pbrd.conf" % (thisDir, i)) net["r%s" % i].loadConf("pbrd", "%s/r%s/pbrd.conf" % (thisDir, i))
net["r%s" % i].startRouter() tgen.gears["r%s" % i].start()
# For debugging after starting FRR daemons, uncomment the next line # For debugging after starting FRR daemons, uncomment the next line
# CLI(net) # CLI(net)
def teardown_module(module): def teardown_module(module):
global net
print("\n\n** %s: Shutdown Topology" % module.__name__) print("\n\n** %s: Shutdown Topology" % module.__name__)
print("******************************************\n") print("******************************************\n")
tgen = get_topogen()
# End - Shutdown network tgen.stop_topology()
net.stop()
def test_router_running(): def test_router_running():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -172,7 +149,7 @@ def test_router_running():
def test_error_messages_vtysh(): def test_error_messages_vtysh():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -228,7 +205,7 @@ def test_error_messages_vtysh():
def test_error_messages_daemons(): def test_error_messages_daemons():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -319,7 +296,7 @@ def test_error_messages_daemons():
def test_converge_protocols(): def test_converge_protocols():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -408,6 +385,7 @@ def test_converge_protocols():
def route_get_nhg_id(route_str): def route_get_nhg_id(route_str):
net = get_topogen().net
output = net["r1"].cmd('vtysh -c "show ip route %s nexthop-group"' % route_str) output = net["r1"].cmd('vtysh -c "show ip route %s nexthop-group"' % route_str)
match = re.search(r"Nexthop Group ID: (\d+)", output) match = re.search(r"Nexthop Group ID: (\d+)", output)
assert match is not None, ( assert match is not None, (
@ -419,6 +397,7 @@ def route_get_nhg_id(route_str):
def verify_nexthop_group(nhg_id, recursive=False, ecmp=0): def verify_nexthop_group(nhg_id, recursive=False, ecmp=0):
net = get_topogen().net
# Verify NHG is valid/installed # Verify NHG is valid/installed
output = net["r1"].cmd('vtysh -c "show nexthop-group rib %d"' % nhg_id) output = net["r1"].cmd('vtysh -c "show nexthop-group rib %d"' % nhg_id)
@ -457,7 +436,7 @@ def verify_route_nexthop_group(route_str, recursive=False, ecmp=0):
def test_nexthop_groups(): def test_nexthop_groups():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -606,7 +585,7 @@ def test_nexthop_groups():
def test_rip_status(): def test_rip_status():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -666,7 +645,7 @@ def test_rip_status():
def test_ripng_status(): def test_ripng_status():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -733,7 +712,7 @@ def test_ripng_status():
def test_ospfv2_interfaces(): def test_ospfv2_interfaces():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -818,7 +797,7 @@ def test_ospfv2_interfaces():
def test_isis_interfaces(): def test_isis_interfaces():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -884,7 +863,7 @@ def test_isis_interfaces():
def test_bgp_summary(): def test_bgp_summary():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -1045,7 +1024,7 @@ def test_bgp_summary():
def test_bgp_ipv6_summary(): def test_bgp_ipv6_summary():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -1140,6 +1119,7 @@ def test_bgp_ipv6_summary():
def test_nht(): def test_nht():
net = get_topogen().net
print("\n\n**** Test that nexthop tracking is at least nominally working ****\n") print("\n\n**** Test that nexthop tracking is at least nominally working ****\n")
thisDir = os.path.dirname(os.path.realpath(__file__)) thisDir = os.path.dirname(os.path.realpath(__file__))
@ -1188,7 +1168,7 @@ def test_nht():
def test_bgp_ipv4(): def test_bgp_ipv4():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -1258,7 +1238,7 @@ def test_bgp_ipv4():
def test_bgp_ipv6(): def test_bgp_ipv6():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -1327,7 +1307,7 @@ def test_bgp_ipv6():
def test_route_map(): def test_route_map():
global fatal_error global fatal_error
global net net = get_topogen().net
if fatal_error != "": if fatal_error != "":
pytest.skip(fatal_error) pytest.skip(fatal_error)
@ -1370,7 +1350,7 @@ def test_route_map():
def test_nexthop_groups_with_route_maps(): def test_nexthop_groups_with_route_maps():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -1467,7 +1447,7 @@ def test_nexthop_groups_with_route_maps():
def test_nexthop_group_replace(): def test_nexthop_group_replace():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -1500,7 +1480,7 @@ def test_nexthop_group_replace():
def test_mpls_interfaces(): def test_mpls_interfaces():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -1569,7 +1549,7 @@ def test_mpls_interfaces():
def test_shutdown_check_stderr(): def test_shutdown_check_stderr():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":
@ -1632,7 +1612,7 @@ def test_shutdown_check_stderr():
def test_shutdown_check_memleak(): def test_shutdown_check_memleak():
global fatal_error global fatal_error
global net net = get_topogen().net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if fatal_error != "":

View File

@ -46,28 +46,6 @@ from lib.topolog import logger
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.ospfd] pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.ospfd]
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): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
topodef = { topodef = {
@ -76,7 +54,6 @@ def setup_module(mod):
"s3": ("r2", "r4"), "s3": ("r2", "r4"),
} }
tgen = Topogen(topodef, mod.__name__) tgen = Topogen(topodef, mod.__name__)
# tgen = Topogen(build, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -49,13 +49,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd] pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd]
class BFDTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# Create 4 routers # Create 4 routers
for routern in range(1, 5): for routern in range(1, 5):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -75,7 +69,7 @@ class BFDTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
tgen = Topogen(BFDTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -50,10 +50,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -63,7 +60,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -53,10 +53,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -66,7 +63,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -45,10 +45,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class BgpAggregateAddressTopo1(Topo):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
def build_topo(tgen):
r1 = tgen.add_router("r1") r1 = tgen.add_router("r1")
r2 = tgen.add_router("r2") r2 = tgen.add_router("r2")
peer1 = tgen.add_exabgp_peer( peer1 = tgen.add_exabgp_peer(
@ -65,7 +63,7 @@ class BgpAggregateAddressTopo1(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(BgpAggregateAddressTopo1, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router = tgen.gears["r1"] router = tgen.gears["r1"]

View File

@ -43,10 +43,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class BgpAggregatorAsnZero(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
r1 = tgen.add_router("r1") r1 = tgen.add_router("r1")
peer1 = tgen.add_exabgp_peer( peer1 = tgen.add_exabgp_peer(
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1" "peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
@ -58,7 +55,7 @@ class BgpAggregatorAsnZero(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(BgpAggregatorAsnZero, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router = tgen.gears["r1"] router = tgen.gears["r1"]

View File

@ -94,16 +94,8 @@ NETWORK = {"ipv4": "2.2.2.2/32", "ipv6": "22:22::2/128"}
NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"} NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
class BGPALLOWASIN(Topo): def build_topo(tgen):
"""
Test BGPALLOWASIN - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function""" """Build function"""
tgen = get_topogen(self)
# Building topology from json file # Building topology from json file
build_topo_from_json(tgen, topo) build_topo_from_json(tgen, topo)
@ -128,7 +120,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(BGPALLOWASIN, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -48,10 +48,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 4): for routern in range(1, 4):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -62,7 +59,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -43,10 +43,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class BgpAggregatorAsnZero(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
r1 = tgen.add_router("r1") r1 = tgen.add_router("r1")
peer1 = tgen.add_exabgp_peer( peer1 = tgen.add_exabgp_peer(
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1" "peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
@ -58,7 +55,7 @@ class BgpAggregatorAsnZero(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(BgpAggregatorAsnZero, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router = tgen.gears["r1"] router = tgen.gears["r1"]

View File

@ -74,21 +74,9 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
class InvalidCLIError(Exception): class InvalidCLIError(Exception):
"""Raise when the CLI command is wrong""" """Raise when the CLI command is wrong"""
pass pass
def build_topo(tgen):
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 # Create routers
tgen.add_router("R1") tgen.add_router("R1")
tgen.add_router("R2") tgen.add_router("R2")
@ -143,7 +131,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
tgen.start_topology() tgen.start_topology()

View File

@ -79,13 +79,6 @@ from lib.topolog import logger
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_basic_functionality.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global Variable # Global Variable
KEEPALIVETIMER = 2 KEEPALIVETIMER = 2
@ -104,21 +97,6 @@ NETWORK = {
} }
class CreateTopo(Topo):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -138,7 +116,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_basic_functionality.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -43,10 +43,7 @@ from lib.common_config import step
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 5): for routern in range(1, 5):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -64,7 +61,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -48,10 +48,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -61,7 +58,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -69,14 +69,6 @@ from copy import deepcopy
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_communities.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types() ADDR_TYPES = check_address_types()
@ -84,21 +76,6 @@ NETWORK = {"ipv4": "2.2.2.2/32", "ipv6": "22:22::2/128"}
NEXT_HOP_IP = {} NEXT_HOP_IP = {}
class BGPCOMMUNITIES(Topo):
"""
Test BGPCOMMUNITIES - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -118,7 +95,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(BGPCOMMUNITIES, mod.__name__) json_file = "{}/bgp_communities.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -73,14 +73,6 @@ from copy import deepcopy
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_communities_topo2.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types() ADDR_TYPES = check_address_types()
@ -90,21 +82,6 @@ NETWORK = {
} }
class BGPCOMMUNITIES(Topo):
"""
Test BGPCOMMUNITIES - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -124,7 +101,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(BGPCOMMUNITIES, mod.__name__) json_file = "{}/bgp_communities_topo2.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -43,10 +43,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
def build_topo(tgen):
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -56,7 +54,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -62,10 +62,7 @@ from time import sleep
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
tgen.add_router("z1") tgen.add_router("z1")
tgen.add_router("y1") tgen.add_router("y1")
tgen.add_router("y2") tgen.add_router("y2")
@ -110,7 +107,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -142,10 +142,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class BgpConditionalAdvertisementTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
r1 = tgen.add_router("r1") r1 = tgen.add_router("r1")
r2 = tgen.add_router("r2") r2 = tgen.add_router("r2")
r3 = tgen.add_router("r3") r3 = tgen.add_router("r3")
@ -166,7 +163,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
tgen = Topogen(BgpConditionalAdvertisementTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -50,10 +50,8 @@ from lib.common_config import step
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
def build_topo(tgen):
for routern in range(1, 5): for routern in range(1, 5):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -65,7 +63,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -41,10 +41,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -54,7 +51,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -41,10 +41,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -54,7 +51,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -44,10 +44,7 @@ from lib.common_config import step
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -57,7 +54,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -43,10 +43,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -56,7 +53,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -41,10 +41,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -54,7 +51,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -1,7 +1,9 @@
! !
router bgp 65001 router bgp 65001
timers 3 10
no bgp ebgp-requires-policy no bgp ebgp-requires-policy
neighbor 192.168.1.2 remote-as external neighbor 192.168.1.2 remote-as external
neighbor 192.168.1.2 timers connect 5
address-family ipv4 unicast address-family ipv4 unicast
neighbor 192.168.1.2 disable-addpath-rx neighbor 192.168.1.2 disable-addpath-rx
exit-address-family exit-address-family

View File

@ -1,8 +1,12 @@
router bgp 65002 router bgp 65002
timers 3 10
no bgp ebgp-requires-policy no bgp ebgp-requires-policy
neighbor 192.168.1.1 remote-as external neighbor 192.168.1.1 remote-as external
neighbor 192.168.1.1 timers connect 5
neighbor 192.168.2.3 remote-as external neighbor 192.168.2.3 remote-as external
neighbor 192.168.2.3 timers connect 5
neighbor 192.168.2.4 remote-as external neighbor 192.168.2.4 remote-as external
neighbor 192.168.2.4 timers connect 5
address-family ipv4 unicast address-family ipv4 unicast
neighbor 192.168.1.1 addpath-tx-all-paths neighbor 192.168.1.1 addpath-tx-all-paths
exit-address-family exit-address-family

View File

@ -1,6 +1,8 @@
router bgp 65003 router bgp 65003
timers 3 10
no bgp ebgp-requires-policy no bgp ebgp-requires-policy
neighbor 192.168.2.2 remote-as external neighbor 192.168.2.2 remote-as external
neighbor 192.168.2.2 timers connect 5
address-family ipv4 unicast address-family ipv4 unicast
redistribute connected redistribute connected
exit-address-family exit-address-family

View File

@ -1,6 +1,8 @@
router bgp 65004 router bgp 65004
timers 3 10
no bgp ebgp-requires-policy no bgp ebgp-requires-policy
neighbor 192.168.2.2 remote-as external neighbor 192.168.2.2 remote-as external
neighbor 192.168.2.2 timers connect 5
address-family ipv4 unicast address-family ipv4 unicast
redistribute connected redistribute connected
exit-address-family exit-address-family

View File

@ -25,7 +25,6 @@ Test if AddPath RX direction is not negotiated via AddPath capability.
import os import os
import sys import sys
import json import json
import time
import pytest import pytest
import functools import functools
@ -35,17 +34,12 @@ sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413 # pylint: disable=C0413
from lib import topotest from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
from mininet.topo import Topo
from lib.common_config import step from lib.common_config import step
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 5): for routern in range(1, 5):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -60,7 +54,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -52,10 +52,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -65,7 +62,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -54,10 +54,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
def build_topo(tgen):
for routern in range(1, 4): for routern in range(1, 4):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -68,7 +66,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -60,10 +60,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
def build_topo(tgen):
for routern in range(1, 7): for routern in range(1, 7):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -84,7 +82,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -58,23 +58,17 @@ total_ebgp_peers = 20
##################################################### #####################################################
class BGPECMPTopo1(Topo): def build_topo(tgen):
"BGP ECMP Topology 1"
def build(self, **_opts):
tgen = get_topogen(self)
# Create the BGP router
router = tgen.add_router("r1") router = tgen.add_router("r1")
# Setup Switches - 1 switch per 5 peering routers # Setup Switches - 1 switch per 5 peering routers
for swNum in range(1, (total_ebgp_peers + 4) / 5 + 1): for swNum in range(1, (total_ebgp_peers + 4) // 5 + 1):
switch = tgen.add_switch("s{}".format(swNum)) switch = tgen.add_switch("s{}".format(swNum))
switch.add_link(router) switch.add_link(router)
# Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors # Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
for peerNum in range(1, total_ebgp_peers + 1): for peerNum in range(1, total_ebgp_peers + 1):
swNum = (peerNum - 1) / 5 + 1 swNum = (peerNum - 1) // 5 + 1
peer_ip = "10.0.{}.{}".format(swNum, peerNum + 100) peer_ip = "10.0.{}.{}".format(swNum, peerNum + 100)
peer_route = "via 10.0.{}.1".format(swNum) peer_route = "via 10.0.{}.1".format(swNum)
@ -94,7 +88,7 @@ class BGPECMPTopo1(Topo):
def setup_module(module): def setup_module(module):
tgen = Topogen(BGPECMPTopo1, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
# Starting Routers # Starting Routers

View File

@ -71,14 +71,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/ebgp_ecmp_topo2.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NEXT_HOPS = {"ipv4": [], "ipv6": []} NEXT_HOPS = {"ipv4": [], "ipv6": []}
@ -89,21 +81,6 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
class CreateTopo(Topo):
"""
Test topology builder.
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment. Sets up the pytest environment.
@ -125,7 +102,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/ebgp_ecmp_topo2.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers # to start deamons and then start routers

View File

@ -71,14 +71,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/ibgp_ecmp_topo2.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NEXT_HOPS = {"ipv4": [], "ipv6": []} NEXT_HOPS = {"ipv4": [], "ipv6": []}
@ -89,21 +81,6 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
class CreateTopo(Topo):
"""
Test topology builder.
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment. Sets up the pytest environment.
@ -125,7 +102,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/ibgp_ecmp_topo2.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers # to start deamons and then start routers

View File

@ -40,7 +40,7 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413 # pylint: disable=C0413
# Import topogen and topotest helpers # Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen from lib.topogen import Topogen, get_topogen
from mininet.topo import Topo from lib import topojson
from lib.common_config import ( from lib.common_config import (
start_topology, start_topology,
@ -63,15 +63,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/ibgp_ecmp_topo3.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NEXT_HOPS = {"ipv4": [], "ipv6": []} NEXT_HOPS = {"ipv4": [], "ipv6": []}
NETWORK = {"ipv4": "192.168.1.10/32", "ipv6": "fd00:0:0:1::10/128"} NETWORK = {"ipv4": "192.168.1.10/32", "ipv6": "fd00:0:0:1::10/128"}
@ -79,45 +70,20 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
class CreateTopo(Topo):
"""
Test topology builder.
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment. Sets up the pytest environment.
* `mod`: module name * `mod`: module name
""" """
global NEXT_HOPS, INTF_LIST_R3, INTF_LIST_R2, TEST_STATIC
global ADDR_TYPES global ADDR_TYPES
testsuite_run_time = time.asctime(time.localtime(time.time())) testsuite_run_time = time.asctime(time.localtime(time.time()))
logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("Testsuite start time: {}".format(testsuite_run_time))
logger.info("=" * 40) logger.info("=" * 40)
logger.info("Running setup_module to create topology") tgen = topojson.setup_module_from_json(mod.__file__)
topo = tgen.json_topo
# This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__)
# Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers
start_topology(tgen)
# Creating configuration from JSON
build_config_from_json(tgen, topo)
# Don't run this test if we have any failure. # Don't run this test if we have any failure.
if tgen.routers_have_failure(): if tgen.routers_have_failure():
@ -136,18 +102,7 @@ def setup_module(mod):
def teardown_module(): def teardown_module():
""" get_topogen().stop_topology()
Teardown the pytest environment.
* `mod`: module name
"""
logger.info("Running teardown_module to delete topology")
tgen = get_topogen()
# Stop toplogy and Remove tmp files
tgen.stop_topology()
def static_or_nw(tgen, topo, tc_name, test_type, dut): def static_or_nw(tgen, topo, tc_name, test_type, dut):
@ -221,12 +176,11 @@ def static_or_nw(tgen, topo, tc_name, test_type, dut):
@pytest.mark.parametrize("test_type", ["redist_static"]) @pytest.mark.parametrize("test_type", ["redist_static"])
def test_ecmp_fast_convergence(request, test_type): def test_ecmp_fast_convergence(request, test_type, tgen, topo):
"""This test is to verify bgp fast-convergence cli functionality""" """This test is to verify bgp fast-convergence cli functionality"""
tc_name = request.node.name tc_name = request.node.name
write_test_header(tc_name) write_test_header(tc_name)
tgen = get_topogen()
# Verifying RIB routes # Verifying RIB routes
dut = "r3" dut = "r3"

View File

@ -62,7 +62,7 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.pimd]
##################################################### #####################################################
class NetworkTopo(Topo): def build_topo(tgen):
""" """
EVPN Multihoming Topology - EVPN Multihoming Topology -
1. Two level CLOS 1. Two level CLOS
@ -71,11 +71,6 @@ class NetworkTopo(Topo):
4. Two dual attached hosts per-rack - hostdx1, hostdx2 4. Two dual attached hosts per-rack - hostdx1, hostdx2
""" """
def build(self, **_opts):
"Build function"
tgen = get_topogen(self)
tgen.add_router("spine1") tgen.add_router("spine1")
tgen.add_router("spine2") tgen.add_router("spine2")
tgen.add_router("torm11") tgen.add_router("torm11")
@ -371,7 +366,7 @@ def config_hosts(tgen, hosts):
def setup_module(module): def setup_module(module):
"Setup topology" "Setup topology"
tgen = Topogen(NetworkTopo, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
krel = platform.release() krel = platform.release()

View File

@ -88,13 +88,7 @@ HOST_SUFFIX = {'host1': '1', 'host2': '2'}
TRIGGERS = ["base", "no_rt5", "no_rt2"] TRIGGERS = ["base", "no_rt5", "no_rt2"]
class TemplateTopo(Topo): def build_topo(tgen):
"""Test topology builder"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# This function only purpose is to define allocation and relationship # This function only purpose is to define allocation and relationship
# between routers and add links. # between routers and add links.
@ -123,7 +117,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
kernelv = platform.release() kernelv = platform.release()

View File

@ -48,12 +48,9 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class BGPEVPNTopo(Topo):
"Test topology builder"
def build(self, *_args, **_opts): def build_topo(tgen):
"Build function" "Build function"
tgen = get_topogen(self)
tgen.add_router("r1") tgen.add_router("r1")
tgen.add_router("r2") tgen.add_router("r2")
@ -72,7 +69,7 @@ class BGPEVPNTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
tgen = Topogen(BGPEVPNTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -49,12 +49,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd] pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
class TemplateTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# This function only purpose is to define allocation and relationship # This function only purpose is to define allocation and relationship
# between routers, switches and hosts. # between routers, switches and hosts.
@ -91,7 +87,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
tgen.start_topology() tgen.start_topology()

View File

@ -56,16 +56,18 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
##################################################### #####################################################
class BGPFeaturesTopo1(Topo): def build_topo(tgen):
"BGP Features Topology 1"
def build(self, **_opts):
tgen = get_topogen(self)
# Create the routers
for rtrNum in range(1, 6): for rtrNum in range(1, 6):
tgen.add_router("r{}".format(rtrNum)) tgen.add_router("r{}".format(rtrNum))
# create ExaBGP peers
for peer_num in range(1, 5):
tgen.add_exabgp_peer(
"peer{}".format(peer_num),
ip="192.168.101.{}".format(peer_num + 2),
defaultRoute="via 192.168.101.1",
)
# Setup Switches and connections # Setup Switches and connections
for swNum in range(1, 11): for swNum in range(1, 11):
tgen.add_switch("sw{}".format(swNum)) tgen.add_switch("sw{}".format(swNum))
@ -91,6 +93,12 @@ class BGPFeaturesTopo1(Topo):
tgen.gears["r2"].add_link(tgen.gears["sw5"]) tgen.gears["r2"].add_link(tgen.gears["sw5"])
tgen.gears["r5"].add_link(tgen.gears["sw5"]) tgen.gears["r5"].add_link(tgen.gears["sw5"])
# Add ExaBGP peers to sw4
tgen.gears["peer1"].add_link(tgen.gears["sw4"])
tgen.gears["peer2"].add_link(tgen.gears["sw4"])
tgen.gears["peer3"].add_link(tgen.gears["sw4"])
tgen.gears["peer4"].add_link(tgen.gears["sw4"])
##################################################### #####################################################
# #
@ -100,7 +108,7 @@ class BGPFeaturesTopo1(Topo):
def setup_module(module): def setup_module(module):
tgen = Topogen(BGPFeaturesTopo1, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
# Starting Routers # Starting Routers

View File

@ -82,13 +82,7 @@ pytestmark = [pytest.mark.bgpd]
##################################################### #####################################################
class BGPFLOWSPECTopo1(Topo): def build_topo(tgen):
"BGP EBGP Flowspec Topology 1"
def build(self, **_opts):
tgen = get_topogen(self)
# Setup Routers
tgen.add_router("r1") tgen.add_router("r1")
# Setup Control Path Switch 1. r1-eth0 # Setup Control Path Switch 1. r1-eth0
@ -110,7 +104,7 @@ class BGPFLOWSPECTopo1(Topo):
def setup_module(module): def setup_module(module):
tgen = Topogen(BGPFLOWSPECTopo1, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
# check for zebra capability # check for zebra capability

View File

@ -142,15 +142,6 @@ from lib.common_config import (
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/bgp_gr_topojson_topo1.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
logger.info("Could not read file:", jsonFile)
# Global variables # Global variables
NEXT_HOP_IP = {"ipv4": "192.168.1.10", "ipv6": "fd00:0:0:1::10"} NEXT_HOP_IP = {"ipv4": "192.168.1.10", "ipv6": "fd00:0:0:1::10"}
NEXT_HOP_IP_1 = {"ipv4": "192.168.0.1", "ipv6": "fd00::1"} NEXT_HOP_IP_1 = {"ipv4": "192.168.0.1", "ipv6": "fd00::1"}
@ -160,28 +151,6 @@ GR_RESTART_TIMER = 20
PREFERRED_NEXT_HOP = "link_local" PREFERRED_NEXT_HOP = "link_local"
class GenerateTopo(Topo):
"""
Test topology builder
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# This function only purpose is to create topology
# as defined in input json file.
#
# Create topology (setup module)
# Creating 2 routers topology, r1, r2in IBGP
# Bring up topology
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -203,7 +172,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(GenerateTopo, mod.__name__) json_file = "{}/bgp_gr_topojson_topo1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -141,14 +141,6 @@ from lib.common_config import (
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/bgp_gr_topojson_topo2.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
logger.info("Could not read file:", jsonFile)
# Global variables # Global variables
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
GR_RESTART_TIMER = 5 GR_RESTART_TIMER = 5
@ -159,28 +151,6 @@ NEXT_HOP_4 = ["192.168.1.1", "192.168.4.2"]
NEXT_HOP_6 = ["fd00:0:0:1::1", "fd00:0:0:4::2"] NEXT_HOP_6 = ["fd00:0:0:1::1", "fd00:0:0:4::2"]
class GenerateTopo(Topo):
"""
Test topology builder
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# This function only purpose is to create topology
# as defined in input json file.
#
# Create topology (setup module)
# Creating 2 routers topology, r1, r2in IBGP
# Bring up topology
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -202,7 +172,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(GenerateTopo, mod.__name__) json_file = "{}/bgp_gr_topojson_topo2.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -78,10 +78,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 6): for routern in range(1, 6):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -110,7 +107,7 @@ def _run_cmd_and_check(router, cmd, results_file, retries=100, intvl=0.5):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -75,17 +75,10 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/ebgp_gshut_topo1.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
logger.info("Could not read file:", jsonFile)
# Global variables # Global variables
NETWORK = {"ipv4": "100.0.10.1/32", "ipv6": "1::1/128"} NETWORK = {"ipv4": "100.0.10.1/32", "ipv6": "1::1/128"}
NEXT_HOP_IP_1 = {"ipv4": "10.0.2.1", "ipv6": "fd00:0:0:1::1"} NEXT_HOP_IP_1 = {"ipv4": "10.0.2.1", "ipv6": "fd00:0:0:1::1"}
@ -94,28 +87,6 @@ PREFERRED_NEXT_HOP = "link_local"
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
class GenerateTopo(Topo):
"""
Test topology builder
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# This function only purpose is to create topology
# as defined in input json file.
#
# Create topology (setup module)
# Creating 2 routers topology, r1, r2in IBGP
# Bring up topology
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -137,7 +108,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(GenerateTopo, mod.__name__) json_file = "{}/ebgp_gshut_topo1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -78,14 +78,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/ibgp_gshut_topo1.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
logger.info("Could not read file:", jsonFile)
# Global variables # Global variables
NETWORK = {"ipv4": "100.0.10.1/32", "ipv6": "1::1/128"} NETWORK = {"ipv4": "100.0.10.1/32", "ipv6": "1::1/128"}
NEXT_HOP_IP_1 = {"ipv4": "10.0.3.1", "ipv6": "fd00:0:0:3::1"} NEXT_HOP_IP_1 = {"ipv4": "10.0.3.1", "ipv6": "fd00:0:0:3::1"}
@ -94,28 +86,6 @@ PREFERRED_NEXT_HOP = "link_local"
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
class GenerateTopo(Topo):
"""
Test topology builder
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# This function only purpose is to create topology
# as defined in input json file.
#
# Create topology (setup module)
# Creating 2 routers topology, r1, r2in IBGP
# Bring up topology
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -137,7 +107,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(GenerateTopo, mod.__name__) json_file = "{}/ibgp_gshut_topo1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -39,7 +39,6 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413 # pylint: disable=C0413
# Import topogen and topotest helpers # Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen from lib.topogen import Topogen, get_topogen
from mininet.topo import Topo
from lib.common_config import ( from lib.common_config import (
start_topology, start_topology,
@ -66,13 +65,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables # Global variables
topo = None topo = None
# Reading the data from JSON File for topology creation
jsonFile = "{}/rfc5549_ebgp_ibgp_nbr.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NETWORK = { NETWORK = {
@ -121,21 +113,6 @@ unchange is configure on EBGP peers
""" """
class CreateTopo(Topo):
"""
Test topology builder.
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
"""Set up the pytest environment.""" """Set up the pytest environment."""
@ -147,7 +124,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/rfc5549_ebgp_ibgp_nbr.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers # to start deamons and then start routers

View File

@ -40,7 +40,6 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413 # pylint: disable=C0413
# Import topogen and topotest helpers # Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen from lib.topogen import Topogen, get_topogen
from mininet.topo import Topo
from lib.common_config import ( from lib.common_config import (
start_topology, start_topology,
@ -71,13 +70,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables # Global variables
topo = None topo = None
# Reading the data from JSON File for topology creation
jsonFile = "{}/rfc5549_ebgp_nbr.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NETWORK = { NETWORK = {
@ -137,21 +129,6 @@ TC32. Verify IPv4 route received with IPv6 nexthop can be advertised to
""" """
class CreateTopo(Topo):
"""
Test topology builder.
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
"""Set up the pytest environment.""" """Set up the pytest environment."""
global topo, ADDR_TYPES global topo, ADDR_TYPES
@ -163,7 +140,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/rfc5549_ebgp_nbr.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers # to start deamons and then start routers

View File

@ -37,7 +37,6 @@ sys.path.append(os.path.join(CWD, "../"))
sys.path.append(os.path.join(CWD, "../../")) sys.path.append(os.path.join(CWD, "../../"))
from lib.topogen import Topogen, get_topogen from lib.topogen import Topogen, get_topogen
from mininet.topo import Topo
from lib.common_config import ( from lib.common_config import (
write_test_header, write_test_header,
@ -62,13 +61,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables # Global variables
topo = None topo = None
# Reading the data from JSON File for topology creation
jsonFile = "{}/rfc5549_ebgp_unnumbered_nbr.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NO_OF_RTES = 2 NO_OF_RTES = 2
@ -124,21 +116,6 @@ shut / no shut of nexthop and BGP peer interfaces
""" """
class CreateTopo(Topo):
"""
Test topology builder.
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
"""Set up the pytest environment.""" """Set up the pytest environment."""
global topo, ADDR_TYPES global topo, ADDR_TYPES
@ -150,7 +127,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/rfc5549_ebgp_unnumbered_nbr.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers # to start deamons and then start routers

View File

@ -39,7 +39,6 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413 # pylint: disable=C0413
# Import topogen and topotest helpers # Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen from lib.topogen import Topogen, get_topogen
from mininet.topo import Topo
from lib.common_config import ( from lib.common_config import (
start_topology, start_topology,
@ -67,13 +66,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables # Global variables
topo = None topo = None
# Reading the data from JSON File for topology creation
jsonFile = "{}/rfc5549_ibgp_nbr.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NETWORK = { NETWORK = {
@ -121,21 +113,6 @@ TESTCASES = """
""" """
class CreateTopo(Topo):
"""
Test topology builder.
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
"""Set up the pytest environment.""" """Set up the pytest environment."""
@ -147,7 +124,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/rfc5549_ibgp_nbr.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers # to start deamons and then start routers

View File

@ -38,7 +38,6 @@ sys.path.append(os.path.join(CWD, "../../"))
# pylint: disable=C0413 # pylint: disable=C0413
# Import topogen and topotest helpers # Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen from lib.topogen import Topogen, get_topogen
from mininet.topo import Topo
from lib.common_config import ( from lib.common_config import (
start_topology, start_topology,
@ -58,13 +57,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
# Global variables # Global variables
topo = None topo = None
# Reading the data from JSON File for topology creation
jsonFile = "{}/rfc5549_ibgp_unnumbered_nbr.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
@ -107,21 +99,6 @@ TESTCASES = """
""" """
class CreateTopo(Topo):
"""
Test topology builder.
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
"""Set up the pytest environment.""" """Set up the pytest environment."""
@ -133,7 +110,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/rfc5549_ibgp_unnumbered_nbr.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers
# to start deamons and then start routers # to start deamons and then start routers

View File

@ -49,12 +49,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class BGPIPV6RTADVTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# Create 2 routers. # Create 2 routers.
tgen.add_router("r1") tgen.add_router("r1")
@ -67,7 +63,7 @@ class BGPIPV6RTADVTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
tgen = Topogen(BGPIPV6RTADVTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -94,12 +94,8 @@ CWD = os.path.dirname(os.path.realpath(__file__))
TEST = os.path.basename(CWD) TEST = os.path.basename(CWD)
class ThisTestTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# This function only purpose is to define allocation and relationship # This function only purpose is to define allocation and relationship
# between routers, switches and hosts. # between routers, switches and hosts.

View File

@ -95,12 +95,8 @@ CWD = os.path.dirname(os.path.realpath(__file__))
TEST = os.path.basename(CWD) TEST = os.path.basename(CWD)
class ThisTestTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# This function only purpose is to define allocation and relationship # This function only purpose is to define allocation and relationship
# between routers, switches and hosts. # between routers, switches and hosts.

View File

@ -81,13 +81,6 @@ CWD = os_path.dirname(os_path.realpath(__file__))
sys.path.append(os_path.join(CWD, "../")) sys.path.append(os_path.join(CWD, "../"))
sys.path.append(os_path.join(CWD, "../lib/")) sys.path.append(os_path.join(CWD, "../lib/"))
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/bgp_large_community_topo_1.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json_load(topoJson)
except IOError:
logger.info("Could not read file:", jsonFile)
# Global variables # Global variables
bgp_convergence = False bgp_convergence = False
@ -124,22 +117,6 @@ STANDARD_COMM = {
} }
class CreateTopo(Topo):
"""
Test topology builder
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -159,7 +136,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_large_community_topo_1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -97,39 +97,16 @@ from lib.topolog import logger
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/bgp_large_community_topo_2.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
bgp_convergence = False bgp_convergence = False
NETWORKS = {"ipv4": ["200.50.2.0/32"], "ipv6": ["1::1/128"]} NETWORKS = {"ipv4": ["200.50.2.0/32"], "ipv6": ["1::1/128"]}
class GenerateTopo(Topo):
"""
Test topology builder
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -149,7 +126,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(GenerateTopo, mod.__name__) json_file = "{}/bgp_large_community_topo_2.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -66,13 +66,8 @@ this scenario, the servers are also routers as they have to announce
anycast IP (VIP) addresses via BGP. anycast IP (VIP) addresses via BGP.
""" """
def build_topo(tgen):
class BgpLinkBwTopo(Topo):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# Create 10 routers - 1 super-spine, 2 spines, 3 leafs # Create 10 routers - 1 super-spine, 2 spines, 3 leafs
# and 4 servers # and 4 servers
@ -121,7 +116,7 @@ class BgpLinkBwTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
tgen = Topogen(BgpLinkBwTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -67,27 +67,12 @@ LISTEN_ADDRESSES = {
} }
# Reads data from JSON File for topology and configuration creation.
jsonFile = "{}/bgp_listen_on_multiple_addresses.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
class TemplateTopo(Topo):
"Topology builder."
def build(self, *_args, **_opts):
"Defines the allocation and relationship between routers and switches."
tgen = get_topogen(self)
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
"Sets up the test environment." "Sets up the test environment."
tgen = Topogen(TemplateTopo, mod.__name__) json_file = "{}/bgp_listen_on_multiple_addresses.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# Adds extra parameters to bgpd so they listen for connections on specific # Adds extra parameters to bgpd so they listen for connections on specific
# multiple addresses. # multiple addresses.

View File

@ -46,10 +46,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 5): for routern in range(1, 5):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -63,7 +60,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -62,12 +62,8 @@ pytestmark = [pytest.mark.bgpd]
# +-----+ +-----+ +-----+ # +-----+ +-----+ +-----+
class TemplateTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# This function only purpose is to define allocation and relationship # This function only purpose is to define allocation and relationship
# between routers, switches and hosts. # between routers, switches and hosts.
@ -92,7 +88,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
tgen.start_topology() tgen.start_topology()

View File

@ -50,10 +50,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -63,7 +60,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -46,10 +46,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -59,7 +56,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -41,10 +41,7 @@ from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -54,7 +51,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -145,15 +145,9 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_multi_vrf_topo1.json".format(CWD)
try: pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"} NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
@ -185,21 +179,6 @@ LOOPBACK_2 = {
} }
class CreateTopo(Topo):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -222,7 +201,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_multi_vrf_topo1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -105,14 +105,6 @@ from lib.topojson import build_config_from_json, build_topo_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_multi_vrf_topo2.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"} NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
@ -139,21 +131,6 @@ HOLDDOWNTIMER = 3
PREFERRED_NEXT_HOP = "link_local" PREFERRED_NEXT_HOP = "link_local"
class CreateTopo(Topo):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -176,7 +153,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_multi_vrf_topo2.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -74,8 +74,7 @@ from functools import partial
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest from lib import topotest
from lib.micronet_compat import Mininet from lib.topogen import get_topogen, Topogen
from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
@ -91,38 +90,28 @@ fatal_error = ""
##################################################### #####################################################
class NetworkTopo(Topo): def build_topo(tgen):
"BGP Multiview Topology 1"
def build(self, **_opts):
exabgpPrivateDirs = ["/etc/exabgp", "/var/run/exabgp", "/var/log"]
# Setup Routers # Setup Routers
router = {} router = tgen.add_router("r1")
for i in range(1, 2):
router[i] = topotest.addRouter(self, "r%s" % i)
# Setup Provider BGP peers # Setup Provider BGP peers
peer = {} peer = {}
for i in range(1, 9): for i in range(1, 9):
peer[i] = self.addHost( peer[i] = tgen.add_exabgp_peer(
"peer%s" % i, "peer%s" % i,
ip="172.16.1.%s/24" % i, ip="172.16.1.%s/24" % i,
defaultRoute="via 172.16.1.254", defaultRoute="via 172.16.1.254"
privateDirs=exabgpPrivateDirs,
) )
# Setup Switches
switch = {}
# First switch is for a dummy interface (for local network) # First switch is for a dummy interface (for local network)
switch[0] = self.addSwitch("sw0") switch = tgen.add_switch("sw0")
self.addLink(switch[0], router[1], intfName2="r1-stub") switch.add_link(router, nodeif="r1-stub")
# Second switch is for connection to all peering routers # Second switch is for connection to all peering routers
switch[1] = self.addSwitch("sw1") switch = tgen.add_switch("sw1")
self.addLink(switch[1], router[1], intfName2="r1-eth0") switch.add_link(router, nodeif="r1-eth0")
for j in range(1, 9): for j in range(1, 9):
self.addLink(switch[1], peer[j], intfName2="peer%s-eth0" % j) switch.add_link(peer[j], nodeif="peer%s-eth0" % j)
##################################################### #####################################################
@ -133,87 +122,43 @@ class NetworkTopo(Topo):
def setup_module(module): def setup_module(module):
global topo, net
print("\n\n** %s: Setup Topology" % module.__name__)
print("******************************************\n")
print("Cleanup old Mininet runs")
os.system("sudo mn -c > /dev/null 2>&1")
thisDir = os.path.dirname(os.path.realpath(__file__)) thisDir = os.path.dirname(os.path.realpath(__file__))
topo = NetworkTopo() tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
net = Mininet(controller=None, topo=topo)
net.start()
# Starting Routers # Starting Routers
for i in range(1, 2): router = tgen.net["r1"]
net["r%s" % i].loadConf("zebra", "%s/r%s/zebra.conf" % (thisDir, i)) router.loadConf("zebra", "%s/r1/zebra.conf" % thisDir)
net["r%s" % i].loadConf("bgpd", "%s/r%s/bgpd.conf" % (thisDir, i)) router.loadConf("bgpd", "%s/r1/bgpd.conf" % thisDir)
net["r%s" % i].startRouter() tgen.gears["r1"].start()
# Starting PE Hosts and init ExaBGP on each of them # Starting PE Hosts and init ExaBGP on each of them
print("*** Starting BGP on all 8 Peers") peer_list = tgen.exabgp_peers()
for i in range(1, 9): for pname, peer in peer_list.items():
net["peer%s" % i].cmd("cp %s/exabgp.env /etc/exabgp/exabgp.env" % thisDir) peer_dir = os.path.join(thisDir, pname)
net["peer%s" % i].cmd("cp %s/peer%s/* /etc/exabgp/" % (thisDir, i)) env_file = os.path.join(thisDir, "exabgp.env")
net["peer%s" % i].cmd("chmod 644 /etc/exabgp/*") peer.start(peer_dir, env_file)
net["peer%s" % i].cmd("chmod 755 /etc/exabgp/*.py")
net["peer%s" % i].cmd("chown -R exabgp:exabgp /etc/exabgp")
net["peer%s" % i].cmd("exabgp -e /etc/exabgp/exabgp.env /etc/exabgp/exabgp.cfg")
print("peer%s" % i),
print("")
# For debugging after starting FRR daemons, uncomment the next line
# CLI(net)
def teardown_module(module): def teardown_module(module):
global net tgen = get_topogen()
tgen.stop_topology()
print("\n\n** %s: Shutdown Topology" % module.__name__)
print("******************************************\n")
# Shutdown - clean up everything
print("*** Killing BGP on Peer routers")
# Killing ExaBGP
for i in range(1, 9):
net["peer%s" % i].cmd("kill `cat /var/run/exabgp/exabgp.pid`")
# End - Shutdown network
net.stop()
def test_router_running(): def test_router_running():
global fatal_error tgen = get_topogen()
global net
# Skip if previous fatal error condition is raised if tgen.routers_have_failure():
if fatal_error != "": pytest.skip(tgen.errors)
pytest.skip(fatal_error)
print("\n\n** Check if FRR is running on each Router node")
print("******************************************\n")
# Starting Routers
for i in range(1, 2):
fatal_error = net["r%s" % i].checkRouterRunning()
assert fatal_error == "", fatal_error
# For debugging after starting FRR daemons, uncomment the next line
# CLI(net)
def test_bgp_converge(): def test_bgp_converge():
"Check for BGP converged on all peers and BGP views" "Check for BGP converged on all peers and BGP views"
global fatal_error tgen = get_topogen()
global net
# Skip if previous fatal error condition is raised if tgen.routers_have_failure():
if fatal_error != "": pytest.skip(tgen.errors)
pytest.skip(fatal_error)
# Wait for BGP to converge (All Neighbors in either Full or TwoWay State) # Wait for BGP to converge (All Neighbors in either Full or TwoWay State)
@ -224,7 +169,7 @@ def test_bgp_converge():
# Look for any node not yet converged # Look for any node not yet converged
for i in range(1, 2): for i in range(1, 2):
for view in range(1, 4): for view in range(1, 4):
notConverged = net["r%s" % i].cmd( notConverged = tgen.net["r%s" % i].cmd(
'vtysh -c "show ip bgp view %s summary" 2> /dev/null | grep ^[0-9] | grep -vP " 11\s+(\d+)"' 'vtysh -c "show ip bgp view %s summary" 2> /dev/null | grep ^[0-9] | grep -vP " 11\s+(\d+)"'
% view % view
) )
@ -242,7 +187,7 @@ def test_bgp_converge():
break break
else: else:
# Bail out with error if a router fails to converge # Bail out with error if a router fails to converge
bgpStatus = net["r%s" % i].cmd('vtysh -c "show ip bgp view %s summary"' % view) bgpStatus = tgen.net["r%s" % i].cmd('vtysh -c "show ip bgp view %s summary"' % view)
assert False, "BGP did not converge:\n%s" % bgpStatus assert False, "BGP did not converge:\n%s" % bgpStatus
# Wait for an extra 5s to announce all routes # Wait for an extra 5s to announce all routes
@ -256,53 +201,92 @@ def test_bgp_converge():
# print("\nwaiting 15s for routes to populate") # print("\nwaiting 15s for routes to populate")
# sleep(15) # sleep(15)
# Make sure that all daemons are running tgen.routers_have_failure()
for i in range(1, 2):
fatal_error = net["r%s" % i].checkRouterRunning()
assert fatal_error == "", fatal_error
# For debugging after starting FRR daemons, uncomment the next line
# CLI(net)
def test_bgp_routingTable(): def test_bgp_routingTable():
global fatal_error tgen = get_topogen()
global net
# Skip if previous fatal error condition is raised if tgen.routers_have_failure():
if fatal_error != "": pytest.skip(tgen.errors)
pytest.skip(fatal_error)
thisDir = os.path.dirname(os.path.realpath(__file__)) thisDir = os.path.dirname(os.path.realpath(__file__))
print("Verifying BGP Routing Tables")
def router_json_cmp(router, cmd, data): print("\n\n** Verifying BGP Routing Tables")
json_data = json.loads(router.cmd("vtysh -c \"{}\" 2> /dev/null".format(cmd))) print("******************************************\n")
return topotest.json_cmp(json_data, data) diffresult = {}
router = net["r1"]
for view in range(1, 4):
json_file = "{}/{}/view_{}.json".format(thisDir, router.name, view)
expected = json.loads(open(json_file).read())
test_func = partial(
router_json_cmp, router, "show ip bgp view {} json".format(view), expected
)
_, result = topotest.run_and_expect(test_func, None, count=5, wait=1)
assertmsg = "Routing Table verification failed for router {}, view {}".format(
router.name, view
)
assert result is None, assertmsg
# Make sure that all daemons are running
for i in range(1, 2): for i in range(1, 2):
fatal_error = net["r%s" % i].checkRouterRunning() for view in range(1, 4):
assert fatal_error == "", fatal_error success = 0
# For debugging after starting FRR daemons, uncomment the next line # This glob pattern should work as long as number of views < 10
# CLI(net) for refTableFile in glob.glob(
"%s/r%s/show_ip_bgp_view_%s*.ref" % (thisDir, i, view)
):
if os.path.isfile(refTableFile):
# Read expected result from file
expected = open(refTableFile).read().rstrip()
# Fix newlines (make them all the same)
expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
# Actual output from router
actual = (
tgen.net["r%s" % i]
.cmd('vtysh -c "show ip bgp view %s" 2> /dev/null' % view)
.rstrip()
)
# Fix inconsitent spaces between 0.99.24 and newer versions
actual = re.sub("0 0", "0 0", actual)
actual = re.sub(
r"([0-9]) 32768", r"\1 32768", actual
)
# Remove summary line (changed recently)
actual = re.sub(r"Total number.*", "", actual)
actual = re.sub(r"Displayed.*", "", actual)
actual = actual.rstrip()
# Fix table version (ignore it)
actual = re.sub(r"(BGP table version is )[0-9]+", r"\1XXX", actual)
# Fix newlines (make them all the same)
actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1)
# Generate Diff
diff = topotest.get_textdiff(
actual,
expected,
title1="actual BGP routing table",
title2="expected BGP routing table",
)
if diff:
diffresult[refTableFile] = diff
else:
success = 1
print("template %s matched: r%s ok" % (refTableFile, i))
break
if not success:
resultstr = "No template matched.\n"
for f in diffresult.keys():
resultstr += (
"template %s: r%s failed Routing Table Check for view %s:\n%s\n"
% (f, i, view, diffresult[f])
)
raise AssertionError(
"Routing Table verification failed for router r%s, view %s:\n%s"
% (i, view, resultstr)
)
tgen.routers_have_failure()
def test_shutdown_check_stderr(): def test_shutdown_check_stderr():
global fatal_error tgen = get_topogen()
global net
# Skip if previous fatal error condition is raised # Skip if previous fatal error condition is raised
if fatal_error != "": if tgen.routers_have_failure():
pytest.skip(fatal_error) pytest.skip(tgen.errors)
if os.environ.get("TOPOTESTS_CHECK_STDERR") is None: if os.environ.get("TOPOTESTS_CHECK_STDERR") is None:
print( print(
@ -315,36 +299,22 @@ def test_shutdown_check_stderr():
print("\n\n** Verifying unexpected STDERR output from daemons") print("\n\n** Verifying unexpected STDERR output from daemons")
print("******************************************\n") print("******************************************\n")
net["r1"].stopRouter() tgen.net["r1"].stopRouter()
log = net["r1"].getStdErr("bgpd") log = tgen.net["r1"].getStdErr("bgpd")
if log: if log:
print("\nBGPd StdErr Log:\n" + log) print("\nBGPd StdErr Log:\n" + log)
log = net["r1"].getStdErr("zebra") log = tgen.net["r1"].getStdErr("zebra")
if log: if log:
print("\nZebra StdErr Log:\n" + log) print("\nZebra StdErr Log:\n" + log)
def test_shutdown_check_memleak(): def test_shutdown_check_memleak():
global fatal_error tgen = get_topogen()
global net if not tgen.is_memleak_enabled():
pytest.skip("Memory leak test/report is disabled")
# Skip if previous fatal error condition is raised tgen.report_memory_leaks()
if fatal_error != "":
pytest.skip(fatal_error)
if os.environ.get("TOPOTESTS_CHECK_MEMLEAK") is None:
print(
"SKIPPED final check on Memory leaks: Disabled (TOPOTESTS_CHECK_MEMLEAK undefined)\n"
)
pytest.skip("Skipping test for memory leaks")
thisDir = os.path.dirname(os.path.realpath(__file__))
net["r1"].stopRouter()
net["r1"].report_memory_leaks(
os.environ.get("TOPOTESTS_CHECK_MEMLEAK"), os.path.basename(__file__)
)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -94,37 +94,14 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_path_attributes.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Address read from env variables # Address read from env variables
ADDR_TYPES = check_address_types() ADDR_TYPES = check_address_types()
#### ####
class CreateTopo(Topo):
"""
Test CreateTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# Building topology and configuration from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -141,7 +118,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_path_attributes.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -42,10 +42,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 4): for routern in range(1, 4):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -56,7 +53,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -76,10 +76,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
class PeerTypeRelaxTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# Set up routers # Set up routers
tgen.add_router("r1") # DUT tgen.add_router("r1") # DUT
@ -101,7 +99,7 @@ class PeerTypeRelaxTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
tgen = Topogen(PeerTypeRelaxTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
# For all registered routers, load the zebra configuration file # For all registered routers, load the zebra configuration file

View File

@ -73,37 +73,14 @@ from lib.topolog import logger
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/prefix_lists.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
bgp_convergence = False bgp_convergence = False
class BGPPrefixListTopo(Topo):
"""
Test BGPPrefixListTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -118,7 +95,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(BGPPrefixListTopo, mod.__name__) json_file = "{}/prefix_lists.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -44,9 +44,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, **_opts):
tgen = get_topogen(self)
router = tgen.add_router("r1") router = tgen.add_router("r1")
switch = tgen.add_switch("s1") switch = tgen.add_switch("s1")
switch.add_link(router) switch.add_link(router)
@ -63,7 +61,7 @@ class TemplateTopo(Topo):
def setup_module(module): def setup_module(module):
tgen = Topogen(TemplateTopo, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
router = tgen.gears["r1"] router = tgen.gears["r1"]

View File

@ -44,9 +44,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, **_opts):
tgen = get_topogen(self)
router = tgen.add_router("r1") router = tgen.add_router("r1")
switch = tgen.add_switch("s1") switch = tgen.add_switch("s1")
switch.add_link(router) switch.add_link(router)
@ -59,7 +57,7 @@ class TemplateTopo(Topo):
def setup_module(module): def setup_module(module):
tgen = Topogen(TemplateTopo, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
router = tgen.gears["r1"] router = tgen.gears["r1"]

View File

@ -89,14 +89,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/bgp_recursive_route_ebgp_multi_hop.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
logger.info("Could not read file:", jsonFile)
# Global variables # Global variables
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
KEEP_ALIVE_TIMER = 2 KEEP_ALIVE_TIMER = 2
@ -124,21 +116,6 @@ Loopabck_IP = {
} }
class CreateTopo(Topo):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -153,7 +130,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_recursive_route_ebgp_multi_hop.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -53,10 +53,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 4): for routern in range(1, 4):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -70,7 +67,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -81,12 +81,8 @@ CWD = os.path.dirname(os.path.realpath(__file__))
TEST = os.path.basename(CWD) TEST = os.path.basename(CWD)
class ThisTestTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# This function only purpose is to define allocation and relationship # This function only purpose is to define allocation and relationship
# between routers, switches and hosts. # between routers, switches and hosts.

View File

@ -41,15 +41,11 @@ sys.path.append(os.path.join(CWD, "../"))
from lib import topotest from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger from lib.topolog import logger
from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -59,7 +55,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -70,17 +70,9 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/bgp_aggregation.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
logger.info("Could not read file:", jsonFile)
# Global variables # Global variables
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types() ADDR_TYPES = check_address_types()
@ -113,21 +105,6 @@ COMMUNITY = [
] ]
class CreateTopo(Topo):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -142,7 +119,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_aggregation.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -115,13 +115,6 @@ TC_38:
bgp_convergence = False bgp_convergence = False
BGP_CONVERGENCE = False BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types() ADDR_TYPES = check_address_types()
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/bgp_route_map_topo1.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
bgp_convergence = False bgp_convergence = False
@ -131,22 +124,6 @@ NEXT_HOP = {"ipv4": "10.0.0.2", "ipv6": "fd00::2"}
ADDR_TYPES = check_address_types() ADDR_TYPES = check_address_types()
class CreateTopo(Topo):
"""
Test topology builder
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -161,7 +138,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_route_map_topo1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -147,18 +147,9 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology and configuration creation
jsonFile = "{}/bgp_route_map_topo2.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
# Global variables # Global variables
bgp_convergence = False bgp_convergence = False
@ -169,21 +160,6 @@ BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types() ADDR_TYPES = check_address_types()
class BGPRmapTopo(Topo):
"""BGPRmapTopo.
BGPRmap topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function."""
tgen = get_topogen(self)
# Building topology and configuration from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
"""setup_module. """setup_module.
@ -197,7 +173,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(BGPRmapTopo, mod.__name__) json_file = "{}/bgp_route_map_topo2.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -49,24 +49,13 @@ from lib.topolog import logger
# Required to instantiate the topology builder class. # Required to instantiate the topology builder class.
from lib.micronet_compat import Topo from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
##################################################### def build_topo(tgen):
##
## Network Topology Definition
##
#####################################################
class NetworkTopo(Topo):
"BGP_RR_IBGP Topology 1"
def build(self, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
tgen.add_router("tor1") tgen.add_router("tor1")
tgen.add_router("tor2") tgen.add_router("tor2")
tgen.add_router("spine1") tgen.add_router("spine1")
@ -102,7 +91,7 @@ class NetworkTopo(Topo):
def setup_module(module): def setup_module(module):
"Setup topology" "Setup topology"
tgen = Topogen(NetworkTopo, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
# This is a sample of configuration loading. # This is a sample of configuration loading.

View File

@ -47,10 +47,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 4): for routern in range(1, 4):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -64,7 +61,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -47,10 +47,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 4): for routern in range(1, 4):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -61,7 +58,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -50,12 +50,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.snmp] pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.snmp]
class TemplateTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# This function only purpose is to define allocation and relationship # This function only purpose is to define allocation and relationship
# between routers, switches and hosts. # between routers, switches and hosts.
@ -131,7 +127,7 @@ def setup_module(mod):
pytest.skip(error_msg) pytest.skip(error_msg)
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
tgen.start_topology() tgen.start_topology()

View File

@ -42,7 +42,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class Topology(Topo): def build_topo(tgen):
""" """
CE1 CE3 CE5 CE1 CE3 CE5
(eth0) (eth0) (eth0) (eth0) (eth0) (eth0)
@ -79,8 +79,6 @@ class Topology(Topo):
(eth0) (eth0) (eth0) (eth0) (eth0) (eth0)
CE2 CE4 CE6 CE2 CE4 CE6
""" """
def build(self, *_args, **_opts):
tgen = get_topogen(self)
tgen.add_router("r1") tgen.add_router("r1")
tgen.add_router("r2") tgen.add_router("r2")
tgen.add_router("ce1") tgen.add_router("ce1")
@ -104,7 +102,7 @@ def setup_module(mod):
if result is not True: if result is not True:
pytest.skip("Kernel requirements are not met") pytest.skip("Kernel requirements are not met")
tgen = Topogen(Topology, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()
for rname, router in tgen.routers().items(): for rname, router in tgen.routers().items():

View File

@ -43,10 +43,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 4): for routern in range(1, 4):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -60,7 +57,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -54,10 +54,7 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -67,7 +64,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -76,10 +76,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class TemplateTopo(Topo): CWD = os.path.dirname(os.path.realpath(__file__))
def build(self, *_args, **_opts): def build_topo(tgen):
tgen = get_topogen(self)
for routern in range(1, 6): for routern in range(1, 6):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -101,7 +99,7 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -81,17 +81,9 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_vrf_dynamic_route_leak_topo1.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables # Global variables
NETWORK1_1 = {"ipv4": "11.11.11.1/32", "ipv6": "11:11::1/128"} NETWORK1_1 = {"ipv4": "11.11.11.1/32", "ipv6": "11:11::1/128"}
NETWORK1_2 = {"ipv4": "11.11.11.11/32", "ipv6": "11:11::11/128"} NETWORK1_2 = {"ipv4": "11.11.11.11/32", "ipv6": "11:11::11/128"}
@ -125,21 +117,6 @@ LOOPBACK_2 = {
PREFERRED_NEXT_HOP = "global" PREFERRED_NEXT_HOP = "global"
class CreateTopo(Topo):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -147,7 +124,6 @@ def setup_module(mod):
* `mod`: module name * `mod`: module name
""" """
global topo
testsuite_run_time = time.asctime(time.localtime(time.time())) testsuite_run_time = time.asctime(time.localtime(time.time()))
logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("Testsuite start time: {}".format(testsuite_run_time))
logger.info("=" * 40) logger.info("=" * 40)
@ -155,7 +131,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/bgp_vrf_dynamic_route_leak_topo1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -97,16 +97,8 @@ NETWORK3_4 = {"ipv4": "50.50.50.50/32", "ipv6": "50:50::50/128"}
PREFERRED_NEXT_HOP = "global" PREFERRED_NEXT_HOP = "global"
class CreateTopo(Topo): def build_topo(tgen):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function""" """Build function"""
tgen = get_topogen(self)
# Building topology from json file # Building topology from json file
build_topo_from_json(tgen, topo) build_topo_from_json(tgen, topo)
@ -127,7 +119,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -50,12 +50,8 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class BGPIPV6RTADVVRFTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# Create 2 routers. # Create 2 routers.
tgen.add_router("r1") tgen.add_router("r1")
@ -74,7 +70,7 @@ def setup_module(mod):
if result is not True: if result is not True:
pytest.skip("Kernel requirements are not met") pytest.skip("Kernel requirements are not met")
tgen = Topogen(BGPIPV6RTADVVRFTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -57,13 +57,7 @@ CustomizeVrfWithNetns = True
##################################################### #####################################################
class BGPVRFNETNSTopo1(Topo): def build_topo(tgen):
"BGP EBGP VRF NETNS Topology 1"
def build(self, **_opts):
tgen = get_topogen(self)
# Setup Routers
tgen.add_router("r1") tgen.add_router("r1")
# Setup Switches # Setup Switches
@ -86,7 +80,7 @@ class BGPVRFNETNSTopo1(Topo):
def setup_module(module): def setup_module(module):
tgen = Topogen(BGPVRFNETNSTopo1, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
# Get r1 reference # Get r1 reference

View File

@ -41,13 +41,12 @@ from lib.topolog import logger
from lib.micronet_compat import Topo from lib.micronet_compat import Topo
pytestmark = [pytest.mark.bgpd] pytestmark = [pytest.mark.bgpd]
class BGPVRFTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
for routern in range(1, 2): for routern in range(1, 2):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -55,7 +54,7 @@ class BGPVRFTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
tgen = Topogen(BGPVRFTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
# For all registered routers, load the zebra configuration file # For all registered routers, load the zebra configuration file

View File

@ -49,16 +49,14 @@ from lib.micronet_compat import Topo
pytestmark = [pytest.mark.staticd] pytestmark = [pytest.mark.staticd]
class TimingTopo(Topo): def build_topo(tgen):
def build(self, *_args, **_opts):
tgen = get_topogen(self)
tgen.add_router("r1") tgen.add_router("r1")
switch = tgen.add_switch("s1") switch = tgen.add_switch("s1")
switch.add_link(tgen.gears["r1"]) switch.add_link(tgen.gears["r1"])
def setup_module(mod): def setup_module(mod):
tgen = Topogen(TimingTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
router_list = tgen.routers() router_list = tgen.routers()

View File

@ -55,14 +55,7 @@ from lib.micronet_compat import Topo
##################################################### #####################################################
class NetworkTopo(Topo): def build_topo(tgen):
"EIGRP Topology 1"
def build(self, **_opts):
"Build function"
tgen = get_topogen(self)
for routern in range(1, 4): for routern in range(1, 4):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -96,7 +89,7 @@ class NetworkTopo(Topo):
def setup_module(module): def setup_module(module):
"Setup topology" "Setup topology"
tgen = Topogen(NetworkTopo, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
# This is a sample of configuration loading. # This is a sample of configuration loading.

View File

@ -59,14 +59,7 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.bgpd]
##################################################### #####################################################
class NetworkTopo(Topo): def build_topo(tgen):
"evpn-pim Topology 1"
def build(self, **_opts):
"Build function"
tgen = get_topogen(self)
tgen.add_router("spine") tgen.add_router("spine")
tgen.add_router("leaf1") tgen.add_router("leaf1")
tgen.add_router("leaf2") tgen.add_router("leaf2")
@ -105,7 +98,7 @@ class NetworkTopo(Topo):
def setup_module(module): def setup_module(module):
"Setup topology" "Setup topology"
tgen = Topogen(NetworkTopo, module.__name__) tgen = Topogen(build_topo, module.__name__)
tgen.start_topology() tgen.start_topology()
leaf1 = tgen.gears["leaf1"] leaf1 = tgen.gears["leaf1"]

View File

@ -85,17 +85,9 @@ from lib.bgp import (
) )
from lib.topojson import build_topo_from_json, build_config_from_json from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/evpn_type5_chaos_topo1.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Reading the data from JSON File for topology creation # Reading the data from JSON File for topology creation
# Global variables # Global variables
TCPDUMP_FILE = "evpn_log.txt" TCPDUMP_FILE = "evpn_log.txt"
@ -139,21 +131,6 @@ BRCTL = {
} }
class CreateTopo(Topo):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod): def setup_module(mod):
""" """
Sets up the pytest environment Sets up the pytest environment
@ -161,7 +138,6 @@ def setup_module(mod):
* `mod`: module name * `mod`: module name
""" """
global topo
testsuite_run_time = time.asctime(time.localtime(time.time())) testsuite_run_time = time.asctime(time.localtime(time.time()))
logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("Testsuite start time: {}".format(testsuite_run_time))
logger.info("=" * 40) logger.info("=" * 40)
@ -169,7 +145,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) json_file = "{}/evpn_type5_chaos_topo1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -142,18 +142,7 @@ BRCTL = {
} }
class CreateTopo(Topo): def build_topo(tgen):
"""
Test BasicTopo - topology 1
* `Topo`: Topology object
"""
def build(self, *_args, **_opts):
"""Build function"""
tgen = get_topogen(self)
# Building topology from json file
build_topo_from_json(tgen, topo) build_topo_from_json(tgen, topo)
@ -172,7 +161,7 @@ def setup_module(mod):
logger.info("Running setup_module to create topology") logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(CreateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# ... and here it calls Mininet initialization functions. # ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers # Starting topology, create tmp files which are loaded to routers

View File

@ -30,19 +30,10 @@ import os
import sys import sys
import pytest import pytest
# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers # Import topogen and topotest helpers
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger from lib.topolog import logger
# Required to instantiate the topology builder class.
from lib.micronet_compat import Topo
# TODO: select markers based on daemons used during test # TODO: select markers based on daemons used during test
# pytest module level markers # pytest module level markers
@ -56,18 +47,9 @@ pytestmark = [
""" """
class TemplateTopo(Topo): def build_topo(tgen):
"Test topology builder"
def build(self, *_args, **_opts):
"Build function" "Build function"
tgen = get_topogen(self)
# This function only purpose is to define allocation and relationship
# between routers, switches and hosts.
#
# Example
#
# Create 2 routers # Create 2 routers
for routern in range(1, 3): for routern in range(1, 3):
tgen.add_router("r{}".format(routern)) tgen.add_router("r{}".format(routern))
@ -85,8 +67,20 @@ class TemplateTopo(Topo):
def setup_module(mod): def setup_module(mod):
"Sets up the pytest environment" "Sets up the pytest environment"
# This function initiates the topology build with Topogen... # This function initiates the topology build with Topogen...
tgen = Topogen(TemplateTopo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
# The basic topology above could also have be more easily specified using a
# dictionary, remove the build_topo function and use the following instead:
#
# topodef = {
# "s1": "r1"
# "s2": ("r1", "r2")
# }
# tgen = Topogen(topodef, mod.__name__)
# ... and here it calls initialization functions. # ... and here it calls initialization functions.
tgen.start_topology() tgen.start_topology()
@ -94,6 +88,7 @@ def setup_module(mod):
router_list = tgen.routers() router_list = tgen.routers()
# For all registred routers, load the zebra configuration file # For all registred routers, load the zebra configuration file
# CWD = os.path.dirname(os.path.realpath(__file__))
for rname, router in router_list.items(): for rname, router in router_list.items():
router.load_config( router.load_config(
TopoRouter.RD_ZEBRA, TopoRouter.RD_ZEBRA,

Some files were not shown because too many files have changed in this diff Show More