From e82b531df94b9fd7bc456df8a1b7c58f2770eff9 Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Thu, 29 Jul 2021 09:38:55 +0000 Subject: tests: remove legacy Topo class (fixes many pylint errors) Signed-off-by: Christian Hopps --- tests/topotests/bgp_auth/test_bgp_auth.py | 114 +++++++++++++----------------- 1 file changed, 51 insertions(+), 63 deletions(-) (limited to 'tests/topotests/bgp_auth') diff --git a/tests/topotests/bgp_auth/test_bgp_auth.py b/tests/topotests/bgp_auth/test_bgp_auth.py index b13f3d6e2..48ba0cca5 100644 --- a/tests/topotests/bgp_auth/test_bgp_auth.py +++ b/tests/topotests/bgp_auth/test_bgp_auth.py @@ -74,76 +74,64 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd] class InvalidCLIError(Exception): """Raise when the CLI command is wrong""" - pass - -class TemplateTopo(Topo): - "Test topology builder" - - def build(self, *_args, **_opts): - "Build function" - tgen = get_topogen(self) - - # This function only purpose is to define allocation and relationship - # between routers, switches and hosts. - # - # - # Create routers - tgen.add_router("R1") - tgen.add_router("R2") - tgen.add_router("R3") - - # R1-R2 1 - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["R1"]) - switch.add_link(tgen.gears["R2"]) - - # R1-R3 1 - switch = tgen.add_switch("s2") - switch.add_link(tgen.gears["R1"]) - switch.add_link(tgen.gears["R3"]) - - # R2-R3 1 - switch = tgen.add_switch("s3") - switch.add_link(tgen.gears["R2"]) - switch.add_link(tgen.gears["R3"]) - - # R1-R2 2 - switch = tgen.add_switch("s4") - switch.add_link(tgen.gears["R1"]) - switch.add_link(tgen.gears["R2"]) - - # R1-R3 2 - switch = tgen.add_switch("s5") - switch.add_link(tgen.gears["R1"]) - switch.add_link(tgen.gears["R3"]) - - # R2-R3 2 - switch = tgen.add_switch("s6") - switch.add_link(tgen.gears["R2"]) - 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 build_topo(tgen): + # Create routers + tgen.add_router("R1") + tgen.add_router("R2") + tgen.add_router("R3") + + # R1-R2 1 + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["R1"]) + switch.add_link(tgen.gears["R2"]) + + # R1-R3 1 + switch = tgen.add_switch("s2") + switch.add_link(tgen.gears["R1"]) + switch.add_link(tgen.gears["R3"]) + + # R2-R3 1 + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["R2"]) + switch.add_link(tgen.gears["R3"]) + + # R1-R2 2 + switch = tgen.add_switch("s4") + switch.add_link(tgen.gears["R1"]) + switch.add_link(tgen.gears["R2"]) + + # R1-R3 2 + switch = tgen.add_switch("s5") + switch.add_link(tgen.gears["R1"]) + switch.add_link(tgen.gears["R3"]) + + # R2-R3 2 + switch = tgen.add_switch("s6") + switch.add_link(tgen.gears["R2"]) + 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): "Sets up the pytest environment" # 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. tgen.start_topology() -- cgit v1.2.3