Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 02521c91c47ea3e43a9dae05b98dfa6def9feaff Mon Sep 17 00:00:00 2001
- From: Philippe Guibert <philippe.guibert@6wind.com>
- Date: Thu, 3 Oct 2019 08:38:25 +0200
- Subject: [PATCH] topotests: add bgp route reflector scenario
- that scenario involves 2 route reflector servers, replicating the same
- route to a route reflector client, named r1. the goal is to check there
- is no flapping when one route reflector server leaves, as the other
- remaing present.
- Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
- ---
- tests/topotests/bgp_rr_case/#__init__.py# | 1 +
- tests/topotests/bgp_rr_case/__init__.py | 0
- tests/topotests/bgp_rr_case/r1/bgpd.conf | 31 ++++
- tests/topotests/bgp_rr_case/r1/zebra.conf | 10 ++
- tests/topotests/bgp_rr_case/r2/bgpd.conf | 28 ++++
- tests/topotests/bgp_rr_case/r2/zebra.conf | 13 ++
- tests/topotests/bgp_rr_case/r3/bgpd.conf | 24 +++
- tests/topotests/bgp_rr_case/r3/zebra.conf | 13 ++
- tests/topotests/bgp_rr_case/r4/bgpd.conf | 36 +++++
- tests/topotests/bgp_rr_case/r4/zebra.conf | 11 ++
- .../topotests/bgp_rr_case/test_bgp_rr_case.py | 153 ++++++++++++++++++
- 11 files changed, 320 insertions(+)
- create mode 100644 tests/topotests/bgp_rr_case/#__init__.py#
- create mode 100644 tests/topotests/bgp_rr_case/__init__.py
- create mode 100644 tests/topotests/bgp_rr_case/r1/bgpd.conf
- create mode 100644 tests/topotests/bgp_rr_case/r1/zebra.conf
- create mode 100644 tests/topotests/bgp_rr_case/r2/bgpd.conf
- create mode 100644 tests/topotests/bgp_rr_case/r2/zebra.conf
- create mode 100644 tests/topotests/bgp_rr_case/r3/bgpd.conf
- create mode 100644 tests/topotests/bgp_rr_case/r3/zebra.conf
- create mode 100644 tests/topotests/bgp_rr_case/r4/bgpd.conf
- create mode 100644 tests/topotests/bgp_rr_case/r4/zebra.conf
- create mode 100755 tests/topotests/bgp_rr_case/test_bgp_rr_case.py
- diff --git a/tests/topotests/bgp_rr_case/#__init__.py# b/tests/topotests/bgp_rr_case/#__init__.py#
- new file mode 100644
- index 000000000000..9029c51c87bf
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/#__init__.py#
- @@ -0,0 +1 @@
- +macs
- \ No newline at end of file
- diff --git a/tests/topotests/bgp_rr_case/__init__.py b/tests/topotests/bgp_rr_case/__init__.py
- new file mode 100644
- index 000000000000..e69de29bb2d1
- diff --git a/tests/topotests/bgp_rr_case/r1/bgpd.conf b/tests/topotests/bgp_rr_case/r1/bgpd.conf
- new file mode 100644
- index 000000000000..08f2a54ced15
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/r1/bgpd.conf
- @@ -0,0 +1,31 @@
- +debug bgp updates
- +debug bgp zebra
- +debug bgp neighbor-events
- +debug bgp vpn label
- +debug bgp vpn leak-from-vrf
- +debug bgp vpn leak-to-vrf
- +!
- +router bgp 100
- + bgp router-id 10.0.1.1
- + neighbor 10.0.1.101 remote-as 100
- + neighbor 10.0.1.100 remote-as 100
- + address-family ipv4 vpn
- + neighbor 10.0.1.101 activate
- + neighbor 10.0.1.101 soft-reconfiguration inbound
- + neighbor 10.0.1.100 activate
- + neighbor 10.0.1.100 soft-reconfiguration inbound
- + !
- +!
- +router bgp 100 vrf r1-cust1
- + bgp router-id 10.0.1.1
- + address-family ipv4 unicast
- + label vpn export auto
- + maximum-paths 4
- + maximum-paths ibgp 4
- + rd vpn export 64603:1111
- + rt vpn import 64603:1111
- + rt vpn export 64603:1111
- + import vpn
- + export vpn
- + !
- +!
- diff --git a/tests/topotests/bgp_rr_case/r1/zebra.conf b/tests/topotests/bgp_rr_case/r1/zebra.conf
- new file mode 100644
- index 000000000000..984a95dc4c50
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/r1/zebra.conf
- @@ -0,0 +1,10 @@
- +!
- +interface r1-eth0
- + ip address 10.0.1.1/24
- +!
- +interface r1-eth1
- + ip address 10.0.2.22/24
- +!
- +line vty
- +!
- +debug vrf
- diff --git a/tests/topotests/bgp_rr_case/r2/bgpd.conf b/tests/topotests/bgp_rr_case/r2/bgpd.conf
- new file mode 100644
- index 000000000000..9a729c3f4b7e
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/r2/bgpd.conf
- @@ -0,0 +1,28 @@
- +log stdout
- +debug bgp neighbor-events
- +debug bgp updates
- +debug bgp zebra
- +!
- +router bgp 100
- + bgp router-id 10.0.3.100
- + neighbor 10.0.1.1 remote-as 100
- + neighbor 10.0.2.1 remote-as 90
- + address-family ipv4 vpn
- + neighbor 10.0.1.1 activate
- + neighbor 10.0.1.1 route-reflector-client
- + neighbor 10.0.2.1 activate
- + !
- + !
- +router bgp 100 vrf r2-cust1
- + bgp router-id 10.0.3.100
- + address-family ipv4 unicast
- + label vpn export auto
- + rd vpn export 64603:1111
- + rt vpn import 64603:1111
- + rt vpn export 64603:1111
- + import vpn
- + export vpn
- + !
- +!
- +
- +
- diff --git a/tests/topotests/bgp_rr_case/r2/zebra.conf b/tests/topotests/bgp_rr_case/r2/zebra.conf
- new file mode 100644
- index 000000000000..0138a78bb2c8
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/r2/zebra.conf
- @@ -0,0 +1,13 @@
- +!
- +interface lo
- + ip address 10.0.3.100/32
- +!
- +interface r2-eth0
- + ip address 10.0.1.100/24
- +!
- +interface r2-eth1
- + ip address 10.0.2.100/24
- +!
- +line vty
- +!
- +debug vrf
- diff --git a/tests/topotests/bgp_rr_case/r3/bgpd.conf b/tests/topotests/bgp_rr_case/r3/bgpd.conf
- new file mode 100644
- index 000000000000..55d74a7bd55f
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/r3/bgpd.conf
- @@ -0,0 +1,24 @@
- +!
- +router bgp 100
- + bgp router-id 10.0.3.101
- + neighbor 10.0.1.1 remote-as 100
- + neighbor 10.0.2.1 remote-as 90
- + address-family ipv4 vpn
- + neighbor 10.0.1.1 activate
- + neighbor 10.0.1.1 route-reflector-client
- + neighbor 10.0.2.1 activate
- + !
- + !
- +!
- +router bgp 100 vrf r3-cust1
- + bgp router-id 10.0.3.101
- + address-family ipv4 unicast
- + label vpn export auto
- + rd vpn export 64603:1111
- + rt vpn import 64603:1111
- + rt vpn export 64603:1111
- + import vpn
- + export vpn
- + !
- +!
- +
- diff --git a/tests/topotests/bgp_rr_case/r3/zebra.conf b/tests/topotests/bgp_rr_case/r3/zebra.conf
- new file mode 100644
- index 000000000000..095d05eb17a7
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/r3/zebra.conf
- @@ -0,0 +1,13 @@
- +!
- +interface lo
- + ip address 10.0.3.101/32
- +!
- +interface r3-eth0
- + ip address 10.0.1.101/24
- +!
- +interface r3-eth1
- + ip address 10.0.2.101/24
- +!
- +line vty
- +!
- +debug vrf
- diff --git a/tests/topotests/bgp_rr_case/r4/bgpd.conf b/tests/topotests/bgp_rr_case/r4/bgpd.conf
- new file mode 100644
- index 000000000000..e97d7233c845
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/r4/bgpd.conf
- @@ -0,0 +1,36 @@
- +log stdout
- +debug bgp neighbor-events
- +debug bgp updates
- +debug bgp zebra
- +!
- +router bgp 90
- + bgp router-id 10.0.2.1
- + neighbor 10.0.2.100 remote-as 100
- + neighbor 10.0.2.101 remote-as 100
- + address-family ipv4 vpn
- + neighbor 10.0.2.100 activate
- + neighbor 10.0.2.100 route-map test3 out
- + neighbor 10.0.2.101 activate
- + neighbor 10.0.2.101 route-map test2 out
- + network 44.44.44.0/24 rd 64603:1111 label 4444
- + !
- +!
- +router bgp 90 vrf r4-cust1
- + bgp router-id 10.0.2.1
- + address-family ipv4 unicast
- + label vpn export auto
- + rd vpn export 64603:1111
- + rt vpn import 64603:1111
- + rt vpn export 64603:1111
- + import vpn
- + export vpn
- + !
- +!
- +route-map test2 permit 1
- + set extcommunity rt 64603:1111
- + set ip next-hop 10.0.2.1
- +!
- +route-map test3 permit 1
- + set extcommunity rt 64603:1111
- + set ip next-hop 10.0.2.1
- +!
- diff --git a/tests/topotests/bgp_rr_case/r4/zebra.conf b/tests/topotests/bgp_rr_case/r4/zebra.conf
- new file mode 100644
- index 000000000000..0b8f0ad0a99e
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/r4/zebra.conf
- @@ -0,0 +1,11 @@
- +log stdout
- +debug bgp neighbor-events
- +debug bgp updates
- +debug bgp zebra
- +!
- +interface r4-eth0
- + ip address 10.0.2.1/24
- +!
- +line vty
- +!
- +debug vrf
- diff --git a/tests/topotests/bgp_rr_case/test_bgp_rr_case.py b/tests/topotests/bgp_rr_case/test_bgp_rr_case.py
- new file mode 100755
- index 000000000000..c96ee31b351c
- --- /dev/null
- +++ b/tests/topotests/bgp_rr_case/test_bgp_rr_case.py
- @@ -0,0 +1,153 @@
- +#!/usr/bin/env python
- +
- +#
- +# test_bgp_rr_case_topo1.py
- +# Part of NetDEF Topology Tests
- +#
- +# 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_rr_case_topo1.py: Test BGP RR topology
- +"""
- +
- +import json
- +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__))
- +sys.path.append(os.path.join(CWD, '../'))
- +
- +# pylint: disable=C0413
- +# Import topogen and topotest helpers
- +from lib import topotest
- +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
- +
- +
- +#####################################################
- +##
- +## Network Topology Definition
- +##
- +#####################################################
- +
- +class BGPRRCASETopo1(Topo):
- + "BGP RR Topology 1"
- +
- + def build(self, **_opts):
- + tgen = get_topogen(self)
- +
- + # Setup Routers
- + tgen.add_router('r1')
- +
- + # Setup Switches
- + switch = tgen.add_switch('s1')
- + switch.add_link(tgen.gears['r1'])
- +
- + tgen.add_router('r2')
- + tgen.add_router('r3')
- + switch.add_link(tgen.gears['r2'])
- + switch.add_link(tgen.gears['r3'])
- +
- + tgen.add_router('r4')
- + switch = tgen.add_switch('s2')
- + switch.add_link(tgen.gears['r2'])
- + switch.add_link(tgen.gears['r3'])
- + switch.add_link(tgen.gears['r4'])
- + switch.add_link(tgen.gears['r1'])
- +
- +
- +#####################################################
- +##
- +## Tests starting
- +##
- +#####################################################
- +
- +def setup_module(module):
- + tgen = Topogen(BGPRRCASETopo1, module.__name__)
- + tgen.start_topology()
- +
- + if tgen.hasmpls != True:
- + logger.info('MPLS not available, skipping setup')
- + return False
- + #run daemons
- + cmds_vrflite = ['ip link add {}-cust1 type vrf table 101',
- + 'ip ru add oif {}-cust1 table 101',
- + 'ip ru add iif {}-cust1 table 101',
- + 'ip li set dev {}-cust1 up',
- + 'echo 1 > /proc/sys/net/mpls/conf/{}-eth0/input',
- + 'echo 1 > /proc/sys/net/mpls/conf/{}-eth1/input']
- + router = tgen.gears['r1']
- + for cmd in cmds_vrflite:
- + logger.info('cmd to r1: '+cmd);
- + output = router.run(cmd.format('r1'))
- + logger.info('result: '+output);
- +
- + router_list = tgen.routers()
- + for rname, router in router_list.iteritems():
- + logger.info('router {}'.format(rname))
- + router.load_config(
- + TopoRouter.RD_ZEBRA,
- + os.path.join(CWD, '{}/zebra.conf'.format(rname))
- + )
- + if rname == 'r1':
- + router.load_config(
- + TopoRouter.RD_BGP,
- + os.path.join(CWD, '{}/bgpd.conf'.format(rname))
- + )
- + else:
- + router.load_config(
- + TopoRouter.RD_BGP,
- + os.path.join(CWD, '{}/bgpd.conf'.format(rname)),
- + '-Z'
- + )
- + logger.info('Launching BGP and ZEBRA for {}'.format(rname))
- + # BGP and ZEBRA start without underlying VRF
- + tgen.start_router()
- +
- +
- +def teardown_module(module):
- + tgen = get_topogen()
- + tgen.stop_topology()
- +
- +def test_bgp_convergence():
- + "Test for BGP topology convergence"
- + tgen = get_topogen()
- +
- + # uncomment if you want to troubleshoot
- + # tgen.mininet_cli()
- + # Skip if previous fatal error condition is raised
- + logger.info('waiting for bgp convergence')
- + tgen.mininet_cli()
- + if tgen.routers_have_failure():
- + pytest.skip(tgen.errors)
- +
- + logger.info('end test')
- +
- +
- +if __name__ == '__main__':
- +
- + args = ["-s"] + sys.argv[1:]
- + ret = pytest.main(args)
- +
- + sys.exit(ret)
- --
- 2.17.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement