summaryrefslogtreecommitdiff
path: root/tests/topotests/ldp_topo1/test_ldp_topo1.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/ldp_topo1/test_ldp_topo1.py')
-rw-r--r--tests/topotests/ldp_topo1/test_ldp_topo1.py141
1 files changed, 37 insertions, 104 deletions
diff --git a/tests/topotests/ldp_topo1/test_ldp_topo1.py b/tests/topotests/ldp_topo1/test_ldp_topo1.py
index 06e7734094..c21d6bf28e 100644
--- a/tests/topotests/ldp_topo1/test_ldp_topo1.py
+++ b/tests/topotests/ldp_topo1/test_ldp_topo1.py
@@ -65,15 +65,9 @@ import sys
import pytest
from time import sleep
-from mininet.topo import Topo
-from mininet.net import Mininet
-from mininet.node import Node, OVSSwitch, Host
-from mininet.log import setLogLevel, info
-from mininet.cli import CLI
-from mininet.link import Intf
-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lib import topotest
+from lib.topogen import Topogen, get_topogen
fatal_error = ""
@@ -86,73 +80,25 @@ pytestmark = [pytest.mark.ldpd, pytest.mark.ospfd]
#####################################################
-class NetworkTopo(Topo):
- "LDP Test Topology 1"
-
- def build(self, **_opts):
+def build_topo(tgen):
- # Setup Routers
- router = {}
- for i in range(1, 5):
- router[i] = topotest.addRouter(self, "r%s" % i)
-
- # Setup Switches, add Interfaces and Connections
- switch = {}
- # First switch
- switch[0] = self.addSwitch("sw0", cls=topotest.LegacySwitch)
- self.addLink(
- switch[0],
- router[1],
- intfName2="r1-eth0",
- addr1="80:AA:00:00:00:00",
- addr2="00:11:00:01:00:00",
- )
- self.addLink(
- switch[0],
- router[2],
- intfName2="r2-eth0",
- addr1="80:AA:00:00:00:01",
- addr2="00:11:00:02:00:00",
- )
- # Second switch
- switch[1] = self.addSwitch("sw1", cls=topotest.LegacySwitch)
- self.addLink(
- switch[1],
- router[2],
- intfName2="r2-eth1",
- addr1="80:AA:00:01:00:00",
- addr2="00:11:00:02:00:01",
- )
- self.addLink(
- switch[1],
- router[3],
- intfName2="r3-eth0",
- addr1="80:AA:00:01:00:01",
- addr2="00:11:00:03:00:00",
- )
- self.addLink(
- switch[1],
- router[4],
- intfName2="r4-eth0",
- addr1="80:AA:00:01:00:02",
- addr2="00:11:00:04:00:00",
- )
- # Third switch
- switch[2] = self.addSwitch("sw2", cls=topotest.LegacySwitch)
- self.addLink(
- switch[2],
- router[2],
- intfName2="r2-eth2",
- addr1="80:AA:00:02:00:00",
- addr2="00:11:00:02:00:02",
- )
- self.addLink(
- switch[2],
- router[3],
- intfName2="r3-eth1",
- addr1="80:AA:00:02:00:01",
- addr2="00:11:00:03:00:01",
- )
+ # Setup Routers
+ for i in range(1, 5):
+ tgen.add_router("r%s" % i)
+
+ # First switch
+ switch = tgen.add_switch("sw0")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+ # Second switch
+ switch = tgen.add_switch("sw1")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
+ # Third switch
+ switch = tgen.add_switch("sw2")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
#####################################################
@@ -163,48 +109,36 @@ class NetworkTopo(Topo):
def setup_module(module):
- global topo, net
- global fatal_error
-
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__))
- topo = NetworkTopo()
+ tgen = Topogen(build_topo, module.__name__)
+ tgen.start_topology()
- net = Mininet(controller=None, topo=topo)
- net.start()
+ net = tgen.net
# Starting Routers
for i in range(1, 5):
net["r%s" % i].loadConf("zebra", "%s/r%s/zebra.conf" % (thisDir, i))
net["r%s" % i].loadConf("ospfd", "%s/r%s/ospfd.conf" % (thisDir, i))
net["r%s" % i].loadConf("ldpd", "%s/r%s/ldpd.conf" % (thisDir, i))
- fatal_error = net["r%s" % i].startRouter()
-
- if fatal_error != "":
- break
+ tgen.gears["r%s" % i].start()
# For debugging after starting FRR daemons, uncomment the next line
# CLI(net)
def teardown_module(module):
- global net
-
print("\n\n** %s: Shutdown Topology" % module.__name__)
print("******************************************\n")
-
- # End - Shutdown network
- net.stop()
+ tgen = get_topogen()
+ tgen.stop_topology()
def test_router_running():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -225,7 +159,7 @@ def test_router_running():
def test_mpls_interfaces():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -291,7 +225,7 @@ def test_mpls_interfaces():
def test_mpls_ldp_neighbor_establish():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -342,7 +276,7 @@ def test_mpls_ldp_neighbor_establish():
else:
# Bail out with error if a router fails to converge
fatal_error = "MPLS LDP neighbors did not establish"
- assert False, "MPLS LDP neighbors did not establish" % ospfStatus
+ assert False, "MPLS LDP neighbors did not establish"
print("MPLS LDP neighbors established.")
@@ -359,7 +293,7 @@ def test_mpls_ldp_neighbor_establish():
def test_mpls_ldp_discovery():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -428,7 +362,7 @@ def test_mpls_ldp_discovery():
def test_mpls_ldp_neighbor():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -498,7 +432,7 @@ def test_mpls_ldp_neighbor():
def test_mpls_ldp_binding():
global fatal_error
- global net
+ net = get_topogen().net
# Skip this test for now until proper sorting of the output
# is implemented
@@ -590,7 +524,7 @@ def test_mpls_ldp_binding():
def test_zebra_ipv4_routingTable():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -667,7 +601,7 @@ def test_zebra_ipv4_routingTable():
def test_mpls_table():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -746,7 +680,7 @@ def test_mpls_table():
def test_linux_mpls_routes():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -830,7 +764,7 @@ def test_linux_mpls_routes():
def test_shutdown_check_stderr():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -862,7 +796,7 @@ def test_shutdown_check_stderr():
def test_shutdown_check_memleak():
global fatal_error
- global net
+ net = get_topogen().net
# Skip if previous fatal error condition is raised
if fatal_error != "":
@@ -885,7 +819,6 @@ def test_shutdown_check_memleak():
if __name__ == "__main__":
- setLogLevel("info")
# To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli
# retval = pytest.main(["-s", "--tb=no"])
retval = pytest.main(["-s"])