]> git.proxmox.com Git - mirror_frr.git/blobdiff - tests/topotests/bgp_flowspec/test_bgp_flowspec_topo.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / bgp_flowspec / test_bgp_flowspec_topo.py
old mode 100755 (executable)
new mode 100644 (file)
index a7e2c31..fd675dc
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# SPDX-License-Identifier: ISC
 
 #
 # test_bgp_flowspec_topo.py
@@ -6,20 +7,6 @@
 #
 # Copyright (c) 2019 by 6WIND
 #
-# 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_flowspec_topo.py: Test BGP topology with Flowspec EBGP peering
@@ -54,7 +41,6 @@ import functools
 import os
 import sys
 import pytest
-import getopt
 
 # Save the Current Working Directory to find configuration files.
 CWD = os.path.dirname(os.path.realpath(__file__))
@@ -65,11 +51,12 @@ sys.path.append(os.path.join(CWD, "../"))
 from lib import topotest
 from lib.topogen import Topogen, TopoRouter, get_topogen
 from lib.topolog import logger
-from lib.lutil import lUtil
-from lib.lutil import luCommand
 
 # Required to instantiate the topology builder class.
-from mininet.topo import Topo
+
+
+pytestmark = [pytest.mark.bgpd]
+
 
 #####################################################
 ##
@@ -78,24 +65,18 @@ from mininet.topo import Topo
 #####################################################
 
 
-class BGPFLOWSPECTopo1(Topo):
-    "BGP EBGP Flowspec Topology 1"
-
-    def build(self, **_opts):
-        tgen = get_topogen(self)
+def build_topo(tgen):
+    tgen.add_router("r1")
 
-        # Setup Routers
-        tgen.add_router("r1")
+    # Setup Control Path Switch 1. r1-eth0
+    switch = tgen.add_switch("s1")
+    switch.add_link(tgen.gears["r1"])
 
-        # Setup Control Path Switch 1. r1-eth0
-        switch = tgen.add_switch("s1")
-        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)
+    ## 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)
 
 
 #####################################################
@@ -106,7 +87,7 @@ class BGPFLOWSPECTopo1(Topo):
 
 
 def setup_module(module):
-    tgen = Topogen(BGPFLOWSPECTopo1, module.__name__)
+    tgen = Topogen(build_topo, module.__name__)
 
     tgen.start_topology()
     # check for zebra capability
@@ -124,7 +105,7 @@ def setup_module(module):
     router.start()
 
     peer_list = tgen.exabgp_peers()
-    for pname, peer in peer_list.iteritems():
+    for pname, peer in peer_list.items():
         peer_dir = os.path.join(CWD, pname)
         env_file = os.path.join(CWD, "exabgp.env")
         peer.start(peer_dir, env_file)
@@ -200,6 +181,7 @@ def test_bgp_flowspec():
     else:
         logger.info("Check BGP FS entry for 3::3 with redirect IP OK")
 
+
 if __name__ == "__main__":
 
     args = ["-s"] + sys.argv[1:]