mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 07:21:29 +00:00
tests: remove legacy Topo class (fixes many pylint errors)
Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
d7d21c3a19
commit
e82b531df9
@ -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")
|
||||||
|
for i in range(0, 10):
|
||||||
def build(self, **_opts):
|
tgen.add_switch("sw%d" % i).add_link(router)
|
||||||
|
|
||||||
# Setup Routers
|
|
||||||
router = {}
|
|
||||||
#
|
|
||||||
# Setup Main Router
|
|
||||||
router[1] = topotest.addRouter(self, "r1")
|
|
||||||
#
|
|
||||||
|
|
||||||
# Setup Switches
|
|
||||||
switch = {}
|
|
||||||
#
|
|
||||||
for i in range(0, 10):
|
|
||||||
switch[i] = self.addSwitch("sw%s" % i)
|
|
||||||
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 != "":
|
||||||
|
@ -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()
|
||||||
|
@ -49,33 +49,27 @@ 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"
|
# Create 4 routers
|
||||||
|
for routern in range(1, 5):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
switch = tgen.add_switch("s1")
|
||||||
"Build function"
|
switch.add_link(tgen.gears["r1"])
|
||||||
tgen = get_topogen(self)
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
# Create 4 routers
|
switch = tgen.add_switch("s2")
|
||||||
for routern in range(1, 5):
|
switch.add_link(tgen.gears["r2"])
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
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"
|
||||||
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()
|
||||||
|
@ -50,20 +50,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -53,20 +53,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -45,27 +45,25 @@ 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)
|
|
||||||
|
|
||||||
r1 = tgen.add_router("r1")
|
def build_topo(tgen):
|
||||||
r2 = tgen.add_router("r2")
|
r1 = tgen.add_router("r1")
|
||||||
peer1 = tgen.add_exabgp_peer(
|
r2 = tgen.add_router("r2")
|
||||||
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
peer1 = tgen.add_exabgp_peer(
|
||||||
)
|
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
||||||
|
)
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s1")
|
||||||
switch.add_link(r1)
|
switch.add_link(r1)
|
||||||
switch.add_link(peer1)
|
switch.add_link(peer1)
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(r1)
|
switch.add_link(r1)
|
||||||
switch.add_link(r2)
|
switch.add_link(r2)
|
||||||
|
|
||||||
|
|
||||||
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"]
|
||||||
|
@ -43,22 +43,19 @@ 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):
|
r1 = tgen.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
peer1 = tgen.add_exabgp_peer(
|
||||||
|
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
||||||
|
)
|
||||||
|
|
||||||
r1 = tgen.add_router("r1")
|
switch = tgen.add_switch("s1")
|
||||||
peer1 = tgen.add_exabgp_peer(
|
switch.add_link(r1)
|
||||||
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
switch.add_link(peer1)
|
||||||
)
|
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(r1)
|
|
||||||
switch.add_link(peer1)
|
|
||||||
|
|
||||||
|
|
||||||
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"]
|
||||||
|
@ -94,19 +94,11 @@ 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):
|
||||||
"""
|
"""Build function"""
|
||||||
Test BGPALLOWASIN - topology 1
|
|
||||||
|
|
||||||
* `Topo`: Topology object
|
# Building topology from json file
|
||||||
"""
|
build_topo_from_json(tgen, topo)
|
||||||
|
|
||||||
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):
|
||||||
@ -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
|
||||||
|
@ -48,21 +48,18 @@ 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):
|
for routern in range(1, 4):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 4):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
switch.add_link(tgen.gears["r3"])
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -43,22 +43,19 @@ 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):
|
r1 = tgen.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
peer1 = tgen.add_exabgp_peer(
|
||||||
|
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
||||||
|
)
|
||||||
|
|
||||||
r1 = tgen.add_router("r1")
|
switch = tgen.add_switch("s1")
|
||||||
peer1 = tgen.add_exabgp_peer(
|
switch.add_link(r1)
|
||||||
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
switch.add_link(peer1)
|
||||||
)
|
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(r1)
|
|
||||||
switch.add_link(peer1)
|
|
||||||
|
|
||||||
|
|
||||||
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"]
|
||||||
|
@ -74,76 +74,64 @@ 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):
|
||||||
|
# Create routers
|
||||||
|
tgen.add_router("R1")
|
||||||
|
tgen.add_router("R2")
|
||||||
|
tgen.add_router("R3")
|
||||||
|
|
||||||
class TemplateTopo(Topo):
|
# R1-R2 1
|
||||||
"Test topology builder"
|
switch = tgen.add_switch("s1")
|
||||||
|
switch.add_link(tgen.gears["R1"])
|
||||||
|
switch.add_link(tgen.gears["R2"])
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# R1-R3 1
|
||||||
"Build function"
|
switch = tgen.add_switch("s2")
|
||||||
tgen = get_topogen(self)
|
switch.add_link(tgen.gears["R1"])
|
||||||
|
switch.add_link(tgen.gears["R3"])
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
# R2-R3 1
|
||||||
# between routers, switches and hosts.
|
switch = tgen.add_switch("s3")
|
||||||
#
|
switch.add_link(tgen.gears["R2"])
|
||||||
#
|
switch.add_link(tgen.gears["R3"])
|
||||||
# Create routers
|
|
||||||
tgen.add_router("R1")
|
|
||||||
tgen.add_router("R2")
|
|
||||||
tgen.add_router("R3")
|
|
||||||
|
|
||||||
# R1-R2 1
|
# R1-R2 2
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s4")
|
||||||
switch.add_link(tgen.gears["R1"])
|
switch.add_link(tgen.gears["R1"])
|
||||||
switch.add_link(tgen.gears["R2"])
|
switch.add_link(tgen.gears["R2"])
|
||||||
|
|
||||||
# R1-R3 1
|
# R1-R3 2
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s5")
|
||||||
switch.add_link(tgen.gears["R1"])
|
switch.add_link(tgen.gears["R1"])
|
||||||
switch.add_link(tgen.gears["R3"])
|
switch.add_link(tgen.gears["R3"])
|
||||||
|
|
||||||
# R2-R3 1
|
# R2-R3 2
|
||||||
switch = tgen.add_switch("s3")
|
switch = tgen.add_switch("s6")
|
||||||
switch.add_link(tgen.gears["R2"])
|
switch.add_link(tgen.gears["R2"])
|
||||||
switch.add_link(tgen.gears["R3"])
|
switch.add_link(tgen.gears["R3"])
|
||||||
|
|
||||||
# R1-R2 2
|
# R1-R2 3
|
||||||
switch = tgen.add_switch("s4")
|
switch = tgen.add_switch("s7")
|
||||||
switch.add_link(tgen.gears["R1"])
|
switch.add_link(tgen.gears["R1"])
|
||||||
switch.add_link(tgen.gears["R2"])
|
switch.add_link(tgen.gears["R2"])
|
||||||
|
|
||||||
# R1-R3 2
|
# R1-R3 2
|
||||||
switch = tgen.add_switch("s5")
|
switch = tgen.add_switch("s8")
|
||||||
switch.add_link(tgen.gears["R1"])
|
switch.add_link(tgen.gears["R1"])
|
||||||
switch.add_link(tgen.gears["R3"])
|
switch.add_link(tgen.gears["R3"])
|
||||||
|
|
||||||
# R2-R3 2
|
# R2-R3 2
|
||||||
switch = tgen.add_switch("s6")
|
switch = tgen.add_switch("s9")
|
||||||
switch.add_link(tgen.gears["R2"])
|
switch.add_link(tgen.gears["R2"])
|
||||||
switch.add_link(tgen.gears["R3"])
|
switch.add_link(tgen.gears["R3"])
|
||||||
|
|
||||||
# R1-R2 3
|
|
||||||
switch = tgen.add_switch("s7")
|
|
||||||
switch.add_link(tgen.gears["R1"])
|
|
||||||
switch.add_link(tgen.gears["R2"])
|
|
||||||
|
|
||||||
# R1-R3 2
|
|
||||||
switch = tgen.add_switch("s8")
|
|
||||||
switch.add_link(tgen.gears["R1"])
|
|
||||||
switch.add_link(tgen.gears["R3"])
|
|
||||||
|
|
||||||
# R2-R3 2
|
|
||||||
switch = tgen.add_switch("s9")
|
|
||||||
switch.add_link(tgen.gears["R2"])
|
|
||||||
switch.add_link(tgen.gears["R3"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -43,28 +43,25 @@ 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):
|
for routern in range(1, 5):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 5):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s3")
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r4"])
|
|
||||||
|
|
||||||
|
|
||||||
def setup_module(mod):
|
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()
|
||||||
|
@ -48,20 +48,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -43,20 +43,18 @@ 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)
|
|
||||||
|
|
||||||
for routern in range(1, 3):
|
def build_topo(tgen):
|
||||||
tgen.add_router("r{}".format(routern))
|
for routern in range(1, 3):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s1")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -62,55 +62,52 @@ 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.add_router("z1")
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("y1")
|
||||||
|
tgen.add_router("y2")
|
||||||
|
tgen.add_router("y3")
|
||||||
|
tgen.add_router("x1")
|
||||||
|
tgen.add_router("c1")
|
||||||
|
|
||||||
tgen.add_router("z1")
|
# 10.0.1.0/30
|
||||||
tgen.add_router("y1")
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("y2")
|
switch.add_link(tgen.gears["c1"])
|
||||||
tgen.add_router("y3")
|
switch.add_link(tgen.gears["x1"])
|
||||||
tgen.add_router("x1")
|
|
||||||
tgen.add_router("c1")
|
|
||||||
|
|
||||||
# 10.0.1.0/30
|
# 10.0.2.0/30
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["c1"])
|
switch.add_link(tgen.gears["x1"])
|
||||||
switch.add_link(tgen.gears["x1"])
|
switch.add_link(tgen.gears["y1"])
|
||||||
|
|
||||||
# 10.0.2.0/30
|
# 10.0.3.0/30
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["x1"])
|
switch.add_link(tgen.gears["y1"])
|
||||||
switch.add_link(tgen.gears["y1"])
|
switch.add_link(tgen.gears["y2"])
|
||||||
|
|
||||||
# 10.0.3.0/30
|
# 10.0.4.0/30
|
||||||
switch = tgen.add_switch("s3")
|
switch = tgen.add_switch("s4")
|
||||||
switch.add_link(tgen.gears["y1"])
|
switch.add_link(tgen.gears["y1"])
|
||||||
switch.add_link(tgen.gears["y2"])
|
switch.add_link(tgen.gears["y3"])
|
||||||
|
|
||||||
# 10.0.4.0/30
|
# 10.0.5.0/30
|
||||||
switch = tgen.add_switch("s4")
|
switch = tgen.add_switch("s5")
|
||||||
switch.add_link(tgen.gears["y1"])
|
switch.add_link(tgen.gears["y2"])
|
||||||
switch.add_link(tgen.gears["y3"])
|
switch.add_link(tgen.gears["y3"])
|
||||||
|
|
||||||
# 10.0.5.0/30
|
# 10.0.6.0/30
|
||||||
switch = tgen.add_switch("s5")
|
switch = tgen.add_switch("s6")
|
||||||
switch.add_link(tgen.gears["y2"])
|
switch.add_link(tgen.gears["y2"])
|
||||||
switch.add_link(tgen.gears["y3"])
|
switch.add_link(tgen.gears["z1"])
|
||||||
|
|
||||||
# 10.0.6.0/30
|
# 10.0.7.0/30
|
||||||
switch = tgen.add_switch("s6")
|
switch = tgen.add_switch("s7")
|
||||||
switch.add_link(tgen.gears["y2"])
|
switch.add_link(tgen.gears["y3"])
|
||||||
switch.add_link(tgen.gears["z1"])
|
switch.add_link(tgen.gears["z1"])
|
||||||
|
|
||||||
# 10.0.7.0/30
|
|
||||||
switch = tgen.add_switch("s7")
|
|
||||||
switch.add_link(tgen.gears["y3"])
|
|
||||||
switch.add_link(tgen.gears["z1"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -142,21 +142,18 @@ 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):
|
r1 = tgen.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
r2 = tgen.add_router("r2")
|
||||||
|
r3 = tgen.add_router("r3")
|
||||||
|
|
||||||
r1 = tgen.add_router("r1")
|
switch = tgen.add_switch("s1")
|
||||||
r2 = tgen.add_router("r2")
|
switch.add_link(r1)
|
||||||
r3 = tgen.add_router("r3")
|
switch.add_link(r2)
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(r1)
|
switch.add_link(r2)
|
||||||
switch.add_link(r2)
|
switch.add_link(r3)
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
|
||||||
switch.add_link(r2)
|
|
||||||
switch.add_link(r3)
|
|
||||||
|
|
||||||
|
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
@ -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()
|
||||||
|
@ -50,22 +50,20 @@ 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)
|
|
||||||
|
|
||||||
for routern in range(1, 5):
|
def build_topo(tgen):
|
||||||
tgen.add_router("r{}".format(routern))
|
for routern in range(1, 5):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s1")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
switch.add_link(tgen.gears["r4"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -41,20 +41,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -41,20 +41,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -44,20 +44,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -43,20 +43,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -41,20 +41,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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,32 +34,27 @@ 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):
|
for routern in range(1, 5):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 5):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
switch.add_link(tgen.gears["r4"])
|
||||||
switch = tgen.add_switch("s2")
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
switch.add_link(tgen.gears["r4"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -52,20 +52,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -54,21 +54,19 @@ 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)
|
|
||||||
|
|
||||||
for routern in range(1, 4):
|
def build_topo(tgen):
|
||||||
tgen.add_router("r{}".format(routern))
|
for routern in range(1, 4):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s1")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -60,31 +60,29 @@ 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)
|
|
||||||
|
|
||||||
for routern in range(1, 7):
|
def build_topo(tgen):
|
||||||
tgen.add_router("r{}".format(routern))
|
for routern in range(1, 7):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
# Scenario 1.
|
# Scenario 1.
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s1")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
# Scenario 2.
|
# Scenario 2.
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
switch.add_link(tgen.gears["r4"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
# Scenario 3.
|
# Scenario 3.
|
||||||
switch = tgen.add_switch("s3")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["r5"])
|
switch.add_link(tgen.gears["r5"])
|
||||||
switch.add_link(tgen.gears["r6"])
|
switch.add_link(tgen.gears["r6"])
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -58,32 +58,26 @@ total_ebgp_peers = 20
|
|||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
|
||||||
class BGPECMPTopo1(Topo):
|
def build_topo(tgen):
|
||||||
"BGP ECMP Topology 1"
|
router = tgen.add_router("r1")
|
||||||
|
|
||||||
def build(self, **_opts):
|
# Setup Switches - 1 switch per 5 peering routers
|
||||||
tgen = get_topogen(self)
|
for swNum in range(1, (total_ebgp_peers + 4) // 5 + 1):
|
||||||
|
switch = tgen.add_switch("s{}".format(swNum))
|
||||||
|
switch.add_link(router)
|
||||||
|
|
||||||
# Create the BGP router
|
# Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
|
||||||
router = tgen.add_router("r1")
|
for peerNum in range(1, total_ebgp_peers + 1):
|
||||||
|
swNum = (peerNum - 1) // 5 + 1
|
||||||
|
|
||||||
# Setup Switches - 1 switch per 5 peering routers
|
peer_ip = "10.0.{}.{}".format(swNum, peerNum + 100)
|
||||||
for swNum in range(1, (total_ebgp_peers + 4) / 5 + 1):
|
peer_route = "via 10.0.{}.1".format(swNum)
|
||||||
switch = tgen.add_switch("s{}".format(swNum))
|
peer = tgen.add_exabgp_peer(
|
||||||
switch.add_link(router)
|
"peer{}".format(peerNum), ip=peer_ip, defaultRoute=peer_route
|
||||||
|
)
|
||||||
|
|
||||||
# Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
|
switch = tgen.gears["s{}".format(swNum)]
|
||||||
for peerNum in range(1, total_ebgp_peers + 1):
|
switch.add_link(peer)
|
||||||
swNum = (peerNum - 1) / 5 + 1
|
|
||||||
|
|
||||||
peer_ip = "10.0.{}.{}".format(swNum, peerNum + 100)
|
|
||||||
peer_route = "via 10.0.{}.1".format(swNum)
|
|
||||||
peer = tgen.add_exabgp_peer(
|
|
||||||
"peer{}".format(peerNum), ip=peer_ip, defaultRoute=peer_route
|
|
||||||
)
|
|
||||||
|
|
||||||
switch = tgen.gears["s{}".format(swNum)]
|
|
||||||
switch.add_link(peer)
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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"
|
||||||
|
@ -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,110 +71,105 @@ 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):
|
tgen.add_router("spine1")
|
||||||
"Build function"
|
tgen.add_router("spine2")
|
||||||
|
tgen.add_router("torm11")
|
||||||
|
tgen.add_router("torm12")
|
||||||
|
tgen.add_router("torm21")
|
||||||
|
tgen.add_router("torm22")
|
||||||
|
tgen.add_router("hostd11")
|
||||||
|
tgen.add_router("hostd12")
|
||||||
|
tgen.add_router("hostd21")
|
||||||
|
tgen.add_router("hostd22")
|
||||||
|
|
||||||
tgen = get_topogen(self)
|
# On main router
|
||||||
|
# First switch is for a dummy interface (for local network)
|
||||||
|
|
||||||
tgen.add_router("spine1")
|
##################### spine1 ########################
|
||||||
tgen.add_router("spine2")
|
# spine1-eth0 is connected to torm11-eth0
|
||||||
tgen.add_router("torm11")
|
switch = tgen.add_switch("sw1")
|
||||||
tgen.add_router("torm12")
|
switch.add_link(tgen.gears["spine1"])
|
||||||
tgen.add_router("torm21")
|
switch.add_link(tgen.gears["torm11"])
|
||||||
tgen.add_router("torm22")
|
|
||||||
tgen.add_router("hostd11")
|
|
||||||
tgen.add_router("hostd12")
|
|
||||||
tgen.add_router("hostd21")
|
|
||||||
tgen.add_router("hostd22")
|
|
||||||
|
|
||||||
# On main router
|
# spine1-eth1 is connected to torm12-eth0
|
||||||
# First switch is for a dummy interface (for local network)
|
switch = tgen.add_switch("sw2")
|
||||||
|
switch.add_link(tgen.gears["spine1"])
|
||||||
|
switch.add_link(tgen.gears["torm12"])
|
||||||
|
|
||||||
##################### spine1 ########################
|
# spine1-eth2 is connected to torm21-eth0
|
||||||
# spine1-eth0 is connected to torm11-eth0
|
switch = tgen.add_switch("sw3")
|
||||||
switch = tgen.add_switch("sw1")
|
switch.add_link(tgen.gears["spine1"])
|
||||||
switch.add_link(tgen.gears["spine1"])
|
switch.add_link(tgen.gears["torm21"])
|
||||||
switch.add_link(tgen.gears["torm11"])
|
|
||||||
|
|
||||||
# spine1-eth1 is connected to torm12-eth0
|
# spine1-eth3 is connected to torm22-eth0
|
||||||
switch = tgen.add_switch("sw2")
|
switch = tgen.add_switch("sw4")
|
||||||
switch.add_link(tgen.gears["spine1"])
|
switch.add_link(tgen.gears["spine1"])
|
||||||
switch.add_link(tgen.gears["torm12"])
|
switch.add_link(tgen.gears["torm22"])
|
||||||
|
|
||||||
# spine1-eth2 is connected to torm21-eth0
|
##################### spine2 ########################
|
||||||
switch = tgen.add_switch("sw3")
|
# spine2-eth0 is connected to torm11-eth1
|
||||||
switch.add_link(tgen.gears["spine1"])
|
switch = tgen.add_switch("sw5")
|
||||||
switch.add_link(tgen.gears["torm21"])
|
switch.add_link(tgen.gears["spine2"])
|
||||||
|
switch.add_link(tgen.gears["torm11"])
|
||||||
|
|
||||||
# spine1-eth3 is connected to torm22-eth0
|
# spine2-eth1 is connected to torm12-eth1
|
||||||
switch = tgen.add_switch("sw4")
|
switch = tgen.add_switch("sw6")
|
||||||
switch.add_link(tgen.gears["spine1"])
|
switch.add_link(tgen.gears["spine2"])
|
||||||
switch.add_link(tgen.gears["torm22"])
|
switch.add_link(tgen.gears["torm12"])
|
||||||
|
|
||||||
##################### spine2 ########################
|
# spine2-eth2 is connected to torm21-eth1
|
||||||
# spine2-eth0 is connected to torm11-eth1
|
switch = tgen.add_switch("sw7")
|
||||||
switch = tgen.add_switch("sw5")
|
switch.add_link(tgen.gears["spine2"])
|
||||||
switch.add_link(tgen.gears["spine2"])
|
switch.add_link(tgen.gears["torm21"])
|
||||||
switch.add_link(tgen.gears["torm11"])
|
|
||||||
|
|
||||||
# spine2-eth1 is connected to torm12-eth1
|
# spine2-eth3 is connected to torm22-eth1
|
||||||
switch = tgen.add_switch("sw6")
|
switch = tgen.add_switch("sw8")
|
||||||
switch.add_link(tgen.gears["spine2"])
|
switch.add_link(tgen.gears["spine2"])
|
||||||
switch.add_link(tgen.gears["torm12"])
|
switch.add_link(tgen.gears["torm22"])
|
||||||
|
|
||||||
# spine2-eth2 is connected to torm21-eth1
|
##################### torm11 ########################
|
||||||
switch = tgen.add_switch("sw7")
|
# torm11-eth2 is connected to hostd11-eth0
|
||||||
switch.add_link(tgen.gears["spine2"])
|
switch = tgen.add_switch("sw9")
|
||||||
switch.add_link(tgen.gears["torm21"])
|
switch.add_link(tgen.gears["torm11"])
|
||||||
|
switch.add_link(tgen.gears["hostd11"])
|
||||||
|
|
||||||
# spine2-eth3 is connected to torm22-eth1
|
# torm11-eth3 is connected to hostd12-eth0
|
||||||
switch = tgen.add_switch("sw8")
|
switch = tgen.add_switch("sw10")
|
||||||
switch.add_link(tgen.gears["spine2"])
|
switch.add_link(tgen.gears["torm11"])
|
||||||
switch.add_link(tgen.gears["torm22"])
|
switch.add_link(tgen.gears["hostd12"])
|
||||||
|
|
||||||
##################### torm11 ########################
|
##################### torm12 ########################
|
||||||
# torm11-eth2 is connected to hostd11-eth0
|
# torm12-eth2 is connected to hostd11-eth1
|
||||||
switch = tgen.add_switch("sw9")
|
switch = tgen.add_switch("sw11")
|
||||||
switch.add_link(tgen.gears["torm11"])
|
switch.add_link(tgen.gears["torm12"])
|
||||||
switch.add_link(tgen.gears["hostd11"])
|
switch.add_link(tgen.gears["hostd11"])
|
||||||
|
|
||||||
# torm11-eth3 is connected to hostd12-eth0
|
# torm12-eth3 is connected to hostd12-eth1
|
||||||
switch = tgen.add_switch("sw10")
|
switch = tgen.add_switch("sw12")
|
||||||
switch.add_link(tgen.gears["torm11"])
|
switch.add_link(tgen.gears["torm12"])
|
||||||
switch.add_link(tgen.gears["hostd12"])
|
switch.add_link(tgen.gears["hostd12"])
|
||||||
|
|
||||||
##################### torm12 ########################
|
##################### torm21 ########################
|
||||||
# torm12-eth2 is connected to hostd11-eth1
|
# torm21-eth2 is connected to hostd21-eth0
|
||||||
switch = tgen.add_switch("sw11")
|
switch = tgen.add_switch("sw13")
|
||||||
switch.add_link(tgen.gears["torm12"])
|
switch.add_link(tgen.gears["torm21"])
|
||||||
switch.add_link(tgen.gears["hostd11"])
|
switch.add_link(tgen.gears["hostd21"])
|
||||||
|
|
||||||
# torm12-eth3 is connected to hostd12-eth1
|
# torm21-eth3 is connected to hostd22-eth0
|
||||||
switch = tgen.add_switch("sw12")
|
switch = tgen.add_switch("sw14")
|
||||||
switch.add_link(tgen.gears["torm12"])
|
switch.add_link(tgen.gears["torm21"])
|
||||||
switch.add_link(tgen.gears["hostd12"])
|
switch.add_link(tgen.gears["hostd22"])
|
||||||
|
|
||||||
##################### torm21 ########################
|
##################### torm22 ########################
|
||||||
# torm21-eth2 is connected to hostd21-eth0
|
# torm22-eth2 is connected to hostd21-eth1
|
||||||
switch = tgen.add_switch("sw13")
|
switch = tgen.add_switch("sw15")
|
||||||
switch.add_link(tgen.gears["torm21"])
|
switch.add_link(tgen.gears["torm22"])
|
||||||
switch.add_link(tgen.gears["hostd21"])
|
switch.add_link(tgen.gears["hostd21"])
|
||||||
|
|
||||||
# torm21-eth3 is connected to hostd22-eth0
|
# torm22-eth3 is connected to hostd22-eth1
|
||||||
switch = tgen.add_switch("sw14")
|
switch = tgen.add_switch("sw16")
|
||||||
switch.add_link(tgen.gears["torm21"])
|
switch.add_link(tgen.gears["torm22"])
|
||||||
switch.add_link(tgen.gears["hostd22"])
|
switch.add_link(tgen.gears["hostd22"])
|
||||||
|
|
||||||
##################### torm22 ########################
|
|
||||||
# torm22-eth2 is connected to hostd21-eth1
|
|
||||||
switch = tgen.add_switch("sw15")
|
|
||||||
switch.add_link(tgen.gears["torm22"])
|
|
||||||
switch.add_link(tgen.gears["hostd21"])
|
|
||||||
|
|
||||||
# torm22-eth3 is connected to hostd22-eth1
|
|
||||||
switch = tgen.add_switch("sw16")
|
|
||||||
switch.add_link(tgen.gears["torm22"])
|
|
||||||
switch.add_link(tgen.gears["hostd22"])
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -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()
|
||||||
|
@ -88,29 +88,23 @@ 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"""
|
# This function only purpose is to define allocation and relationship
|
||||||
|
# between routers and add links.
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# Create routers
|
||||||
"""Build function"""
|
for pe in PES:
|
||||||
tgen = get_topogen(self)
|
tgen.add_router(pe)
|
||||||
|
for host in HOSTS:
|
||||||
|
tgen.add_router(host)
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
krel = platform.release()
|
||||||
# between routers and add links.
|
logger.info('Kernel version ' + krel)
|
||||||
|
|
||||||
# Create routers
|
#Add links
|
||||||
for pe in PES:
|
tgen.add_link(tgen.gears['PE1'], tgen.gears['PE2'], 'PE1-eth0', 'PE2-eth0')
|
||||||
tgen.add_router(pe)
|
tgen.add_link(tgen.gears['PE1'], tgen.gears['host1'], 'PE1-eth1', 'host1-eth0')
|
||||||
for host in HOSTS:
|
tgen.add_link(tgen.gears['PE2'], tgen.gears['host2'], 'PE2-eth1', 'host2-eth0')
|
||||||
tgen.add_router(host)
|
|
||||||
|
|
||||||
krel = platform.release()
|
|
||||||
logger.info('Kernel version ' + krel)
|
|
||||||
|
|
||||||
#Add links
|
|
||||||
tgen.add_link(tgen.gears['PE1'], tgen.gears['PE2'], 'PE1-eth0', 'PE2-eth0')
|
|
||||||
tgen.add_link(tgen.gears['PE1'], tgen.gears['host1'], 'PE1-eth1', 'host1-eth0')
|
|
||||||
tgen.add_link(tgen.gears['PE2'], tgen.gears['host2'], 'PE2-eth1', 'host2-eth0')
|
|
||||||
|
|
||||||
|
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
@ -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()
|
||||||
|
@ -48,31 +48,28 @@ 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")
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s1")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s3")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -49,49 +49,45 @@ 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"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# This function only purpose is to define allocation and relationship
|
||||||
"Build function"
|
# between routers, switches and hosts.
|
||||||
tgen = get_topogen(self)
|
#
|
||||||
|
#
|
||||||
|
# Create routers
|
||||||
|
tgen.add_router("P1")
|
||||||
|
tgen.add_router("PE1")
|
||||||
|
tgen.add_router("PE2")
|
||||||
|
tgen.add_router("host1")
|
||||||
|
tgen.add_router("host2")
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
# Host1-PE1
|
||||||
# between routers, switches and hosts.
|
switch = tgen.add_switch("s1")
|
||||||
#
|
switch.add_link(tgen.gears["host1"])
|
||||||
#
|
switch.add_link(tgen.gears["PE1"])
|
||||||
# Create routers
|
|
||||||
tgen.add_router("P1")
|
|
||||||
tgen.add_router("PE1")
|
|
||||||
tgen.add_router("PE2")
|
|
||||||
tgen.add_router("host1")
|
|
||||||
tgen.add_router("host2")
|
|
||||||
|
|
||||||
# Host1-PE1
|
# PE1-P1
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["host1"])
|
switch.add_link(tgen.gears["PE1"])
|
||||||
switch.add_link(tgen.gears["PE1"])
|
switch.add_link(tgen.gears["P1"])
|
||||||
|
|
||||||
# PE1-P1
|
# P1-PE2
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["PE1"])
|
switch.add_link(tgen.gears["P1"])
|
||||||
switch.add_link(tgen.gears["P1"])
|
switch.add_link(tgen.gears["PE2"])
|
||||||
|
|
||||||
# P1-PE2
|
# PE2-host2
|
||||||
switch = tgen.add_switch("s3")
|
switch = tgen.add_switch("s4")
|
||||||
switch.add_link(tgen.gears["P1"])
|
switch.add_link(tgen.gears["PE2"])
|
||||||
switch.add_link(tgen.gears["PE2"])
|
switch.add_link(tgen.gears["host2"])
|
||||||
|
|
||||||
# PE2-host2
|
|
||||||
switch = tgen.add_switch("s4")
|
|
||||||
switch.add_link(tgen.gears["PE2"])
|
|
||||||
switch.add_link(tgen.gears["host2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
|
@ -56,40 +56,48 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
|
|||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
|
||||||
class BGPFeaturesTopo1(Topo):
|
def build_topo(tgen):
|
||||||
"BGP Features Topology 1"
|
for rtrNum in range(1, 6):
|
||||||
|
tgen.add_router("r{}".format(rtrNum))
|
||||||
|
|
||||||
def build(self, **_opts):
|
# create ExaBGP peers
|
||||||
tgen = get_topogen(self)
|
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",
|
||||||
|
)
|
||||||
|
|
||||||
# Create the routers
|
# Setup Switches and connections
|
||||||
for rtrNum in range(1, 6):
|
for swNum in range(1, 11):
|
||||||
tgen.add_router("r{}".format(rtrNum))
|
tgen.add_switch("sw{}".format(swNum))
|
||||||
|
|
||||||
# Setup Switches and connections
|
# Add connections to stub switches
|
||||||
for swNum in range(1, 11):
|
tgen.gears["r1"].add_link(tgen.gears["sw6"])
|
||||||
tgen.add_switch("sw{}".format(swNum))
|
tgen.gears["r2"].add_link(tgen.gears["sw7"])
|
||||||
|
tgen.gears["r3"].add_link(tgen.gears["sw8"])
|
||||||
|
tgen.gears["r4"].add_link(tgen.gears["sw9"])
|
||||||
|
tgen.gears["r5"].add_link(tgen.gears["sw10"])
|
||||||
|
|
||||||
# Add connections to stub switches
|
# Add connections to R1-R2-R3 core
|
||||||
tgen.gears["r1"].add_link(tgen.gears["sw6"])
|
tgen.gears["r1"].add_link(tgen.gears["sw1"])
|
||||||
tgen.gears["r2"].add_link(tgen.gears["sw7"])
|
tgen.gears["r1"].add_link(tgen.gears["sw3"])
|
||||||
tgen.gears["r3"].add_link(tgen.gears["sw8"])
|
tgen.gears["r2"].add_link(tgen.gears["sw1"])
|
||||||
tgen.gears["r4"].add_link(tgen.gears["sw9"])
|
tgen.gears["r2"].add_link(tgen.gears["sw2"])
|
||||||
tgen.gears["r5"].add_link(tgen.gears["sw10"])
|
tgen.gears["r3"].add_link(tgen.gears["sw2"])
|
||||||
|
tgen.gears["r3"].add_link(tgen.gears["sw3"])
|
||||||
|
|
||||||
# Add connections to R1-R2-R3 core
|
# Add connections to external R4/R5 Routers
|
||||||
tgen.gears["r1"].add_link(tgen.gears["sw1"])
|
tgen.gears["r1"].add_link(tgen.gears["sw4"])
|
||||||
tgen.gears["r1"].add_link(tgen.gears["sw3"])
|
tgen.gears["r4"].add_link(tgen.gears["sw4"])
|
||||||
tgen.gears["r2"].add_link(tgen.gears["sw1"])
|
tgen.gears["r2"].add_link(tgen.gears["sw5"])
|
||||||
tgen.gears["r2"].add_link(tgen.gears["sw2"])
|
tgen.gears["r5"].add_link(tgen.gears["sw5"])
|
||||||
tgen.gears["r3"].add_link(tgen.gears["sw2"])
|
|
||||||
tgen.gears["r3"].add_link(tgen.gears["sw3"])
|
|
||||||
|
|
||||||
# Add connections to external R4/R5 Routers
|
# Add ExaBGP peers to sw4
|
||||||
tgen.gears["r1"].add_link(tgen.gears["sw4"])
|
tgen.gears["peer1"].add_link(tgen.gears["sw4"])
|
||||||
tgen.gears["r4"].add_link(tgen.gears["sw4"])
|
tgen.gears["peer2"].add_link(tgen.gears["sw4"])
|
||||||
tgen.gears["r2"].add_link(tgen.gears["sw5"])
|
tgen.gears["peer3"].add_link(tgen.gears["sw4"])
|
||||||
tgen.gears["r5"].add_link(tgen.gears["sw5"])
|
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
|
||||||
|
@ -82,24 +82,18 @@ pytestmark = [pytest.mark.bgpd]
|
|||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
|
||||||
class BGPFLOWSPECTopo1(Topo):
|
def build_topo(tgen):
|
||||||
"BGP EBGP Flowspec Topology 1"
|
tgen.add_router("r1")
|
||||||
|
|
||||||
def build(self, **_opts):
|
# Setup Control Path Switch 1. r1-eth0
|
||||||
tgen = get_topogen(self)
|
switch = tgen.add_switch("s1")
|
||||||
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
|
||||||
# Setup Routers
|
## Add eBGP ExaBGP neighbors
|
||||||
tgen.add_router("r1")
|
peer_ip = "10.0.1.101" ## peer
|
||||||
|
peer_route = "via 10.0.1.1" ## router
|
||||||
# Setup Control Path Switch 1. r1-eth0
|
peer = tgen.add_exabgp_peer("peer1", ip=peer_ip, defaultRoute=peer_route)
|
||||||
switch = tgen.add_switch("s1")
|
switch.add_link(peer)
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
|
|
||||||
## Add eBGP ExaBGP neighbors
|
|
||||||
peer_ip = "10.0.1.101" ## peer
|
|
||||||
peer_route = "via 10.0.1.1" ## router
|
|
||||||
peer = tgen.add_exabgp_peer("peer1", ip=peer_ip, defaultRoute=peer_route)
|
|
||||||
switch.add_link(peer)
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -78,28 +78,25 @@ 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):
|
for routern in range(1, 6):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 6):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s3")
|
switch = tgen.add_switch("s4")
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r4"])
|
switch.add_link(tgen.gears["r5"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s4")
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r5"])
|
|
||||||
|
|
||||||
|
|
||||||
def _run_cmd_and_check(router, cmd, results_file, retries=100, intvl=0.5):
|
def _run_cmd_and_check(router, cmd, results_file, retries=100, intvl=0.5):
|
||||||
@ -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()
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -49,25 +49,21 @@ from lib.micronet_compat import Topo
|
|||||||
pytestmark = [pytest.mark.bgpd]
|
pytestmark = [pytest.mark.bgpd]
|
||||||
|
|
||||||
|
|
||||||
class BGPIPV6RTADVTopo(Topo):
|
def build_topo(tgen):
|
||||||
"Test topology builder"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# Create 2 routers.
|
||||||
"Build function"
|
tgen.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r2")
|
||||||
|
|
||||||
# Create 2 routers.
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r1")
|
switch.add_link(tgen.gears["r1"])
|
||||||
tgen.add_router("r2")
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -94,48 +94,44 @@ 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"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# This function only purpose is to define allocation and relationship
|
||||||
"Build function"
|
# between routers, switches and hosts.
|
||||||
tgen = get_topogen(self)
|
#
|
||||||
|
# Create P/PE routers
|
||||||
|
tgen.add_router("r1")
|
||||||
|
# check for mpls
|
||||||
|
if tgen.hasmpls != True:
|
||||||
|
logger.info("MPLS not available, tests will be skipped")
|
||||||
|
return
|
||||||
|
for routern in range(2, 5):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
# Create CE routers
|
||||||
|
for routern in range(1, 4):
|
||||||
|
tgen.add_router("ce{}".format(routern))
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
# CE/PE links
|
||||||
# between routers, switches and hosts.
|
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
|
||||||
#
|
tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
|
||||||
# Create P/PE routers
|
tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
|
||||||
tgen.add_router("r1")
|
|
||||||
# check for mpls
|
|
||||||
if tgen.hasmpls != True:
|
|
||||||
logger.info("MPLS not available, tests will be skipped")
|
|
||||||
return
|
|
||||||
for routern in range(2, 5):
|
|
||||||
tgen.add_router("r{}".format(routern))
|
|
||||||
# Create CE routers
|
|
||||||
for routern in range(1, 4):
|
|
||||||
tgen.add_router("ce{}".format(routern))
|
|
||||||
|
|
||||||
# CE/PE links
|
# Create a switch with just one router connected to it to simulate a
|
||||||
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
|
# empty network.
|
||||||
tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
|
switch = {}
|
||||||
tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
|
switch[0] = tgen.add_switch("sw0")
|
||||||
|
switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
|
||||||
|
switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
|
||||||
|
|
||||||
# Create a switch with just one router connected to it to simulate a
|
switch[1] = tgen.add_switch("sw1")
|
||||||
# empty network.
|
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
|
||||||
switch = {}
|
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
|
||||||
switch[0] = tgen.add_switch("sw0")
|
switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
|
||||||
switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
|
|
||||||
switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
|
|
||||||
|
|
||||||
switch[1] = tgen.add_switch("sw1")
|
switch[1] = tgen.add_switch("sw2")
|
||||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
|
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
||||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
|
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
||||||
switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
|
|
||||||
|
|
||||||
switch[1] = tgen.add_switch("sw2")
|
|
||||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
|
||||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
|
||||||
|
|
||||||
|
|
||||||
def ltemplatePreRouterStartHook():
|
def ltemplatePreRouterStartHook():
|
||||||
|
@ -95,54 +95,50 @@ 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"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# This function only purpose is to define allocation and relationship
|
||||||
"Build function"
|
# between routers, switches and hosts.
|
||||||
tgen = get_topogen(self)
|
#
|
||||||
|
# Create P/PE routers
|
||||||
|
# check for mpls
|
||||||
|
tgen.add_router("r1")
|
||||||
|
if tgen.hasmpls != True:
|
||||||
|
logger.info("MPLS not available, tests will be skipped")
|
||||||
|
return
|
||||||
|
mach = platform.machine()
|
||||||
|
krel = platform.release()
|
||||||
|
if mach[:1] == "a" and topotest.version_cmp(krel, "4.11") < 0:
|
||||||
|
logger.info("Need Kernel version 4.11 to run on arm processor")
|
||||||
|
return
|
||||||
|
for routern in range(2, 5):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
# Create CE routers
|
||||||
|
for routern in range(1, 5):
|
||||||
|
tgen.add_router("ce{}".format(routern))
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
# CE/PE links
|
||||||
# between routers, switches and hosts.
|
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
|
||||||
#
|
tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
|
||||||
# Create P/PE routers
|
tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
|
||||||
# check for mpls
|
tgen.add_link(tgen.gears["ce4"], tgen.gears["r4"], "ce4-eth0", "r4-eth5")
|
||||||
tgen.add_router("r1")
|
|
||||||
if tgen.hasmpls != True:
|
|
||||||
logger.info("MPLS not available, tests will be skipped")
|
|
||||||
return
|
|
||||||
mach = platform.machine()
|
|
||||||
krel = platform.release()
|
|
||||||
if mach[:1] == "a" and topotest.version_cmp(krel, "4.11") < 0:
|
|
||||||
logger.info("Need Kernel version 4.11 to run on arm processor")
|
|
||||||
return
|
|
||||||
for routern in range(2, 5):
|
|
||||||
tgen.add_router("r{}".format(routern))
|
|
||||||
# Create CE routers
|
|
||||||
for routern in range(1, 5):
|
|
||||||
tgen.add_router("ce{}".format(routern))
|
|
||||||
|
|
||||||
# CE/PE links
|
# Create a switch with just one router connected to it to simulate a
|
||||||
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
|
# empty network.
|
||||||
tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
|
switch = {}
|
||||||
tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
|
switch[0] = tgen.add_switch("sw0")
|
||||||
tgen.add_link(tgen.gears["ce4"], tgen.gears["r4"], "ce4-eth0", "r4-eth5")
|
switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
|
||||||
|
switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
|
||||||
|
|
||||||
# Create a switch with just one router connected to it to simulate a
|
switch[1] = tgen.add_switch("sw1")
|
||||||
# empty network.
|
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
|
||||||
switch = {}
|
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
|
||||||
switch[0] = tgen.add_switch("sw0")
|
switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
|
||||||
switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
|
|
||||||
switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
|
|
||||||
|
|
||||||
switch[1] = tgen.add_switch("sw1")
|
switch[1] = tgen.add_switch("sw2")
|
||||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
|
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
||||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
|
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
||||||
switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
|
|
||||||
|
|
||||||
switch[1] = tgen.add_switch("sw2")
|
|
||||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
|
||||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
|
||||||
|
|
||||||
|
|
||||||
def ltemplatePreRouterStartHook():
|
def ltemplatePreRouterStartHook():
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -66,62 +66,57 @@ 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):
|
||||||
|
"Build function"
|
||||||
|
|
||||||
class BgpLinkBwTopo(Topo):
|
# Create 10 routers - 1 super-spine, 2 spines, 3 leafs
|
||||||
"Test topology builder"
|
# and 4 servers
|
||||||
|
routers = {}
|
||||||
|
for i in range(1, 11):
|
||||||
|
routers[i] = tgen.add_router("r{}".format(i))
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# Create 13 "switches" - to interconnect the above routers
|
||||||
"Build function"
|
switches = {}
|
||||||
tgen = get_topogen(self)
|
for i in range(1, 14):
|
||||||
|
switches[i] = tgen.add_switch("s{}".format(i))
|
||||||
|
|
||||||
# Create 10 routers - 1 super-spine, 2 spines, 3 leafs
|
# Interconnect R1 (super-spine) to R2 and R3 (the two spines)
|
||||||
# and 4 servers
|
switches[1].add_link(tgen.gears["r1"])
|
||||||
routers = {}
|
switches[1].add_link(tgen.gears["r2"])
|
||||||
for i in range(1, 11):
|
switches[2].add_link(tgen.gears["r1"])
|
||||||
routers[i] = tgen.add_router("r{}".format(i))
|
switches[2].add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
# Create 13 "switches" - to interconnect the above routers
|
# Interconnect R2 (spine in pod-1) to R4 and R5 (the associated
|
||||||
switches = {}
|
# leaf switches)
|
||||||
for i in range(1, 14):
|
switches[3].add_link(tgen.gears["r2"])
|
||||||
switches[i] = tgen.add_switch("s{}".format(i))
|
switches[3].add_link(tgen.gears["r4"])
|
||||||
|
switches[4].add_link(tgen.gears["r2"])
|
||||||
|
switches[4].add_link(tgen.gears["r5"])
|
||||||
|
|
||||||
# Interconnect R1 (super-spine) to R2 and R3 (the two spines)
|
# Interconnect R3 (spine in pod-2) to R6 (associated leaf)
|
||||||
switches[1].add_link(tgen.gears["r1"])
|
switches[5].add_link(tgen.gears["r3"])
|
||||||
switches[1].add_link(tgen.gears["r2"])
|
switches[5].add_link(tgen.gears["r6"])
|
||||||
switches[2].add_link(tgen.gears["r1"])
|
|
||||||
switches[2].add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
# Interconnect R2 (spine in pod-1) to R4 and R5 (the associated
|
# Interconnect leaf switches to servers
|
||||||
# leaf switches)
|
switches[6].add_link(tgen.gears["r4"])
|
||||||
switches[3].add_link(tgen.gears["r2"])
|
switches[6].add_link(tgen.gears["r7"])
|
||||||
switches[3].add_link(tgen.gears["r4"])
|
switches[7].add_link(tgen.gears["r4"])
|
||||||
switches[4].add_link(tgen.gears["r2"])
|
switches[7].add_link(tgen.gears["r8"])
|
||||||
switches[4].add_link(tgen.gears["r5"])
|
switches[8].add_link(tgen.gears["r5"])
|
||||||
|
switches[8].add_link(tgen.gears["r9"])
|
||||||
|
switches[9].add_link(tgen.gears["r6"])
|
||||||
|
switches[9].add_link(tgen.gears["r10"])
|
||||||
|
|
||||||
# Interconnect R3 (spine in pod-2) to R6 (associated leaf)
|
# Create empty networks for the servers
|
||||||
switches[5].add_link(tgen.gears["r3"])
|
switches[10].add_link(tgen.gears["r7"])
|
||||||
switches[5].add_link(tgen.gears["r6"])
|
switches[11].add_link(tgen.gears["r8"])
|
||||||
|
switches[12].add_link(tgen.gears["r9"])
|
||||||
# Interconnect leaf switches to servers
|
switches[13].add_link(tgen.gears["r10"])
|
||||||
switches[6].add_link(tgen.gears["r4"])
|
|
||||||
switches[6].add_link(tgen.gears["r7"])
|
|
||||||
switches[7].add_link(tgen.gears["r4"])
|
|
||||||
switches[7].add_link(tgen.gears["r8"])
|
|
||||||
switches[8].add_link(tgen.gears["r5"])
|
|
||||||
switches[8].add_link(tgen.gears["r9"])
|
|
||||||
switches[9].add_link(tgen.gears["r6"])
|
|
||||||
switches[9].add_link(tgen.gears["r10"])
|
|
||||||
|
|
||||||
# Create empty networks for the servers
|
|
||||||
switches[10].add_link(tgen.gears["r7"])
|
|
||||||
switches[11].add_link(tgen.gears["r8"])
|
|
||||||
switches[12].add_link(tgen.gears["r9"])
|
|
||||||
switches[13].add_link(tgen.gears["r10"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -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.
|
||||||
|
@ -46,24 +46,21 @@ 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):
|
for routern in range(1, 5):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 5):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
switch.add_link(tgen.gears["r4"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -62,37 +62,33 @@ pytestmark = [pytest.mark.bgpd]
|
|||||||
# +-----+ +-----+ +-----+
|
# +-----+ +-----+ +-----+
|
||||||
|
|
||||||
|
|
||||||
class TemplateTopo(Topo):
|
def build_topo(tgen):
|
||||||
"Test topology builder"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# This function only purpose is to define allocation and relationship
|
||||||
"Build function"
|
# between routers, switches and hosts.
|
||||||
tgen = get_topogen(self)
|
#
|
||||||
|
#
|
||||||
|
# Create routers
|
||||||
|
tgen.add_router("R1")
|
||||||
|
tgen.add_router("R2")
|
||||||
|
tgen.add_router("R3")
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
# R1-R2
|
||||||
# between routers, switches and hosts.
|
switch = tgen.add_switch("s1")
|
||||||
#
|
switch.add_link(tgen.gears["R1"])
|
||||||
#
|
switch.add_link(tgen.gears["R2"])
|
||||||
# Create routers
|
|
||||||
tgen.add_router("R1")
|
|
||||||
tgen.add_router("R2")
|
|
||||||
tgen.add_router("R3")
|
|
||||||
|
|
||||||
# R1-R2
|
# R2-R3
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["R1"])
|
switch.add_link(tgen.gears["R2"])
|
||||||
switch.add_link(tgen.gears["R2"])
|
switch.add_link(tgen.gears["R3"])
|
||||||
|
|
||||||
# R2-R3
|
|
||||||
switch = tgen.add_switch("s2")
|
|
||||||
switch.add_link(tgen.gears["R2"])
|
|
||||||
switch.add_link(tgen.gears["R3"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
|
@ -50,20 +50,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -46,20 +46,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -41,20 +41,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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"
|
# Setup Routers
|
||||||
|
router = tgen.add_router("r1")
|
||||||
|
|
||||||
def build(self, **_opts):
|
# Setup Provider BGP peers
|
||||||
|
peer = {}
|
||||||
|
for i in range(1, 9):
|
||||||
|
peer[i] = tgen.add_exabgp_peer(
|
||||||
|
"peer%s" % i,
|
||||||
|
ip="172.16.1.%s/24" % i,
|
||||||
|
defaultRoute="via 172.16.1.254"
|
||||||
|
)
|
||||||
|
|
||||||
exabgpPrivateDirs = ["/etc/exabgp", "/var/run/exabgp", "/var/log"]
|
# First switch is for a dummy interface (for local network)
|
||||||
|
switch = tgen.add_switch("sw0")
|
||||||
|
switch.add_link(router, nodeif="r1-stub")
|
||||||
|
|
||||||
# Setup Routers
|
# Second switch is for connection to all peering routers
|
||||||
router = {}
|
switch = tgen.add_switch("sw1")
|
||||||
for i in range(1, 2):
|
switch.add_link(router, nodeif="r1-eth0")
|
||||||
router[i] = topotest.addRouter(self, "r%s" % i)
|
for j in range(1, 9):
|
||||||
|
switch.add_link(peer[j], nodeif="peer%s-eth0" % j)
|
||||||
# Setup Provider BGP peers
|
|
||||||
peer = {}
|
|
||||||
for i in range(1, 9):
|
|
||||||
peer[i] = self.addHost(
|
|
||||||
"peer%s" % i,
|
|
||||||
ip="172.16.1.%s/24" % i,
|
|
||||||
defaultRoute="via 172.16.1.254",
|
|
||||||
privateDirs=exabgpPrivateDirs,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup Switches
|
|
||||||
switch = {}
|
|
||||||
# First switch is for a dummy interface (for local network)
|
|
||||||
switch[0] = self.addSwitch("sw0")
|
|
||||||
self.addLink(switch[0], router[1], intfName2="r1-stub")
|
|
||||||
# Second switch is for connection to all peering routers
|
|
||||||
switch[1] = self.addSwitch("sw1")
|
|
||||||
self.addLink(switch[1], router[1], intfName2="r1-eth0")
|
|
||||||
for j in range(1, 9):
|
|
||||||
self.addLink(switch[1], peer[j], intfName2="peer%s-eth0" % j)
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -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__":
|
||||||
|
@ -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
|
||||||
|
@ -42,21 +42,18 @@ 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):
|
for routern in range(1, 4):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 4):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
switch.add_link(tgen.gears["r3"])
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -76,32 +76,30 @@ 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
|
||||||
tgen.add_router("r2")
|
tgen.add_router("r2")
|
||||||
|
|
||||||
# Set up peers
|
# Set up peers
|
||||||
for peern in range(1, 5):
|
for peern in range(1, 5):
|
||||||
peer = tgen.add_exabgp_peer(
|
peer = tgen.add_exabgp_peer(
|
||||||
"peer{}".format(peern),
|
"peer{}".format(peern),
|
||||||
ip="10.0.{}.2/24".format(peern),
|
ip="10.0.{}.2/24".format(peern),
|
||||||
defaultRoute="via 10.0.{}.1".format(peern),
|
defaultRoute="via 10.0.{}.1".format(peern),
|
||||||
)
|
)
|
||||||
if peern == 2:
|
if peern == 2:
|
||||||
tgen.add_link(tgen.gears["r2"], peer)
|
tgen.add_link(tgen.gears["r2"], peer)
|
||||||
else:
|
else:
|
||||||
tgen.add_link(tgen.gears["r1"], peer)
|
tgen.add_link(tgen.gears["r1"], peer)
|
||||||
tgen.add_link(tgen.gears["r1"], tgen.gears["r2"])
|
tgen.add_link(tgen.gears["r1"], tgen.gears["r2"])
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -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
|
||||||
|
@ -44,26 +44,24 @@ 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):
|
router = tgen.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
switch = tgen.add_switch("s1")
|
||||||
router = tgen.add_router("r1")
|
switch.add_link(router)
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(router)
|
|
||||||
|
|
||||||
switch = tgen.gears["s1"]
|
switch = tgen.gears["s1"]
|
||||||
peer1 = tgen.add_exabgp_peer(
|
peer1 = tgen.add_exabgp_peer(
|
||||||
"peer1", ip="10.0.0.101", defaultRoute="via 10.0.0.1"
|
"peer1", ip="10.0.0.101", defaultRoute="via 10.0.0.1"
|
||||||
)
|
)
|
||||||
peer2 = tgen.add_exabgp_peer(
|
peer2 = tgen.add_exabgp_peer(
|
||||||
"peer2", ip="10.0.0.102", defaultRoute="via 10.0.0.1"
|
"peer2", ip="10.0.0.102", defaultRoute="via 10.0.0.1"
|
||||||
)
|
)
|
||||||
switch.add_link(peer1)
|
switch.add_link(peer1)
|
||||||
switch.add_link(peer2)
|
switch.add_link(peer2)
|
||||||
|
|
||||||
|
|
||||||
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"]
|
||||||
|
@ -44,22 +44,20 @@ 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):
|
router = tgen.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
switch = tgen.add_switch("s1")
|
||||||
router = tgen.add_router("r1")
|
switch.add_link(router)
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(router)
|
|
||||||
|
|
||||||
switch = tgen.gears["s1"]
|
switch = tgen.gears["s1"]
|
||||||
peer1 = tgen.add_exabgp_peer(
|
peer1 = tgen.add_exabgp_peer(
|
||||||
"peer1", ip="10.0.0.101", defaultRoute="via 10.0.0.1"
|
"peer1", ip="10.0.0.101", defaultRoute="via 10.0.0.1"
|
||||||
)
|
)
|
||||||
switch.add_link(peer1)
|
switch.add_link(peer1)
|
||||||
|
|
||||||
|
|
||||||
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"]
|
||||||
|
@ -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
|
||||||
|
@ -53,24 +53,21 @@ 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):
|
for routern in range(1, 4):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 4):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -81,35 +81,31 @@ 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"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# This function only purpose is to define allocation and relationship
|
||||||
"Build function"
|
# between routers, switches and hosts.
|
||||||
tgen = get_topogen(self)
|
#
|
||||||
|
# Create P/PE routers
|
||||||
|
tgen.add_router("r1")
|
||||||
|
for routern in range(2, 5):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
# Create a switch with just one router connected to it to simulate a
|
||||||
|
# empty network.
|
||||||
|
switch = {}
|
||||||
|
switch[0] = tgen.add_switch("sw0")
|
||||||
|
switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
|
||||||
|
switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
switch[1] = tgen.add_switch("sw1")
|
||||||
# between routers, switches and hosts.
|
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
|
||||||
#
|
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
|
||||||
# Create P/PE routers
|
switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
|
||||||
tgen.add_router("r1")
|
|
||||||
for routern in range(2, 5):
|
|
||||||
tgen.add_router("r{}".format(routern))
|
|
||||||
# Create a switch with just one router connected to it to simulate a
|
|
||||||
# empty network.
|
|
||||||
switch = {}
|
|
||||||
switch[0] = tgen.add_switch("sw0")
|
|
||||||
switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
|
|
||||||
switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
|
|
||||||
|
|
||||||
switch[1] = tgen.add_switch("sw1")
|
switch[2] = tgen.add_switch("sw2")
|
||||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
|
switch[2].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
||||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
|
switch[2].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
||||||
switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
|
|
||||||
|
|
||||||
switch[2] = tgen.add_switch("sw2")
|
|
||||||
switch[2].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
|
||||||
switch[2].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
|
||||||
|
|
||||||
|
|
||||||
def ltemplatePreRouterStartHook():
|
def ltemplatePreRouterStartHook():
|
||||||
|
@ -41,25 +41,21 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -49,48 +49,37 @@ 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):
|
||||||
##
|
"Build function"
|
||||||
## Network Topology Definition
|
|
||||||
##
|
|
||||||
#####################################################
|
|
||||||
|
|
||||||
|
tgen.add_router("tor1")
|
||||||
|
tgen.add_router("tor2")
|
||||||
|
tgen.add_router("spine1")
|
||||||
|
|
||||||
class NetworkTopo(Topo):
|
# First switch is for a dummy interface (for local network)
|
||||||
"BGP_RR_IBGP Topology 1"
|
# on tor1
|
||||||
|
# 192.168.1.0/24
|
||||||
|
switch = tgen.add_switch("sw1")
|
||||||
|
switch.add_link(tgen.gears["tor1"])
|
||||||
|
|
||||||
def build(self, **_opts):
|
# 192.168.2.0/24 - tor1 <-> spine1 connection
|
||||||
"Build function"
|
switch = tgen.add_switch("sw2")
|
||||||
|
switch.add_link(tgen.gears["tor1"])
|
||||||
|
switch.add_link(tgen.gears["spine1"])
|
||||||
|
|
||||||
tgen = get_topogen(self)
|
# 3rd switch is for a dummy interface (for local netwokr)
|
||||||
|
# 192.168.3.0/24 - tor2
|
||||||
|
switch = tgen.add_switch("sw3")
|
||||||
|
switch.add_link(tgen.gears["tor2"])
|
||||||
|
|
||||||
tgen.add_router("tor1")
|
# 192.168.4.0/24 - tor2 <-> spine1 connection
|
||||||
tgen.add_router("tor2")
|
switch = tgen.add_switch("sw4")
|
||||||
tgen.add_router("spine1")
|
switch.add_link(tgen.gears["tor2"])
|
||||||
|
switch.add_link(tgen.gears["spine1"])
|
||||||
# First switch is for a dummy interface (for local network)
|
|
||||||
# on tor1
|
|
||||||
# 192.168.1.0/24
|
|
||||||
switch = tgen.add_switch("sw1")
|
|
||||||
switch.add_link(tgen.gears["tor1"])
|
|
||||||
|
|
||||||
# 192.168.2.0/24 - tor1 <-> spine1 connection
|
|
||||||
switch = tgen.add_switch("sw2")
|
|
||||||
switch.add_link(tgen.gears["tor1"])
|
|
||||||
switch.add_link(tgen.gears["spine1"])
|
|
||||||
|
|
||||||
# 3rd switch is for a dummy interface (for local netwokr)
|
|
||||||
# 192.168.3.0/24 - tor2
|
|
||||||
switch = tgen.add_switch("sw3")
|
|
||||||
switch.add_link(tgen.gears["tor2"])
|
|
||||||
|
|
||||||
# 192.168.4.0/24 - tor2 <-> spine1 connection
|
|
||||||
switch = tgen.add_switch("sw4")
|
|
||||||
switch.add_link(tgen.gears["tor2"])
|
|
||||||
switch.add_link(tgen.gears["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.
|
||||||
|
@ -47,24 +47,21 @@ 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):
|
for routern in range(1, 4):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 4):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -47,21 +47,18 @@ 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):
|
for routern in range(1, 4):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 4):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
switch.add_link(tgen.gears["r3"])
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -50,75 +50,71 @@ 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"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# This function only purpose is to define allocation and relationship
|
||||||
"Build function"
|
# between routers, switches and hosts.
|
||||||
tgen = get_topogen(self)
|
#
|
||||||
|
#
|
||||||
|
# Create routers
|
||||||
|
tgen.add_router("r1")
|
||||||
|
tgen.add_router("r2")
|
||||||
|
tgen.add_router("r3")
|
||||||
|
tgen.add_router("r4")
|
||||||
|
tgen.add_router("ce1")
|
||||||
|
tgen.add_router("ce2")
|
||||||
|
tgen.add_router("ce3")
|
||||||
|
tgen.add_router("ce4")
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
# r1-r2
|
||||||
# between routers, switches and hosts.
|
switch = tgen.add_switch("s1")
|
||||||
#
|
switch.add_link(tgen.gears["r1"])
|
||||||
#
|
switch.add_link(tgen.gears["r2"])
|
||||||
# Create routers
|
|
||||||
tgen.add_router("r1")
|
|
||||||
tgen.add_router("r2")
|
|
||||||
tgen.add_router("r3")
|
|
||||||
tgen.add_router("r4")
|
|
||||||
tgen.add_router("ce1")
|
|
||||||
tgen.add_router("ce2")
|
|
||||||
tgen.add_router("ce3")
|
|
||||||
tgen.add_router("ce4")
|
|
||||||
|
|
||||||
# r1-r2
|
# r1-r3
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
# r1-r3
|
# r1-r4
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
# r1-r4
|
# r1-ce1
|
||||||
switch = tgen.add_switch("s3")
|
switch = tgen.add_switch("s4")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r4"])
|
switch.add_link(tgen.gears["ce1"])
|
||||||
|
|
||||||
# r1-ce1
|
# r1-ce3
|
||||||
switch = tgen.add_switch("s4")
|
switch = tgen.add_switch("s5")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["ce1"])
|
switch.add_link(tgen.gears["ce3"])
|
||||||
|
|
||||||
# r1-ce3
|
# r1-ce4
|
||||||
switch = tgen.add_switch("s5")
|
switch = tgen.add_switch("s6")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["ce3"])
|
switch.add_link(tgen.gears["ce4"])
|
||||||
|
|
||||||
# r1-ce4
|
# r1-dangling
|
||||||
switch = tgen.add_switch("s6")
|
switch = tgen.add_switch("s7")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["ce4"])
|
|
||||||
|
|
||||||
# r1-dangling
|
# r2-r3
|
||||||
switch = tgen.add_switch("s7")
|
switch = tgen.add_switch("s8")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
# r2-r3
|
# r3-r4
|
||||||
switch = tgen.add_switch("s8")
|
switch = tgen.add_switch("s9")
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
# r3-r4
|
# r4-ce2
|
||||||
switch = tgen.add_switch("s9")
|
switch = tgen.add_switch("s10")
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
switch.add_link(tgen.gears["r4"])
|
switch.add_link(tgen.gears["ce2"])
|
||||||
|
|
||||||
# r4-ce2
|
|
||||||
switch = tgen.add_switch("s10")
|
|
||||||
switch.add_link(tgen.gears["r4"])
|
|
||||||
switch.add_link(tgen.gears["ce2"])
|
|
||||||
|
|
||||||
|
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
@ -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()
|
||||||
|
|
||||||
|
@ -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,24 +79,22 @@ class Topology(Topo):
|
|||||||
(eth0) (eth0) (eth0)
|
(eth0) (eth0) (eth0)
|
||||||
CE2 CE4 CE6
|
CE2 CE4 CE6
|
||||||
"""
|
"""
|
||||||
def build(self, *_args, **_opts):
|
tgen.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r2")
|
||||||
tgen.add_router("r1")
|
tgen.add_router("ce1")
|
||||||
tgen.add_router("r2")
|
tgen.add_router("ce2")
|
||||||
tgen.add_router("ce1")
|
tgen.add_router("ce3")
|
||||||
tgen.add_router("ce2")
|
tgen.add_router("ce4")
|
||||||
tgen.add_router("ce3")
|
tgen.add_router("ce5")
|
||||||
tgen.add_router("ce4")
|
tgen.add_router("ce6")
|
||||||
tgen.add_router("ce5")
|
|
||||||
tgen.add_router("ce6")
|
|
||||||
|
|
||||||
tgen.add_link(tgen.gears["r1"], tgen.gears["r2"], "eth0", "eth0")
|
tgen.add_link(tgen.gears["r1"], tgen.gears["r2"], "eth0", "eth0")
|
||||||
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "eth0", "eth1")
|
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "eth0", "eth1")
|
||||||
tgen.add_link(tgen.gears["ce2"], tgen.gears["r2"], "eth0", "eth1")
|
tgen.add_link(tgen.gears["ce2"], tgen.gears["r2"], "eth0", "eth1")
|
||||||
tgen.add_link(tgen.gears["ce3"], tgen.gears["r1"], "eth0", "eth2")
|
tgen.add_link(tgen.gears["ce3"], tgen.gears["r1"], "eth0", "eth2")
|
||||||
tgen.add_link(tgen.gears["ce4"], tgen.gears["r2"], "eth0", "eth2")
|
tgen.add_link(tgen.gears["ce4"], tgen.gears["r2"], "eth0", "eth2")
|
||||||
tgen.add_link(tgen.gears["ce5"], tgen.gears["r1"], "eth0", "eth3")
|
tgen.add_link(tgen.gears["ce5"], tgen.gears["r1"], "eth0", "eth3")
|
||||||
tgen.add_link(tgen.gears["ce6"], tgen.gears["r2"], "eth0", "eth3")
|
tgen.add_link(tgen.gears["ce6"], tgen.gears["r2"], "eth0", "eth3")
|
||||||
|
|
||||||
|
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
@ -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():
|
||||||
|
@ -43,24 +43,21 @@ 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):
|
for routern in range(1, 4):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 4):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -54,20 +54,17 @@ 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):
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 3):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -76,32 +76,30 @@ 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):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
for routern in range(1, 6):
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r{}".format(routern))
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.add_switch("s2")
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s2")
|
switch = tgen.add_switch("s3")
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r3"])
|
switch.add_link(tgen.gears["r4"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s3")
|
switch = tgen.add_switch("s4")
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r4"])
|
switch.add_link(tgen.gears["r5"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s4")
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r5"])
|
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
@ -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
|
||||||
|
@ -97,19 +97,11 @@ 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):
|
||||||
"""
|
"""Build function"""
|
||||||
Test BasicTopo - topology 1
|
|
||||||
|
|
||||||
* `Topo`: Topology object
|
# Building topology from json file
|
||||||
"""
|
build_topo_from_json(tgen, topo)
|
||||||
|
|
||||||
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):
|
||||||
@ -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
|
||||||
|
@ -50,20 +50,16 @@ from lib.micronet_compat import Topo
|
|||||||
pytestmark = [pytest.mark.bgpd]
|
pytestmark = [pytest.mark.bgpd]
|
||||||
|
|
||||||
|
|
||||||
class BGPIPV6RTADVVRFTopo(Topo):
|
def build_topo(tgen):
|
||||||
"Test topology builder"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# Create 2 routers.
|
||||||
"Build function"
|
tgen.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r2")
|
||||||
|
|
||||||
# Create 2 routers.
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r1")
|
switch.add_link(tgen.gears["r1"])
|
||||||
tgen.add_router("r2")
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
@ -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()
|
||||||
|
@ -57,25 +57,19 @@ CustomizeVrfWithNetns = True
|
|||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
|
||||||
class BGPVRFNETNSTopo1(Topo):
|
def build_topo(tgen):
|
||||||
"BGP EBGP VRF NETNS Topology 1"
|
tgen.add_router("r1")
|
||||||
|
|
||||||
def build(self, **_opts):
|
# Setup Switches
|
||||||
tgen = get_topogen(self)
|
switch = tgen.add_switch("s1")
|
||||||
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
|
||||||
# Setup Routers
|
# Add eBGP ExaBGP neighbors
|
||||||
tgen.add_router("r1")
|
peer_ip = "10.0.1.101"
|
||||||
|
peer_route = "via 10.0.1.1"
|
||||||
# Setup Switches
|
peer = tgen.add_exabgp_peer("peer1", ip=peer_ip, defaultRoute=peer_route)
|
||||||
switch = tgen.add_switch("s1")
|
switch = tgen.gears["s1"]
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(peer)
|
||||||
|
|
||||||
# Add eBGP ExaBGP neighbors
|
|
||||||
peer_ip = "10.0.1.101"
|
|
||||||
peer_route = "via 10.0.1.1"
|
|
||||||
peer = tgen.add_exabgp_peer("peer1", ip=peer_ip, defaultRoute=peer_route)
|
|
||||||
switch = tgen.gears["s1"]
|
|
||||||
switch.add_link(peer)
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -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
|
||||||
|
@ -41,21 +41,20 @@ 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))
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -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.add_router("r1")
|
||||||
tgen = get_topogen(self)
|
switch = tgen.add_switch("s1")
|
||||||
tgen.add_router("r1")
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch = tgen.add_switch("s1")
|
|
||||||
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()
|
||||||
|
@ -55,36 +55,29 @@ from lib.micronet_compat import Topo
|
|||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
|
||||||
class NetworkTopo(Topo):
|
def build_topo(tgen):
|
||||||
"EIGRP Topology 1"
|
for routern in range(1, 4):
|
||||||
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
def build(self, **_opts):
|
# On main router
|
||||||
"Build function"
|
# First switch is for a dummy interface (for local network)
|
||||||
|
switch = tgen.add_switch("sw1")
|
||||||
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
|
||||||
tgen = get_topogen(self)
|
# Switches for EIGRP
|
||||||
|
# switch 2 switch is for connection to EIGRP router
|
||||||
|
switch = tgen.add_switch("sw2")
|
||||||
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
for routern in range(1, 4):
|
# switch 4 is stub on remote EIGRP router
|
||||||
tgen.add_router("r{}".format(routern))
|
switch = tgen.add_switch("sw4")
|
||||||
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
# On main router
|
# switch 3 is between EIGRP routers
|
||||||
# First switch is for a dummy interface (for local network)
|
switch = tgen.add_switch("sw3")
|
||||||
switch = tgen.add_switch("sw1")
|
switch.add_link(tgen.gears["r2"])
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r3"])
|
||||||
|
|
||||||
# Switches for EIGRP
|
|
||||||
# switch 2 switch is for connection to EIGRP router
|
|
||||||
switch = tgen.add_switch("sw2")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
# switch 4 is stub on remote EIGRP router
|
|
||||||
switch = tgen.add_switch("sw4")
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
# switch 3 is between EIGRP routers
|
|
||||||
switch = tgen.add_switch("sw3")
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
switch.add_link(tgen.gears["r3"])
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -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.
|
||||||
|
@ -59,41 +59,34 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.bgpd]
|
|||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
|
||||||
class NetworkTopo(Topo):
|
def build_topo(tgen):
|
||||||
"evpn-pim Topology 1"
|
tgen.add_router("spine")
|
||||||
|
tgen.add_router("leaf1")
|
||||||
|
tgen.add_router("leaf2")
|
||||||
|
tgen.add_router("host1")
|
||||||
|
tgen.add_router("host2")
|
||||||
|
|
||||||
def build(self, **_opts):
|
# On main router
|
||||||
"Build function"
|
# First switch is for a dummy interface (for local network)
|
||||||
|
# spine-eth0 is connected to leaf1-eth0
|
||||||
|
switch = tgen.add_switch("sw1")
|
||||||
|
switch.add_link(tgen.gears["spine"])
|
||||||
|
switch.add_link(tgen.gears["leaf1"])
|
||||||
|
|
||||||
tgen = get_topogen(self)
|
# spine-eth1 is connected to leaf2-eth0
|
||||||
|
switch = tgen.add_switch("sw2")
|
||||||
|
switch.add_link(tgen.gears["spine"])
|
||||||
|
switch.add_link(tgen.gears["leaf2"])
|
||||||
|
|
||||||
tgen.add_router("spine")
|
# leaf1-eth1 is connected to host1-eth0
|
||||||
tgen.add_router("leaf1")
|
switch = tgen.add_switch("sw3")
|
||||||
tgen.add_router("leaf2")
|
switch.add_link(tgen.gears["leaf1"])
|
||||||
tgen.add_router("host1")
|
switch.add_link(tgen.gears["host1"])
|
||||||
tgen.add_router("host2")
|
|
||||||
|
|
||||||
# On main router
|
# leaf2-eth1 is connected to host2-eth0
|
||||||
# First switch is for a dummy interface (for local network)
|
switch = tgen.add_switch("sw4")
|
||||||
# spine-eth0 is connected to leaf1-eth0
|
switch.add_link(tgen.gears["leaf2"])
|
||||||
switch = tgen.add_switch("sw1")
|
switch.add_link(tgen.gears["host2"])
|
||||||
switch.add_link(tgen.gears["spine"])
|
|
||||||
switch.add_link(tgen.gears["leaf1"])
|
|
||||||
|
|
||||||
# spine-eth1 is connected to leaf2-eth0
|
|
||||||
switch = tgen.add_switch("sw2")
|
|
||||||
switch.add_link(tgen.gears["spine"])
|
|
||||||
switch.add_link(tgen.gears["leaf2"])
|
|
||||||
|
|
||||||
# leaf1-eth1 is connected to host1-eth0
|
|
||||||
switch = tgen.add_switch("sw3")
|
|
||||||
switch.add_link(tgen.gears["leaf1"])
|
|
||||||
switch.add_link(tgen.gears["host1"])
|
|
||||||
|
|
||||||
# leaf2-eth1 is connected to host2-eth0
|
|
||||||
switch = tgen.add_switch("sw4")
|
|
||||||
switch.add_link(tgen.gears["leaf2"])
|
|
||||||
switch.add_link(tgen.gears["host2"])
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
@ -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"]
|
||||||
|
@ -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
|
||||||
|
@ -142,19 +142,8 @@ BRCTL = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class CreateTopo(Topo):
|
def build_topo(tgen):
|
||||||
"""
|
build_topo_from_json(tgen, 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):
|
||||||
@ -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
|
||||||
|
@ -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,37 +47,40 @@ pytestmark = [
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TemplateTopo(Topo):
|
def build_topo(tgen):
|
||||||
"Test topology builder"
|
"Build function"
|
||||||
|
|
||||||
def build(self, *_args, **_opts):
|
# Create 2 routers
|
||||||
"Build function"
|
for routern in range(1, 3):
|
||||||
tgen = get_topogen(self)
|
tgen.add_router("r{}".format(routern))
|
||||||
|
|
||||||
# This function only purpose is to define allocation and relationship
|
# Create a switch with just one router connected to it to simulate a
|
||||||
# between routers, switches and hosts.
|
# empty network.
|
||||||
#
|
switch = tgen.add_switch("s1")
|
||||||
# Example
|
switch.add_link(tgen.gears["r1"])
|
||||||
#
|
|
||||||
# Create 2 routers
|
|
||||||
for routern in range(1, 3):
|
|
||||||
tgen.add_router("r{}".format(routern))
|
|
||||||
|
|
||||||
# Create a switch with just one router connected to it to simulate a
|
# Create a connection between r1 and r2
|
||||||
# empty network.
|
switch = tgen.add_switch("s2")
|
||||||
switch = tgen.add_switch("s1")
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
# Create a connection between r1 and r2
|
|
||||||
switch = tgen.add_switch("s2")
|
|
||||||
switch.add_link(tgen.gears["r1"])
|
|
||||||
switch.add_link(tgen.gears["r2"])
|
|
||||||
|
|
||||||
|
|
||||||
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
Loading…
Reference in New Issue
Block a user