]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/topotests/bgp_ecmp_topo1/test_bgp_ecmp_topo1.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / bgp_ecmp_topo1 / test_bgp_ecmp_topo1.py
index 75506d1a51a1968c28b74091c8ef600533f05b43..97751ec8cfbea2cdb9c097d2ea63cddc7ffa6075 100644 (file)
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
+# SPDX-License-Identifier: ISC
 
 #
 # test_bgp_ecmp_topo1.py
@@ -7,20 +8,6 @@
 # Copyright (c) 2017 by
 # Network Device Education Foundation, Inc. ("NetDEF")
 #
-# Permission to use, copy, modify, and/or distribute this software
-# for any purpose with or without fee is hereby granted, provided
-# that the above copyright notice and this permission notice appear
-# in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
-# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-# OF THIS SOFTWARE.
-#
 
 """
 test_bgp_ecmp_topo1.py: Test BGP topology with ECMP (Equal Cost MultiPath).
@@ -43,7 +30,6 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
 from lib.topolog import logger
 
 # Required to instantiate the topology builder class.
-from mininet.topo import Topo
 
 
 pytestmark = [pytest.mark.bgpd]
@@ -58,32 +44,26 @@ total_ebgp_peers = 20
 #####################################################
 
 
-class BGPECMPTopo1(Topo):
-    "BGP ECMP Topology 1"
-
-    def build(self, **_opts):
-        tgen = get_topogen(self)
+def build_topo(tgen):
+    router = tgen.add_router("r1")
 
-        # Create the BGP router
-        router = tgen.add_router("r1")
+    # Setup Switches - 1 switch per 5 peering routers
+    for swNum in range(1, (total_ebgp_peers + 4) // 5 + 1):
+        switch = tgen.add_switch("s{}".format(swNum))
+        switch.add_link(router)
 
-        # Setup Switches - 1 switch per 5 peering routers
-        for swNum in range(1, (total_ebgp_peers + 4) / 5 + 1):
-            switch = tgen.add_switch("s{}".format(swNum))
-            switch.add_link(router)
+    # Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
+    for peerNum in range(1, total_ebgp_peers + 1):
+        swNum = (peerNum - 1) // 5 + 1
 
-        # Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
-        for peerNum in range(1, total_ebgp_peers + 1):
-            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
-            )
+        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)
+        switch = tgen.gears["s{}".format(swNum)]
+        switch.add_link(peer)
 
 
 #####################################################
@@ -94,7 +74,7 @@ class BGPECMPTopo1(Topo):
 
 
 def setup_module(module):
-    tgen = Topogen(BGPECMPTopo1, module.__name__)
+    tgen = Topogen(build_topo, module.__name__)
     tgen.start_topology()
 
     # Starting Routers
@@ -119,6 +99,7 @@ def setup_module(module):
 
 
 def teardown_module(module):
+    del module
     tgen = get_topogen()
     tgen.stop_topology()
 
@@ -146,12 +127,6 @@ def test_bgp_convergence():
         with 'json') and compare with `data` contents.
         """
         output = router.vtysh_cmd(cmd, isjson=True)
-        if "ipv4Unicast" in output:
-            output["ipv4Unicast"]["vrfName"] = output["ipv4Unicast"]["vrfName"].replace(
-                "default", "Default"
-            )
-        elif "vrfName" in output:
-            output["vrfName"] = output["vrfName"].replace("default", "Default")
         return topotest.json_cmp(output, data)
 
     test_func = functools.partial(