#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
#
# test_bgp_flowspec_topo.py
#
# 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
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__))
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]
+
#####################################################
##
#####################################################
-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)
#####################################################
def setup_module(module):
- tgen = Topogen(BGPFLOWSPECTopo1, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
# check for zebra capability
else:
logger.info("Check BGP FS entry for 3::3 with redirect IP OK")
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]