diff options
Diffstat (limited to 'tests/topotests/bgp_rfapi_basic_sanity/customize.py')
| -rw-r--r-- | tests/topotests/bgp_rfapi_basic_sanity/customize.py | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/tests/topotests/bgp_rfapi_basic_sanity/customize.py b/tests/topotests/bgp_rfapi_basic_sanity/customize.py index 2c85cf6e9d..1a86746e37 100644 --- a/tests/topotests/bgp_rfapi_basic_sanity/customize.py +++ b/tests/topotests/bgp_rfapi_basic_sanity/customize.py @@ -61,65 +61,52 @@ r3-eth1 .3 | | .3 r3-eth0 | .4 r4-eth0 """ import os -import re -import pytest # pylint: disable=C0413 # Import topogen and topotest helpers -from lib import topotest -from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topogen import get_topogen from lib.topolog import logger from lib.ltemplate import ltemplateRtrCmd # Required to instantiate the topology builder class. -from mininet.topo import Topo -import shutil CWD = os.path.dirname(os.path.realpath(__file__)) # test name based on directory TEST = os.path.basename(CWD) -class ThisTestTopo(Topo): - "Test topology builder" +def build_topo(tgen): + "Build function" - 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 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 - # between routers, switches and hosts. - # - # 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") + switch[1] = tgen.add_switch("sw1") + switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1") + switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0") + switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0") - switch[1] = tgen.add_switch("sw1") - switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1") - switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0") - 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") + 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(): cc = ltemplateRtrCmd() tgen = get_topogen() logger.info("pre router-start hook") - # check for normal init - if len(tgen.net) == 1: - logger.info("Topology not configured, skipping setup") - return False return True |
