mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-04 02:06:12 +00:00
Merge pull request #9199 from LabNConsulting/chopps/micronet-prime
This commit is contained in:
commit
5653bb515c
6
.pylintrc
Normal file
6
.pylintrc
Normal file
@ -0,0 +1,6 @@
|
||||
[MASTER]
|
||||
init-hook="import sys; sys.path.insert(0, '..')"
|
||||
signature-mutators=common_config.retry,retry
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
disable=I,C,R,W
|
@ -12,8 +12,8 @@ Installing Dependencies
|
||||
sudo apt update
|
||||
sudo apt-get install \
|
||||
git autoconf automake libtool make libreadline-dev texinfo \
|
||||
pkg-config libpam0g-dev libjson-c-dev bison flex python3-pytest \
|
||||
libc-ares-dev python3-dev python-ipaddress python3-sphinx \
|
||||
pkg-config libpam0g-dev libjson-c-dev bison flex \
|
||||
libc-ares-dev python3-dev python3-sphinx \
|
||||
install-info build-essential libsnmp-dev perl libcap-dev \
|
||||
libelf-dev
|
||||
|
||||
|
@ -12,8 +12,8 @@ Installing Dependencies
|
||||
sudo apt update
|
||||
sudo apt-get install \
|
||||
git autoconf automake libtool make libreadline-dev texinfo \
|
||||
pkg-config libpam0g-dev libjson-c-dev bison flex python3-pytest \
|
||||
libc-ares-dev python3-dev python-ipaddress python3-sphinx \
|
||||
pkg-config libpam0g-dev libjson-c-dev bison flex \
|
||||
libc-ares-dev python3-dev python3-sphinx \
|
||||
install-info build-essential libsnmp-dev perl \
|
||||
libcap-dev python2 libelf-dev
|
||||
|
||||
|
@ -373,23 +373,18 @@ Building topology and configurations
|
||||
Topology and initial configuration will be created in setup_module(). Following
|
||||
is the sample code::
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
json_file = "{}/my_test_name.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
|
||||
# json topo object is now available in tgen.json_topo
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
start_topology(tgen)
|
||||
|
||||
# Creating configuration from JSON
|
||||
build_config_from_json(tgen, topo)
|
||||
build_config_from_json(tgen)
|
||||
|
||||
def teardown_module(mod):
|
||||
tgen = get_topogen()
|
||||
@ -412,10 +407,12 @@ configurations are like, static routes, prefixlists and route maps etc configs,
|
||||
these configs can be used by any other protocols as it is.
|
||||
BGP config will be specific to BGP protocol testing.
|
||||
|
||||
* JSON file is passed to API build_config_from_json(), which looks for
|
||||
configuration tags in JSON file.
|
||||
* If tag is found in JSON, configuration is created as per input and written
|
||||
to file frr_json.conf
|
||||
* json file is passed to API Topogen() which saves the JSON object in
|
||||
`self.json_topo`
|
||||
* The Topogen object is then passed to API build_config_from_json(), which looks
|
||||
for configuration tags in new JSON object.
|
||||
* If tag is found in the JSON object, configuration is created as per input and
|
||||
written to file frr_json.conf
|
||||
* Once JSON parsing is over, frr_json.conf is loaded onto respective router.
|
||||
Config loading is done using 'vtysh -f <file>'. Initial config at this point
|
||||
is also saved frr_json_initial.conf. This file can be used to reset
|
||||
@ -428,10 +425,10 @@ Writing Tests
|
||||
"""""""""""""
|
||||
|
||||
Test topologies should always be bootstrapped from the
|
||||
example-test/test_example.py, because it contains important boilerplate code
|
||||
that can't be avoided, like:
|
||||
example_test/test_template_json.py, because it contains important boilerplate
|
||||
code that can't be avoided, like:
|
||||
|
||||
imports: os, sys, pytest, topotest/topogen and mininet topology class
|
||||
imports: os, sys, pytest, and topotest/topogen.
|
||||
|
||||
The global variable CWD (Current Working directory): which is most likely going
|
||||
to be used to reference the routers configuration file location
|
||||
|
@ -3,32 +3,37 @@
|
||||
Topotests
|
||||
=========
|
||||
|
||||
Topotests is a suite of topology tests for FRR built on top of Mininet.
|
||||
Topotests is a suite of topology tests for FRR built on top of micronet.
|
||||
|
||||
Installation and Setup
|
||||
----------------------
|
||||
|
||||
Only tested with Ubuntu 16.04 and Ubuntu 18.04 (which uses Mininet 2.2.x).
|
||||
Topotests run under python3. Additionally, for ExaBGP (which is used in some of
|
||||
the BGP tests) an older python2 version must be installed.
|
||||
|
||||
Tested with Ubuntu 20.04 and Ubuntu 18.04 and Debian 11.
|
||||
|
||||
Instructions are the same for all setups (i.e. ExaBGP is only used for BGP
|
||||
tests).
|
||||
|
||||
Installing Mininet Infrastructure
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Installing Topotest Requirements
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code:: shell
|
||||
|
||||
apt-get install mininet
|
||||
apt-get install python-pip
|
||||
apt-get install iproute
|
||||
apt-get install iperf
|
||||
pip install ipaddr
|
||||
pip install "pytest<5"
|
||||
pip install "scapy>=2.4.2"
|
||||
pip install exabgp==3.4.17 (Newer 4.0 version of exabgp is not yet
|
||||
supported)
|
||||
apt-get install iproute2
|
||||
apt-get install net-tools
|
||||
apt-get install python3-pip
|
||||
python3 -m pip install wheel
|
||||
python3 -m pip install 'pytest>=6.2.4'
|
||||
python3 -m pip install 'pytest-xdist>=2.3.0'
|
||||
python3 -m pip install 'scapy>=2.4.5'
|
||||
python3 -m pip install xmltodict
|
||||
# Use python2 pip to install older ExaBGP
|
||||
python2 -m pip install 'exabgp<4.0.0'
|
||||
useradd -d /var/run/exabgp/ -s /bin/false exabgp
|
||||
|
||||
|
||||
Enable Coredumps
|
||||
""""""""""""""""
|
||||
|
||||
@ -125,20 +130,125 @@ And create ``frr`` user and ``frrvty`` group as follows:
|
||||
Executing Tests
|
||||
---------------
|
||||
|
||||
Execute all tests with output to console
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Execute all tests in distributed test mode
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code:: shell
|
||||
|
||||
py.test -s -v --tb=no
|
||||
py.test -s -v -nauto --dist=loadfile
|
||||
|
||||
The above command must be executed from inside the topotests directory.
|
||||
|
||||
All test\_\* scripts in subdirectories are detected and executed (unless
|
||||
disabled in ``pytest.ini`` file).
|
||||
disabled in ``pytest.ini`` file). Pytest will execute up to N tests in parallel
|
||||
where N is based on the number of cores on the host.
|
||||
|
||||
Analyze Test Results (``analyze.py``)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
By default router and execution logs are saved in ``/tmp/topotests`` and an XML
|
||||
results file is saved in ``/tmp/topotests.xml``. An analysis tool ``analyze.py``
|
||||
is provided to archive and analyze these results after the run completes.
|
||||
|
||||
After the test run completes one should pick an archive directory to store the
|
||||
results in and pass this value to ``analyze.py``. On first execution the results
|
||||
are copied to that directory from ``/tmp``, and subsequent runs use that
|
||||
directory for analyzing the results. Below is an example of this which also
|
||||
shows the default behavior which is to display all failed and errored tests in
|
||||
the run.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
~/frr/tests/topotests# ./analyze.py -Ar run-save
|
||||
bgp_multiview_topo1/test_bgp_multiview_topo1.py::test_bgp_converge
|
||||
ospf_basic_functionality/test_ospf_lan.py::test_ospf_lan_tc1_p0
|
||||
bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py::test_BGP_GR_10_p2
|
||||
bgp_multiview_topo1/test_bgp_multiview_topo1.py::test_bgp_routingTable
|
||||
|
||||
Here we see that 4 tests have failed. We an dig deeper by displaying the
|
||||
captured logs and errors. First let's redisplay the results enumerated by adding
|
||||
the ``-E`` flag
|
||||
|
||||
.. code:: shell
|
||||
|
||||
~/frr/tests/topotests# ./analyze.py -Ar run-save -E
|
||||
0 bgp_multiview_topo1/test_bgp_multiview_topo1.py::test_bgp_converge
|
||||
1 ospf_basic_functionality/test_ospf_lan.py::test_ospf_lan_tc1_p0
|
||||
2 bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py::test_BGP_GR_10_p2
|
||||
3 bgp_multiview_topo1/test_bgp_multiview_topo1.py::test_bgp_routingTable
|
||||
|
||||
Now to look at the error message for a failed test we use ``-T N`` where N is
|
||||
the number of the test we are interested in along with ``--errmsg`` option.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
~/frr/tests/topotests# ./analyze.py -Ar run-save -T0 --errmsg
|
||||
bgp_multiview_topo1/test_bgp_multiview_topo1.py::test_bgp_converge: AssertionError: BGP did not converge:
|
||||
|
||||
IPv4 Unicast Summary (VIEW 1):
|
||||
BGP router identifier 172.30.1.1, local AS number 100 vrf-id -1
|
||||
BGP table version 1
|
||||
RIB entries 1, using 184 bytes of memory
|
||||
Peers 3, using 2169 KiB of memory
|
||||
|
||||
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
|
||||
172.16.1.1 4 65001 0 0 0 0 0 never Connect 0 N/A
|
||||
172.16.1.2 4 65002 0 0 0 0 0 never Connect 0 N/A
|
||||
172.16.1.5 4 65005 0 0 0 0 0 never Connect 0 N/A
|
||||
|
||||
Total number of neighbors 3
|
||||
|
||||
assert False
|
||||
|
||||
Now to look at the full text of the error for a failed test we use ``-T N``
|
||||
where N is the number of the test we are interested in along with ``--errtext``
|
||||
option.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
~/frr/tests/topotests# ./analyze.py -Ar run-save -T0 --errtext
|
||||
bgp_multiview_topo1/test_bgp_multiview_topo1.py::test_bgp_converge: def test_bgp_converge():
|
||||
"Check for BGP converged on all peers and BGP views"
|
||||
|
||||
global fatal_error
|
||||
global net
|
||||
[...]
|
||||
else:
|
||||
# Bail out with error if a router fails to converge
|
||||
bgpStatus = net["r%s" % i].cmd('vtysh -c "show ip bgp view %s summary"' % view)
|
||||
> assert False, "BGP did not converge:\n%s" % bgpStatus
|
||||
E AssertionError: BGP did not converge:
|
||||
E
|
||||
E IPv4 Unicast Summary (VIEW 1):
|
||||
E BGP router identifier 172.30.1.1, local AS number 100 vrf-id -1
|
||||
[...]
|
||||
E Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
|
||||
E 172.16.1.1 4 65001 0 0 0 0 0 never Connect 0 N/A
|
||||
E 172.16.1.2 4 65002 0 0 0 0 0 never Connect 0 N/A
|
||||
[...]
|
||||
|
||||
To look at the full capture for a test including the stdout and stderr which
|
||||
includes full debug logs, just use the ``-T N`` option without the ``--errmsg``
|
||||
or ``--errtext`` options.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
~/frr/tests/topotests# ./analyze.py -Ar run-save -T0
|
||||
@classname: bgp_multiview_topo1.test_bgp_multiview_topo1
|
||||
@name: test_bgp_converge
|
||||
@time: 141.401
|
||||
@message: AssertionError: BGP did not converge:
|
||||
[...]
|
||||
system-out: --------------------------------- Captured Log ---------------------------------
|
||||
2021-08-09 02:55:06,581 DEBUG: lib.micronet_compat.topo: Topo(unnamed): Creating
|
||||
2021-08-09 02:55:06,581 DEBUG: lib.micronet_compat.topo: Topo(unnamed): addHost r1
|
||||
[...]
|
||||
2021-08-09 02:57:16,932 DEBUG: topolog.r1: LinuxNamespace(r1): cmd_status("['/bin/bash', '-c', 'vtysh -c "show ip bgp view 1 summary" 2> /dev/null | grep ^[0-9] | grep -vP " 11\\s+(\\d+)"']", kwargs: {'encoding': 'utf-8', 'stdout': -1, 'stderr': -2, 'shell': False})
|
||||
2021-08-09 02:57:22,290 DEBUG: topolog.r1: LinuxNamespace(r1): cmd_status("['/bin/bash', '-c', 'vtysh -c "show ip bgp view 1 summary" 2> /dev/null | grep ^[0-9] | grep -vP " 11\\s+(\\d+)"']", kwargs: {'encoding': 'utf-8', 'stdout': -1, 'stderr': -2, 'shell': False})
|
||||
2021-08-09 02:57:27,636 DEBUG: topolog.r1: LinuxNamespace(r1): cmd_status("['/bin/bash', '-c', 'vtysh -c "show ip bgp view 1 summary"']", kwargs: {'encoding': 'utf-8', 'stdout': -1, 'stderr': -2, 'shell': False})
|
||||
--------------------------------- Captured Out ---------------------------------
|
||||
system-err: --------------------------------- Captured Err ---------------------------------
|
||||
|
||||
``--tb=no`` disables the python traceback which might be irrelevant unless the
|
||||
test script itself is debugged.
|
||||
|
||||
Execute single test
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
@ -161,9 +271,6 @@ Test will set exit code which can be used with ``git bisect``.
|
||||
|
||||
For the simulated topology, see the description in the python file.
|
||||
|
||||
If you need to clear the mininet setup between tests (if it isn't cleanly
|
||||
shutdown), then use the ``mn -c`` command to clean up the environment.
|
||||
|
||||
StdErr log from daemos after exit
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@ -235,18 +342,64 @@ and create ``frr`` user and ``frrvty`` group as shown above.
|
||||
Debugging Topotest Failures
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
For the below debugging options which launch programs, if the topotest is run
|
||||
within screen_ or tmux_, ``gdb``, the shell or ``vtysh`` will be launched using
|
||||
that windowing program, otherwise mininet's ``xterm`` functionality will be used
|
||||
to launch the given program.
|
||||
Install and run tests inside ``tmux`` or ``byobu`` for best results.
|
||||
|
||||
If you wish to force the use of ``xterm`` rather than ``tmux`` or ``screen``, or
|
||||
wish to use ``gnome-terminal`` instead of ``xterm``, set the environment
|
||||
variable ``FRR_TOPO_TERMINAL`` to either ``xterm`` or ``gnome-terminal``.
|
||||
``XTerm`` is also fully supported. GNU ``screen`` can be used in most
|
||||
situations; however, it does not work as well with launching ``vtysh`` or shell
|
||||
on error.
|
||||
|
||||
For the below debugging options which launch programs or CLIs, topotest should
|
||||
be run within ``tmux`` (or ``screen``)_, as ``gdb``, the shell or ``vtysh`` will
|
||||
be launched using that windowing program, otherwise ``xterm`` will be attempted
|
||||
to launch the given programs.
|
||||
|
||||
.. _screen: https://www.gnu.org/software/screen/
|
||||
.. _tmux: https://github.com/tmux/tmux/wiki
|
||||
|
||||
Spawning Debugging CLI, ``vtysh`` or Shells on Routers on Test Failure
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
One can have a debugging CLI invoked on test failures by specifying the
|
||||
``--cli-on-error`` CLI option as shown in the example below.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
pytest --cli-on-error all-protocol-startup
|
||||
|
||||
The debugging CLI can run shell or vtysh commands on any combination of routers
|
||||
It can also open shells or vtysh in their own windows for any combination of
|
||||
routers. This is usually the most useful option when debugging failures. Here is
|
||||
the help command from within a CLI launched on error:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
test_bgp_multiview_topo1/test_bgp_routingTable> help
|
||||
|
||||
Commands:
|
||||
help :: this help
|
||||
sh [hosts] <shell-command> :: execute <shell-command> on <host>
|
||||
term [hosts] :: open shell terminals for hosts
|
||||
vtysh [hosts] :: open vtysh terminals for hosts
|
||||
[hosts] <vtysh-command> :: execute vtysh-command on hosts
|
||||
|
||||
test_bgp_multiview_topo1/test_bgp_routingTable> r1 show int br
|
||||
------ Host: r1 ------
|
||||
Interface Status VRF Addresses
|
||||
--------- ------ --- ---------
|
||||
erspan0 down default
|
||||
gre0 down default
|
||||
gretap0 down default
|
||||
lo up default
|
||||
r1-eth0 up default 172.16.1.254/24
|
||||
r1-stub up default 172.20.0.1/28
|
||||
|
||||
----------------------
|
||||
test_bgp_multiview_topo1/test_bgp_routingTable>
|
||||
|
||||
Additionally, one can have ``vtysh`` or a shell launched on all routers when a
|
||||
test fails. To launch the given process on each router after a test failure
|
||||
specify one of ``--shell-on-error`` or ``--vtysh-on-error``.
|
||||
|
||||
Spawning ``vtysh`` or Shells on Routers
|
||||
"""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
@ -255,8 +408,8 @@ a test. This is enabled by specifying 1 of 2 CLI arguments ``--shell`` or
|
||||
``--vtysh``. Both of these options can be set to a single router value, multiple
|
||||
comma-seperated values, or ``all``.
|
||||
|
||||
When either of these options are specified topotest will pause after each test
|
||||
to allow for inspection of the router state.
|
||||
When either of these options are specified topotest will pause after setup and
|
||||
each test to allow for inspection of the router state.
|
||||
|
||||
Here's an example of launching ``vtysh`` on routers ``rt1`` and ``rt2``.
|
||||
|
||||
@ -264,29 +417,6 @@ Here's an example of launching ``vtysh`` on routers ``rt1`` and ``rt2``.
|
||||
|
||||
pytest --vtysh=rt1,rt2 all-protocol-startup
|
||||
|
||||
Spawning Mininet CLI, ``vtysh`` or Shells on Routers on Test Failure
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
Similar to the previous section one can have ``vtysh`` or a shell launched on
|
||||
routers, but in this case only when a test fails. To launch the given process on
|
||||
each router after a test failure specify one of ``--shell-on-error`` or
|
||||
``--vtysh-on-error``.
|
||||
|
||||
|
||||
Here's an example of having ``vtysh`` launched on test failure.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
pytest --vtysh-on-error all-protocol-startup
|
||||
|
||||
|
||||
Additionally, one can have the mininet CLI invoked on test failures by
|
||||
specifying the ``--mininet-on-error`` CLI option as shown in the example below.
|
||||
|
||||
.. code:: shell
|
||||
|
||||
pytest --mininet-on-error all-protocol-startup
|
||||
|
||||
Debugging with GDB
|
||||
""""""""""""""""""
|
||||
|
||||
@ -424,7 +554,7 @@ top level directory of topotest:
|
||||
|
||||
$ # Change to the top level directory of topotests.
|
||||
$ cd path/to/topotests
|
||||
$ # Tests must be run as root, since Mininet requires it.
|
||||
$ # Tests must be run as root, since micronet requires it.
|
||||
$ sudo pytest
|
||||
|
||||
In order to run a specific test, you can use the following command:
|
||||
@ -493,15 +623,16 @@ Some things to keep in mind:
|
||||
- Avoid including unstable data in your test: don't rely on link-local
|
||||
addresses or ifindex values, for example, because these can change
|
||||
from run to run.
|
||||
- Using sleep is almost never appropriate to wait for some convergence
|
||||
event as the sole item done. As an example: if the test resets the peers
|
||||
in BGP, the test should look for the peers reconverging instead of just
|
||||
sleeping an arbitrary amount of time and continuing on. It is ok to
|
||||
use sleep in a tight loop with appropriate show commands to ensure that
|
||||
the protocol reaches the desired state. This should be bounded by
|
||||
appropriate timeouts for the protocol in question though. See
|
||||
verify_bgp_convergence as a good example of this. If you are having
|
||||
troubles figuring out what to look for, please do not be afraid to ask.
|
||||
- Using sleep is almost never appropriate. As an example: if the test resets the
|
||||
peers in BGP, the test should look for the peers re-converging instead of just
|
||||
sleeping an arbitrary amount of time and continuing on. See
|
||||
`verify_bgp_convergence` as a good example of this. In particular look at it's
|
||||
use of the `@retry` decorator. If you are having troubles figuring out what to
|
||||
look for, please do not be afraid to ask.
|
||||
- Don't duplicate effort. There exists many protocol utility functions that can
|
||||
be found in their eponymous module under `tests/topotests/lib/` (e.g.,
|
||||
`ospf.py`)
|
||||
|
||||
|
||||
|
||||
Topotest File Hierarchy
|
||||
@ -661,25 +792,32 @@ Here is the template topology described in the previous section in python code:
|
||||
|
||||
.. code:: py
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
"Test topology builder"
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
topodef = {
|
||||
"s1": "r1"
|
||||
"s2": ("r1", "r2")
|
||||
}
|
||||
|
||||
# Create 2 routers
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router('r{}'.format(routern))
|
||||
If more specialized topology definitions, or router initialization arguments are
|
||||
required a build function can be used instead of a dictionary:
|
||||
|
||||
# Create a switch with just one router connected to it to simulate a
|
||||
# empty network.
|
||||
switch = tgen.add_switch('s1')
|
||||
switch.add_link(tgen.gears['r1'])
|
||||
.. code:: py
|
||||
|
||||
# Create a connection between r1 and r2
|
||||
switch = tgen.add_switch('s2')
|
||||
switch.add_link(tgen.gears['r1'])
|
||||
switch.add_link(tgen.gears['r2'])
|
||||
def build_topo(tgen):
|
||||
"Build function"
|
||||
|
||||
# Create 2 routers
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
# Create a switch with just one router connected to it to simulate a
|
||||
# empty network.
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
|
||||
# Create a connection between r1 and r2
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
- Run the topology
|
||||
|
||||
@ -701,8 +839,8 @@ Parameters explanation:
|
||||
|
||||
.. option:: -s
|
||||
|
||||
Actives input/output capture. This is required by mininet in order to show
|
||||
the interactive shell.
|
||||
Actives input/output capture. If this is not specified a new window will be
|
||||
opened for the interactive CLI, otherwise it will be activated inline.
|
||||
|
||||
.. option:: --topology-only
|
||||
|
||||
@ -713,110 +851,84 @@ output:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
=== test session starts ===
|
||||
platform linux2 -- Python 2.7.12, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
|
||||
rootdir: /media/sf_src/topotests, inifile: pytest.ini
|
||||
collected 3 items
|
||||
frr/tests/topotests# sudo pytest -s --topology-only ospf_topo1/test_ospf_topo1.py
|
||||
============================= test session starts ==============================
|
||||
platform linux -- Python 3.9.2, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
|
||||
rootdir: /home/chopps/w/frr/tests/topotests, configfile: pytest.ini
|
||||
plugins: forked-1.3.0, xdist-2.3.0
|
||||
collected 11 items
|
||||
|
||||
ospf-topo1/test_ospf_topo1.py *** Starting controller
|
||||
[...]
|
||||
unet>
|
||||
|
||||
*** Starting 6 switches
|
||||
switch1 switch2 switch3 switch4 switch5 switch6 ...
|
||||
r2: frr zebra started
|
||||
r2: frr ospfd started
|
||||
r3: frr zebra started
|
||||
r3: frr ospfd started
|
||||
r1: frr zebra started
|
||||
r1: frr ospfd started
|
||||
r4: frr zebra started
|
||||
r4: frr ospfd started
|
||||
*** Starting CLI:
|
||||
mininet>
|
||||
|
||||
The last line shows us that we are now using the Mininet CLI (Command Line
|
||||
The last line shows us that we are now using the CLI (Command Line
|
||||
Interface), from here you can call your router ``vtysh`` or even bash.
|
||||
|
||||
Here's the help text:
|
||||
|
||||
.. code:: shell
|
||||
unet> help
|
||||
|
||||
Commands:
|
||||
help :: this help
|
||||
sh [hosts] <shell-command> :: execute <shell-command> on <host>
|
||||
term [hosts] :: open shell terminals for hosts
|
||||
vtysh [hosts] :: open vtysh terminals for hosts
|
||||
[hosts] <vtysh-command> :: execute vtysh-command on hosts
|
||||
|
||||
.. code:: shell
|
||||
|
||||
Here are some commands example:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
mininet> r1 ping 10.0.3.1
|
||||
PING 10.0.3.1 (10.0.3.1) 56(84) bytes of data.
|
||||
64 bytes from 10.0.3.1: icmp_seq=1 ttl=64 time=0.576 ms
|
||||
64 bytes from 10.0.3.1: icmp_seq=2 ttl=64 time=0.083 ms
|
||||
64 bytes from 10.0.3.1: icmp_seq=3 ttl=64 time=0.088 ms
|
||||
^C
|
||||
--- 10.0.3.1 ping statistics ---
|
||||
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
|
||||
rtt min/avg/max/mdev = 0.083/0.249/0.576/0.231 ms
|
||||
unet> sh r1 ping 10.0.3.1
|
||||
PING 10.0.3.1 (10.0.3.1) 56(84) bytes of data.
|
||||
64 bytes from 10.0.3.1: icmp_seq=1 ttl=64 time=0.576 ms
|
||||
64 bytes from 10.0.3.1: icmp_seq=2 ttl=64 time=0.083 ms
|
||||
64 bytes from 10.0.3.1: icmp_seq=3 ttl=64 time=0.088 ms
|
||||
^C
|
||||
--- 10.0.3.1 ping statistics ---
|
||||
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
|
||||
rtt min/avg/max/mdev = 0.083/0.249/0.576/0.231 ms
|
||||
|
||||
unet> r1 show run
|
||||
Building configuration...
|
||||
|
||||
Current configuration:
|
||||
!
|
||||
frr version 8.1-dev-my-manual-build
|
||||
frr defaults traditional
|
||||
hostname r1
|
||||
log file /tmp/topotests/ospf_topo1.test_ospf_topo1/r1/zebra.log
|
||||
[...]
|
||||
end
|
||||
|
||||
mininet> r1 ping 10.0.3.3
|
||||
PING 10.0.3.3 (10.0.3.3) 56(84) bytes of data.
|
||||
64 bytes from 10.0.3.3: icmp_seq=1 ttl=64 time=2.87 ms
|
||||
64 bytes from 10.0.3.3: icmp_seq=2 ttl=64 time=0.080 ms
|
||||
64 bytes from 10.0.3.3: icmp_seq=3 ttl=64 time=0.091 ms
|
||||
^C
|
||||
--- 10.0.3.3 ping statistics ---
|
||||
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
|
||||
rtt min/avg/max/mdev = 0.080/1.014/2.872/1.313 ms
|
||||
|
||||
|
||||
|
||||
mininet> r3 vtysh
|
||||
|
||||
Hello, this is FRRouting (version 3.1-devrzalamena-build).
|
||||
Copyright 1996-2005 Kunihiro Ishiguro, et al.
|
||||
|
||||
frr-1# show running-config
|
||||
Building configuration...
|
||||
|
||||
Current configuration:
|
||||
!
|
||||
frr version 3.1-devrzalamena-build
|
||||
frr defaults traditional
|
||||
hostname r3
|
||||
no service integrated-vtysh-config
|
||||
!
|
||||
log file zebra.log
|
||||
!
|
||||
log file ospfd.log
|
||||
!
|
||||
interface r3-eth0
|
||||
ip address 10.0.3.1/24
|
||||
!
|
||||
interface r3-eth1
|
||||
ip address 10.0.10.1/24
|
||||
!
|
||||
interface r3-eth2
|
||||
ip address 172.16.0.2/24
|
||||
!
|
||||
router ospf
|
||||
ospf router-id 10.0.255.3
|
||||
redistribute kernel
|
||||
redistribute connected
|
||||
redistribute static
|
||||
network 10.0.3.0/24 area 0
|
||||
network 10.0.10.0/24 area 0
|
||||
network 172.16.0.0/24 area 1
|
||||
!
|
||||
line vty
|
||||
!
|
||||
end
|
||||
frr-1#
|
||||
unet> show daemons
|
||||
------ Host: r1 ------
|
||||
zebra ospfd ospf6d staticd
|
||||
------- End: r1 ------
|
||||
------ Host: r2 ------
|
||||
zebra ospfd ospf6d staticd
|
||||
------- End: r2 ------
|
||||
------ Host: r3 ------
|
||||
zebra ospfd ospf6d staticd
|
||||
------- End: r3 ------
|
||||
------ Host: r4 ------
|
||||
zebra ospfd ospf6d staticd
|
||||
------- End: r4 ------
|
||||
|
||||
After you successfully configured your topology, you can obtain the
|
||||
configuration files (per-daemon) using the following commands:
|
||||
|
||||
.. code:: shell
|
||||
|
||||
mininet> r3 vtysh -d ospfd
|
||||
unet> sh r3 vtysh -d ospfd
|
||||
|
||||
Hello, this is FRRouting (version 3.1-devrzalamena-build).
|
||||
Copyright 1996-2005 Kunihiro Ishiguro, et al.
|
||||
|
||||
frr-1# show running-config
|
||||
r1# show running-config
|
||||
Building configuration...
|
||||
|
||||
Current configuration:
|
||||
@ -839,7 +951,7 @@ configuration files (per-daemon) using the following commands:
|
||||
line vty
|
||||
!
|
||||
end
|
||||
frr-1#
|
||||
r1#
|
||||
|
||||
Writing Tests
|
||||
"""""""""""""
|
||||
@ -848,15 +960,12 @@ Test topologies should always be bootstrapped from
|
||||
:file:`tests/topotests/example-test/test_template.py` because it contains
|
||||
important boilerplate code that can't be avoided, like:
|
||||
|
||||
- imports: os, sys, pytest, topotest/topogen and mininet topology class
|
||||
- The global variable CWD (Current Working directory): which is most likely
|
||||
going to be used to reference the routers configuration file location
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: py
|
||||
|
||||
# For all registered routers, load the zebra configuration file
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
for rname, router in router_list.items():
|
||||
router.load_config(
|
||||
TopoRouter.RD_ZEBRA,
|
||||
@ -865,21 +974,28 @@ Example:
|
||||
# os.path.join() joins the CWD string with arguments adding the necessary
|
||||
# slashes ('/'). Arguments must not begin with '/'.
|
||||
|
||||
- The topology class that inherits from Mininet Topo class:
|
||||
- The topology definition or build function
|
||||
|
||||
.. code:: py
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
topodef = {
|
||||
"s1": ("r1", "r2"),
|
||||
"s2": ("r2", "r3")
|
||||
}
|
||||
|
||||
def build_topo(tgen):
|
||||
# topology build code
|
||||
...
|
||||
|
||||
- pytest ``setup_module()`` and ``teardown_module()`` to start the topology
|
||||
|
||||
.. code:: py
|
||||
|
||||
def setup_module(_m):
|
||||
tgen = Topogen(TemplateTopo)
|
||||
def setup_module(module):
|
||||
tgen = Topogen(topodef, module.__name__)
|
||||
# or
|
||||
tgen = Topogen(build_topo, module.__name__)
|
||||
|
||||
tgen.start_topology('debug')
|
||||
|
||||
def teardown_module(_m):
|
||||
@ -1042,11 +1158,10 @@ Example of pdb usage:
|
||||
(Pdb) router1 = tgen.gears[router]
|
||||
(Pdb) router1.vtysh_cmd('show ip ospf route')
|
||||
'============ OSPF network routing table ============\r\nN 10.0.1.0/24 [10] area: 0.0.0.0\r\n directly attached to r1-eth0\r\nN 10.0.2.0/24 [20] area: 0.0.0.0\r\n via 10.0.3.3, r1-eth1\r\nN 10.0.3.0/24 [10] area: 0.0.0.0\r\n directly attached to r1-eth1\r\nN 10.0.10.0/24 [20] area: 0.0.0.0\r\n via 10.0.3.1, r1-eth1\r\nN IA 172.16.0.0/24 [20] area: 0.0.0.0\r\n via 10.0.3.1, r1-eth1\r\nN IA 172.16.1.0/24 [30] area: 0.0.0.0\r\n via 10.0.3.1, r1-eth1\r\n\r\n============ OSPF router routing table =============\r\nR 10.0.255.2 [10] area: 0.0.0.0, ASBR\r\n via 10.0.3.3, r1-eth1\r\nR 10.0.255.3 [10] area: 0.0.0.0, ABR, ASBR\r\n via 10.0.3.1, r1-eth1\r\nR 10.0.255.4 IA [20] area: 0.0.0.0, ASBR\r\n via 10.0.3.1, r1-eth1\r\n\r\n============ OSPF external routing table ===========\r\n\r\n\r\n'
|
||||
(Pdb) tgen.mininet_cli()
|
||||
*** Starting CLI:
|
||||
mininet>
|
||||
(Pdb) tgen.cli()
|
||||
unet>
|
||||
|
||||
To enable more debug messages in other Topogen subsystems (like Mininet), more
|
||||
To enable more debug messages in other Topogen subsystems, more
|
||||
logging messages can be displayed by modifying the test configuration file
|
||||
``pytest.ini``:
|
||||
|
||||
|
@ -6,16 +6,18 @@ ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
|
||||
RUN apt update && \
|
||||
apt-get install -y \
|
||||
git autoconf automake libtool make libreadline-dev texinfo \
|
||||
pkg-config libpam0g-dev libjson-c-dev bison flex python3-pytest \
|
||||
libc-ares-dev python3-dev python-ipaddress python3-sphinx \
|
||||
pkg-config libpam0g-dev libjson-c-dev bison flex python3-pip \
|
||||
libc-ares-dev python3-dev python3-sphinx \
|
||||
install-info build-essential libsnmp-dev perl libcap-dev \
|
||||
libelf-dev \
|
||||
sudo gdb iputils-ping time \
|
||||
mininet python-pip iproute2 iperf && \
|
||||
pip install ipaddr && \
|
||||
pip install "pytest<5" && \
|
||||
pip install "scapy>=2.4.2" && \
|
||||
pip install exabgp==3.4.17
|
||||
python-pip net-tools iproute2 && \
|
||||
python3 -m pip install wheel && \
|
||||
python3 -m pip install pytest && \
|
||||
python3 -m pip install pytest-xdist && \
|
||||
python3 -m pip install "scapy>=2.4.2" && \
|
||||
python3 -m pip install xmltodict && \
|
||||
python2 -m pip install 'exabgp<4.0.0'
|
||||
|
||||
RUN groupadd -r -g 92 frr && \
|
||||
groupadd -r -g 85 frrvty && \
|
||||
|
@ -6,21 +6,23 @@ ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
|
||||
RUN apt update && \
|
||||
apt-get install -y \
|
||||
git autoconf automake libtool make libreadline-dev texinfo \
|
||||
pkg-config libpam0g-dev libjson-c-dev bison flex python3-pytest \
|
||||
libc-ares-dev python3-dev python-ipaddress python3-sphinx \
|
||||
pkg-config libpam0g-dev libjson-c-dev bison flex python3-pip \
|
||||
libc-ares-dev python3-dev python3-sphinx \
|
||||
install-info build-essential libsnmp-dev perl \
|
||||
libcap-dev python2 libelf-dev \
|
||||
sudo gdb curl iputils-ping time \
|
||||
libgrpc++-dev libgrpc-dev protobuf-compiler-grpc \
|
||||
lua5.3 liblua5.3-dev \
|
||||
mininet iproute2 iperf && \
|
||||
net-tools iproute2 && \
|
||||
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output /tmp/get-pip.py && \
|
||||
python2 /tmp/get-pip.py && \
|
||||
rm -f /tmp/get-pip.py && \
|
||||
pip2 install ipaddr && \
|
||||
pip2 install "pytest<5" && \
|
||||
pip2 install "scapy>=2.4.2" && \
|
||||
pip2 install exabgp==3.4.17
|
||||
python3 -m pip install wheel && \
|
||||
python3 -m pip install pytest && \
|
||||
python3 -m pip install pytest-xdist && \
|
||||
python3 -m pip install "scapy>=2.4.2" && \
|
||||
python3 -m pip install xmltodict && \
|
||||
python2 -m pip install 'exabgp<4.0.0'
|
||||
|
||||
RUN groupadd -r -g 92 frr && \
|
||||
groupadd -r -g 85 frrvty && \
|
||||
|
@ -34,14 +34,6 @@ import pytest
|
||||
import glob
|
||||
from time import sleep
|
||||
|
||||
from mininet.topo import Topo
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Node, OVSSwitch, Host
|
||||
from mininet.log import setLogLevel, info
|
||||
from mininet.cli import CLI
|
||||
from mininet.link import Intf
|
||||
|
||||
from functools import partial
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.babeld,
|
||||
@ -55,6 +47,7 @@ pytestmark = [
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
|
||||
fatal_error = ""
|
||||
|
||||
@ -66,24 +59,10 @@ fatal_error = ""
|
||||
#####################################################
|
||||
|
||||
|
||||
class NetworkTopo(Topo):
|
||||
"All Protocol Startup Test"
|
||||
|
||||
def build(self, **_opts):
|
||||
|
||||
# Setup Routers
|
||||
router = {}
|
||||
#
|
||||
# Setup Main Router
|
||||
router[1] = topotest.addRouter(self, "r1")
|
||||
#
|
||||
|
||||
# Setup Switches
|
||||
switch = {}
|
||||
#
|
||||
for i in range(0, 10):
|
||||
switch[i] = self.addSwitch("sw%s" % i, cls=topotest.LegacySwitch)
|
||||
self.addLink(switch[i], router[1], intfName2="r1-eth%s" % i)
|
||||
def build_topo(tgen):
|
||||
router = tgen.add_router("r1")
|
||||
for i in range(0, 10):
|
||||
tgen.add_switch("sw%d" % i).add_link(router)
|
||||
|
||||
|
||||
#####################################################
|
||||
@ -94,21 +73,16 @@ class NetworkTopo(Topo):
|
||||
|
||||
|
||||
def setup_module(module):
|
||||
global topo, net
|
||||
global fatal_error
|
||||
|
||||
print("\n\n** %s: Setup Topology" % module.__name__)
|
||||
print("******************************************\n")
|
||||
|
||||
print("Cleanup old Mininet runs")
|
||||
os.system("sudo mn -c > /dev/null 2>&1")
|
||||
os.system("sudo rm /tmp/r* > /dev/null 2>&1")
|
||||
|
||||
thisDir = os.path.dirname(os.path.realpath(__file__))
|
||||
topo = NetworkTopo()
|
||||
tgen = Topogen(build_topo, module.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
net = Mininet(controller=None, topo=topo)
|
||||
net.start()
|
||||
net = tgen.net
|
||||
|
||||
if net["r1"].get_routertype() != "frr":
|
||||
fatal_error = "Test is only implemented for FRR"
|
||||
@ -138,25 +112,22 @@ def setup_module(module):
|
||||
net["r%s" % i].loadConf("nhrpd", "%s/r%s/nhrpd.conf" % (thisDir, i))
|
||||
net["r%s" % i].loadConf("babeld", "%s/r%s/babeld.conf" % (thisDir, i))
|
||||
net["r%s" % i].loadConf("pbrd", "%s/r%s/pbrd.conf" % (thisDir, i))
|
||||
net["r%s" % i].startRouter()
|
||||
tgen.gears["r%s" % i].start()
|
||||
|
||||
# For debugging after starting FRR daemons, uncomment the next line
|
||||
# CLI(net)
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
global net
|
||||
|
||||
print("\n\n** %s: Shutdown Topology" % module.__name__)
|
||||
print("******************************************\n")
|
||||
|
||||
# End - Shutdown network
|
||||
net.stop()
|
||||
tgen = get_topogen()
|
||||
tgen.stop_topology()
|
||||
|
||||
|
||||
def test_router_running():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -177,7 +148,7 @@ def test_router_running():
|
||||
|
||||
def test_error_messages_vtysh():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -233,7 +204,7 @@ def test_error_messages_vtysh():
|
||||
|
||||
def test_error_messages_daemons():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -324,7 +295,7 @@ def test_error_messages_daemons():
|
||||
|
||||
def test_converge_protocols():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -413,6 +384,7 @@ def test_converge_protocols():
|
||||
|
||||
|
||||
def route_get_nhg_id(route_str):
|
||||
net = get_topogen().net
|
||||
output = net["r1"].cmd('vtysh -c "show ip route %s nexthop-group"' % route_str)
|
||||
match = re.search(r"Nexthop Group ID: (\d+)", output)
|
||||
assert match is not None, (
|
||||
@ -424,6 +396,7 @@ def route_get_nhg_id(route_str):
|
||||
|
||||
|
||||
def verify_nexthop_group(nhg_id, recursive=False, ecmp=0):
|
||||
net = get_topogen().net
|
||||
# Verify NHG is valid/installed
|
||||
output = net["r1"].cmd('vtysh -c "show nexthop-group rib %d"' % nhg_id)
|
||||
|
||||
@ -462,7 +435,7 @@ def verify_route_nexthop_group(route_str, recursive=False, ecmp=0):
|
||||
|
||||
def test_nexthop_groups():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -611,7 +584,7 @@ def test_nexthop_groups():
|
||||
|
||||
def test_rip_status():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -671,7 +644,7 @@ def test_rip_status():
|
||||
|
||||
def test_ripng_status():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -738,7 +711,7 @@ def test_ripng_status():
|
||||
|
||||
def test_ospfv2_interfaces():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -765,7 +738,7 @@ def test_ospfv2_interfaces():
|
||||
)
|
||||
# Mask out Bandwidth portion. They may change..
|
||||
actual = re.sub(r"BW [0-9]+ Mbit", "BW XX Mbit", actual)
|
||||
actual = re.sub(r"ifindex [0-9]", "ifindex X", actual)
|
||||
actual = re.sub(r"ifindex [0-9]+", "ifindex X", actual)
|
||||
|
||||
# Drop time in next due
|
||||
actual = re.sub(r"Hello due in [0-9\.]+s", "Hello due in XX.XXXs", actual)
|
||||
@ -823,7 +796,7 @@ def test_ospfv2_interfaces():
|
||||
|
||||
def test_isis_interfaces():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -889,7 +862,7 @@ def test_isis_interfaces():
|
||||
|
||||
def test_bgp_summary():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -906,22 +879,32 @@ def test_bgp_summary():
|
||||
# Read expected result from file
|
||||
expected_original = open(refTableFile).read().rstrip()
|
||||
|
||||
for arguments in ["", "remote-as internal", "remote-as external",
|
||||
"remote-as 100", "remote-as 123",
|
||||
"neighbor 192.168.7.10", "neighbor 192.168.7.10",
|
||||
"neighbor fc00:0:0:8::1000",
|
||||
"neighbor 10.0.0.1",
|
||||
"terse",
|
||||
"remote-as internal terse",
|
||||
"remote-as external terse",
|
||||
"remote-as 100 terse", "remote-as 123 terse",
|
||||
"neighbor 192.168.7.10 terse", "neighbor 192.168.7.10 terse",
|
||||
"neighbor fc00:0:0:8::1000 terse",
|
||||
"neighbor 10.0.0.1 terse"]:
|
||||
for arguments in [
|
||||
"",
|
||||
"remote-as internal",
|
||||
"remote-as external",
|
||||
"remote-as 100",
|
||||
"remote-as 123",
|
||||
"neighbor 192.168.7.10",
|
||||
"neighbor 192.168.7.10",
|
||||
"neighbor fc00:0:0:8::1000",
|
||||
"neighbor 10.0.0.1",
|
||||
"terse",
|
||||
"remote-as internal terse",
|
||||
"remote-as external terse",
|
||||
"remote-as 100 terse",
|
||||
"remote-as 123 terse",
|
||||
"neighbor 192.168.7.10 terse",
|
||||
"neighbor 192.168.7.10 terse",
|
||||
"neighbor fc00:0:0:8::1000 terse",
|
||||
"neighbor 10.0.0.1 terse",
|
||||
]:
|
||||
# Actual output from router
|
||||
actual = (
|
||||
net["r%s" % i]
|
||||
.cmd('vtysh -c "show ip bgp summary ' + arguments + '" 2> /dev/null')
|
||||
.cmd(
|
||||
'vtysh -c "show ip bgp summary ' + arguments + '" 2> /dev/null'
|
||||
)
|
||||
.rstrip()
|
||||
)
|
||||
|
||||
@ -950,7 +933,9 @@ def test_bgp_summary():
|
||||
actual = re.sub(r"Unknown Summary \(VRF default\):", "", actual)
|
||||
actual = re.sub(r"No Unknown neighbor is configured", "", actual)
|
||||
|
||||
actual = re.sub(r"IPv4 labeled-unicast Summary \(VRF default\):", "", actual)
|
||||
actual = re.sub(
|
||||
r"IPv4 labeled-unicast Summary \(VRF default\):", "", actual
|
||||
)
|
||||
actual = re.sub(
|
||||
r"No IPv4 labeled-unicast neighbor is configured", "", actual
|
||||
)
|
||||
@ -964,19 +949,18 @@ def test_bgp_summary():
|
||||
elif "remote-as 123" in arguments:
|
||||
expected = re.sub(
|
||||
r"(192.168.7.(1|2)0|fc00:0:0:8::(1|2)000).+Active.+",
|
||||
"", expected
|
||||
"",
|
||||
expected,
|
||||
)
|
||||
expected = re.sub(r"\nNeighbor.+Desc", "", expected)
|
||||
expected = expected + "% No matching neighbor\n"
|
||||
elif "192.168.7.10" in arguments:
|
||||
expected = re.sub(
|
||||
r"(192.168.7.20|fc00:0:0:8::(1|2)000).+Active.+",
|
||||
"", expected
|
||||
r"(192.168.7.20|fc00:0:0:8::(1|2)000).+Active.+", "", expected
|
||||
)
|
||||
elif "fc00:0:0:8::1000" in arguments:
|
||||
expected = re.sub(
|
||||
r"(192.168.7.(1|2)0|fc00:0:0:8::2000).+Active.+",
|
||||
"", expected
|
||||
r"(192.168.7.(1|2)0|fc00:0:0:8::2000).+Active.+", "", expected
|
||||
)
|
||||
elif "10.0.0.1" in arguments:
|
||||
expected = "No such neighbor in VRF default"
|
||||
@ -1002,8 +986,12 @@ def test_bgp_summary():
|
||||
|
||||
# realign expected neighbor columns if needed
|
||||
try:
|
||||
idx_actual = re.search(r"(Neighbor\s+V\s+)", actual).group(1).find("V")
|
||||
idx_expected = re.search(r"(Neighbor\s+V\s+)", expected).group(1).find("V")
|
||||
idx_actual = (
|
||||
re.search(r"(Neighbor\s+V\s+)", actual).group(1).find("V")
|
||||
)
|
||||
idx_expected = (
|
||||
re.search(r"(Neighbor\s+V\s+)", expected).group(1).find("V")
|
||||
)
|
||||
idx_diff = idx_expected - idx_actual
|
||||
if idx_diff > 0:
|
||||
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
|
||||
@ -1021,7 +1009,7 @@ def test_bgp_summary():
|
||||
diff = topotest.get_textdiff(
|
||||
actual,
|
||||
expected,
|
||||
title1="actual SHOW IP BGP SUMMARY " + arguments.upper() ,
|
||||
title1="actual SHOW IP BGP SUMMARY " + arguments.upper(),
|
||||
title2="expected SHOW IP BGP SUMMARY " + arguments.upper(),
|
||||
)
|
||||
|
||||
@ -1034,7 +1022,9 @@ def test_bgp_summary():
|
||||
else:
|
||||
print("r%s ok" % i)
|
||||
|
||||
assert failures == 0, "SHOW IP BGP SUMMARY failed for router r%s:\n%s" % (
|
||||
assert (
|
||||
failures == 0
|
||||
), "SHOW IP BGP SUMMARY failed for router r%s:\n%s" % (
|
||||
i,
|
||||
diff,
|
||||
)
|
||||
@ -1050,7 +1040,7 @@ def test_bgp_summary():
|
||||
|
||||
def test_bgp_ipv6_summary():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -1101,7 +1091,9 @@ def test_bgp_ipv6_summary():
|
||||
actual = re.sub(r"No Unknown neighbor is configured", "", actual)
|
||||
|
||||
# Remove Labeled Unicast Summary (all of it)
|
||||
actual = re.sub(r"IPv6 labeled-unicast Summary \(VRF default\):", "", actual)
|
||||
actual = re.sub(
|
||||
r"IPv6 labeled-unicast Summary \(VRF default\):", "", actual
|
||||
)
|
||||
actual = re.sub(
|
||||
r"No IPv6 labeled-unicast neighbor is configured", "", actual
|
||||
)
|
||||
@ -1145,6 +1137,7 @@ def test_bgp_ipv6_summary():
|
||||
|
||||
|
||||
def test_nht():
|
||||
net = get_topogen().net
|
||||
print("\n\n**** Test that nexthop tracking is at least nominally working ****\n")
|
||||
|
||||
thisDir = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -1155,7 +1148,7 @@ def test_nht():
|
||||
expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
actual = net["r%s" % i].cmd('vtysh -c "show ip nht" 2> /dev/null').rstrip()
|
||||
actual = re.sub(r"fd [0-9][0-9]", "fd XX", actual)
|
||||
actual = re.sub(r"fd [0-9]+", "fd XX", actual)
|
||||
actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
diff = topotest.get_textdiff(
|
||||
@ -1175,7 +1168,7 @@ def test_nht():
|
||||
expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
actual = net["r%s" % i].cmd('vtysh -c "show ipv6 nht" 2> /dev/null').rstrip()
|
||||
actual = re.sub(r"fd [0-9][0-9]", "fd XX", actual)
|
||||
actual = re.sub(r"fd [0-9]+", "fd XX", actual)
|
||||
actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
diff = topotest.get_textdiff(
|
||||
@ -1193,7 +1186,7 @@ def test_nht():
|
||||
|
||||
def test_bgp_ipv4():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -1263,7 +1256,7 @@ def test_bgp_ipv4():
|
||||
|
||||
def test_bgp_ipv6():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -1332,7 +1325,7 @@ def test_bgp_ipv6():
|
||||
|
||||
def test_route_map():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
if fatal_error != "":
|
||||
pytest.skip(fatal_error)
|
||||
@ -1375,7 +1368,7 @@ def test_route_map():
|
||||
|
||||
def test_nexthop_groups_with_route_maps():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -1418,7 +1411,7 @@ def test_nexthop_groups_with_route_maps():
|
||||
net["r1"].cmd('vtysh -c "sharp remove routes %s 1"' % route_str)
|
||||
net["r1"].cmd('vtysh -c "c t" -c "no ip protocol sharp route-map NH-SRC"')
|
||||
net["r1"].cmd(
|
||||
'vtysh -c "c t" -c "no route-map NH-SRC permit 111" -c "set src %s"' % src_str
|
||||
'vtysh -c "c t" -c "no route-map NH-SRC permit 111" # -c "set src %s"' % src_str
|
||||
)
|
||||
net["r1"].cmd('vtysh -c "c t" -c "no route-map NH-SRC"')
|
||||
|
||||
@ -1472,7 +1465,7 @@ def test_nexthop_groups_with_route_maps():
|
||||
|
||||
def test_nexthop_group_replace():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -1505,7 +1498,7 @@ def test_nexthop_group_replace():
|
||||
|
||||
def test_mpls_interfaces():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -1574,7 +1567,7 @@ def test_mpls_interfaces():
|
||||
|
||||
def test_shutdown_check_stderr():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -1637,7 +1630,7 @@ def test_shutdown_check_stderr():
|
||||
|
||||
def test_shutdown_check_memleak():
|
||||
global fatal_error
|
||||
global net
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
@ -1659,8 +1652,6 @@ def test_shutdown_check_memleak():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
setLogLevel("info")
|
||||
# To suppress tracebacks, either use the following pytest call or add "--tb=no" to cli
|
||||
# retval = pytest.main(["-s", "--tb=no"])
|
||||
retval = pytest.main(["-s"])
|
||||
|
265
tests/topotests/analyze.py
Executable file
265
tests/topotests/analyze.py
Executable file
@ -0,0 +1,265 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 eval: (blacken-mode 1) -*-
|
||||
#
|
||||
# July 9 2021, Christian Hopps <chopps@labn.net>
|
||||
#
|
||||
# Copyright (c) 2021, LabN Consulting, L.L.C.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; see the file COPYING; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
import argparse
|
||||
import glob
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
|
||||
import xmltodict
|
||||
|
||||
|
||||
def get_summary(results):
|
||||
ntest = int(results["@tests"])
|
||||
nfail = int(results["@failures"])
|
||||
nerror = int(results["@errors"])
|
||||
nskip = int(results["@skipped"])
|
||||
npass = ntest - nfail - nskip - nerror
|
||||
return ntest, npass, nfail, nerror, nskip
|
||||
|
||||
|
||||
def print_summary(results, args):
|
||||
ntest, npass, nfail, nerror, nskip = (0, 0, 0, 0, 0)
|
||||
for group in results:
|
||||
_ntest, _npass, _nfail, _nerror, _nskip = get_summary(results[group])
|
||||
if args.verbose:
|
||||
print(
|
||||
f"Group: {group} Total: {_ntest} PASSED: {_npass}"
|
||||
" FAIL: {_nfail} ERROR: {_nerror} SKIP: {_nskip}"
|
||||
)
|
||||
ntest += _ntest
|
||||
npass += _npass
|
||||
nfail += _nfail
|
||||
nerror += _nerror
|
||||
nskip += _nskip
|
||||
print(f"Total: {ntest} PASSED: {npass} FAIL: {nfail} ERROR: {nerror} SKIP: {nskip}")
|
||||
|
||||
|
||||
def get_global_testcase(results):
|
||||
for group in results:
|
||||
for testcase in results[group]["testcase"]:
|
||||
if "@file" not in testcase:
|
||||
return testcase
|
||||
return None
|
||||
|
||||
|
||||
def get_filtered(tfilters, results, args):
|
||||
if isinstance(tfilters, str) or tfilters is None:
|
||||
tfilters = [tfilters]
|
||||
found_files = OrderedDict()
|
||||
for group in results:
|
||||
if isinstance(results[group]["testcase"], list):
|
||||
tlist = results[group]["testcase"]
|
||||
else:
|
||||
tlist = [results[group]["testcase"]]
|
||||
for testcase in tlist:
|
||||
for tfilter in tfilters:
|
||||
if tfilter is None:
|
||||
if (
|
||||
"failure" not in testcase
|
||||
and "error" not in testcase
|
||||
and "skipped" not in testcase
|
||||
):
|
||||
break
|
||||
elif tfilter in testcase:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
# cname = testcase["@classname"]
|
||||
fname = testcase.get("@file", "")
|
||||
cname = testcase.get("@classname", "")
|
||||
if not fname and not cname:
|
||||
name = testcase.get("@name", "")
|
||||
if not name:
|
||||
continue
|
||||
# If we had a failure at the module level we could be here.
|
||||
fname = name.replace(".", "/") + ".py"
|
||||
tcname = fname
|
||||
else:
|
||||
if not fname:
|
||||
fname = cname.replace(".", "/") + ".py"
|
||||
if args.files_only or "@name" not in testcase:
|
||||
tcname = fname
|
||||
else:
|
||||
tcname = fname + "::" + testcase["@name"]
|
||||
found_files[tcname] = testcase
|
||||
return found_files
|
||||
|
||||
|
||||
def dump_testcase(testcase):
|
||||
expand_keys = ("failure", "error", "skipped")
|
||||
|
||||
s = ""
|
||||
for key, val in testcase.items():
|
||||
if isinstance(val, str) or isinstance(val, float) or isinstance(val, int):
|
||||
s += "{}: {}\n".format(key, val)
|
||||
else:
|
||||
for k2, v2 in val.items():
|
||||
s += "{}: {}\n".format(k2, v2)
|
||||
return s
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-A",
|
||||
"--save",
|
||||
action="store_true",
|
||||
help="Save /tmp/topotests{,.xml} in --rundir if --rundir does not yet exist",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-F",
|
||||
"--files-only",
|
||||
action="store_true",
|
||||
help="print test file names rather than individual full testcase names",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-S",
|
||||
"--select",
|
||||
default="fe",
|
||||
help="select results combination of letters: 'e'rrored 'f'ailed 'p'assed 's'kipped.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-r",
|
||||
"--results",
|
||||
help="xml results file or directory containing xml results file",
|
||||
)
|
||||
parser.add_argument("--rundir", help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
"-E",
|
||||
"--enumerate",
|
||||
action="store_true",
|
||||
help="enumerate each item (results scoped)",
|
||||
)
|
||||
parser.add_argument("-T", "--test", help="print testcase at enumeration")
|
||||
parser.add_argument(
|
||||
"--errmsg", action="store_true", help="print testcase error message"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--errtext", action="store_true", help="print testcase error text"
|
||||
)
|
||||
parser.add_argument("--time", action="store_true", help="print testcase run times")
|
||||
|
||||
parser.add_argument("-s", "--summary", action="store_true", help="print summary")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", help="be verbose")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.save and args.results and not os.path.exists(args.results):
|
||||
if not os.path.exists("/tmp/topotests"):
|
||||
logging.critical('No "/tmp/topotests" directory to save')
|
||||
sys.exit(1)
|
||||
subprocess.run(["mv", "/tmp/topotests", args.results])
|
||||
# # Old location for results
|
||||
# if os.path.exists("/tmp/topotests.xml", args.results):
|
||||
# subprocess.run(["mv", "/tmp/topotests.xml", args.results])
|
||||
|
||||
assert (
|
||||
args.test is None or not args.files_only
|
||||
), "Can't have both --files and --test"
|
||||
|
||||
results = {}
|
||||
ttfiles = []
|
||||
if args.rundir:
|
||||
basedir = os.path.realpath(args.rundir)
|
||||
os.chdir(basedir)
|
||||
|
||||
newfiles = glob.glob("tt-group-*/topotests.xml")
|
||||
if newfiles:
|
||||
ttfiles.extend(newfiles)
|
||||
if os.path.exists("topotests.xml"):
|
||||
ttfiles.append("topotests.xml")
|
||||
else:
|
||||
if args.results:
|
||||
if os.path.exists(os.path.join(args.results, "topotests.xml")):
|
||||
args.results = os.path.join(args.results, "topotests.xml")
|
||||
if not os.path.exists(args.results):
|
||||
logging.critical("%s doesn't exist", args.results)
|
||||
sys.exit(1)
|
||||
ttfiles = [args.results]
|
||||
|
||||
if not ttfiles and os.path.exists("/tmp/topotests.xml"):
|
||||
ttfiles.append("/tmp/topotests.xml")
|
||||
|
||||
for f in ttfiles:
|
||||
m = re.match(r"tt-group-(\d+)/topotests.xml", f)
|
||||
group = int(m.group(1)) if m else 0
|
||||
with open(f) as xml_file:
|
||||
results[group] = xmltodict.parse(xml_file.read())["testsuites"]["testsuite"]
|
||||
|
||||
filters = []
|
||||
if "e" in args.select:
|
||||
filters.append("error")
|
||||
if "f" in args.select:
|
||||
filters.append("failure")
|
||||
if "s" in args.select:
|
||||
filters.append("skipped")
|
||||
if "p" in args.select:
|
||||
filters.append(None)
|
||||
|
||||
found_files = get_filtered(filters, results, args)
|
||||
if found_files:
|
||||
if args.test is not None:
|
||||
if args.test == "all":
|
||||
keys = found_files.keys()
|
||||
else:
|
||||
keys = [list(found_files.keys())[int(args.test)]]
|
||||
for key in keys:
|
||||
testcase = found_files[key]
|
||||
if args.errtext:
|
||||
if "error" in testcase:
|
||||
errmsg = testcase["error"]["#text"]
|
||||
elif "failure" in testcase:
|
||||
errmsg = testcase["failure"]["#text"]
|
||||
else:
|
||||
errmsg = "none found"
|
||||
s = "{}: {}".format(key, errmsg)
|
||||
elif args.time:
|
||||
text = testcase["@time"]
|
||||
s = "{}: {}".format(text, key)
|
||||
elif args.errmsg:
|
||||
if "error" in testcase:
|
||||
errmsg = testcase["error"]["@message"]
|
||||
elif "failure" in testcase:
|
||||
errmsg = testcase["failure"]["@message"]
|
||||
else:
|
||||
errmsg = "none found"
|
||||
s = "{}: {}".format(key, errmsg)
|
||||
else:
|
||||
s = dump_testcase(testcase)
|
||||
print(s)
|
||||
elif filters:
|
||||
if args.enumerate:
|
||||
print(
|
||||
"\n".join(["{} {}".format(i, x) for i, x in enumerate(found_files)])
|
||||
)
|
||||
else:
|
||||
print("\n".join(found_files))
|
||||
|
||||
if args.summary:
|
||||
print_summary(results, args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -41,35 +41,16 @@ 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
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.bfdd]
|
||||
|
||||
|
||||
class BFDTopo(Topo):
|
||||
"Test topology builder"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Create 4 routers.
|
||||
for routern in range(1, 4):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(BFDTopo, mod.__name__)
|
||||
topodef = {
|
||||
"s1": ("r1", "r2"),
|
||||
"s2": ("r2", "r3"),
|
||||
}
|
||||
tgen = Topogen(topodef, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -72,9 +72,7 @@ import os
|
||||
import sys
|
||||
import pytest
|
||||
import json
|
||||
import re
|
||||
from time import sleep
|
||||
from time import time
|
||||
from functools import partial
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -87,52 +85,19 @@ 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
|
||||
|
||||
pytestmark = [pytest.mark.bfdd, pytest.mark.isisd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
"Test topology builder"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
#
|
||||
# Define FRR Routers
|
||||
#
|
||||
for router in ["rt1", "rt2", "rt3", "rt4", "rt5"]:
|
||||
tgen.add_router(router)
|
||||
|
||||
#
|
||||
# Define connections
|
||||
#
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2")
|
||||
switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1")
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3")
|
||||
switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1")
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["rt2"], nodeif="eth-rt5")
|
||||
switch.add_link(tgen.gears["rt5"], nodeif="eth-rt2")
|
||||
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["rt3"], nodeif="eth-rt4")
|
||||
switch.add_link(tgen.gears["rt4"], nodeif="eth-rt3")
|
||||
|
||||
switch = tgen.add_switch("s5")
|
||||
switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
|
||||
switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
topodef = {
|
||||
"s1": ("rt1:eth-rt2", "rt2:eth-rt1"),
|
||||
"s2": ("rt1:eth-rt3", "rt3:eth-rt1"),
|
||||
"s3": ("rt2:eth-rt5", "rt5:eth-rt2"),
|
||||
"s4": ("rt3:eth-rt4", "rt4:eth-rt3"),
|
||||
"s5": ("rt4:eth-rt5", "rt5:eth-rt4"),
|
||||
}
|
||||
tgen = Topogen(topodef, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -72,9 +72,7 @@ import os
|
||||
import sys
|
||||
import pytest
|
||||
import json
|
||||
import re
|
||||
from time import sleep
|
||||
from time import time
|
||||
from functools import partial
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -87,58 +85,25 @@ 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
|
||||
|
||||
pytestmark = [pytest.mark.bfdd, pytest.mark.ospfd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
"Test topology builder"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
#
|
||||
# Define FRR Routers
|
||||
#
|
||||
for router in ["rt1", "rt2", "rt3", "rt4", "rt5"]:
|
||||
tgen.add_router(router)
|
||||
|
||||
#
|
||||
# Define connections
|
||||
#
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["rt1"], nodeif="eth-rt2")
|
||||
switch.add_link(tgen.gears["rt2"], nodeif="eth-rt1")
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["rt1"], nodeif="eth-rt3")
|
||||
switch.add_link(tgen.gears["rt3"], nodeif="eth-rt1")
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["rt2"], nodeif="eth-rt5")
|
||||
switch.add_link(tgen.gears["rt5"], nodeif="eth-rt2")
|
||||
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["rt3"], nodeif="eth-rt4")
|
||||
switch.add_link(tgen.gears["rt4"], nodeif="eth-rt3")
|
||||
|
||||
switch = tgen.add_switch("s5")
|
||||
switch.add_link(tgen.gears["rt4"], nodeif="eth-rt5")
|
||||
switch.add_link(tgen.gears["rt5"], nodeif="eth-rt4")
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
topodef = {
|
||||
"s1": ("rt1:eth-rt2", "rt2:eth-rt1"),
|
||||
"s2": ("rt1:eth-rt3", "rt3:eth-rt1"),
|
||||
"s3": ("rt2:eth-rt5", "rt5:eth-rt2"),
|
||||
"s4": ("rt3:eth-rt4", "rt4:eth-rt3"),
|
||||
"s5": ("rt4:eth-rt5", "rt5:eth-rt4"),
|
||||
}
|
||||
tgen = Topogen(topodef, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
||||
# For all registered routers, load the zebra configuration file
|
||||
for rname, router in router_list.iteritems():
|
||||
for rname, router in router_list.items():
|
||||
router.load_config(
|
||||
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
|
||||
)
|
||||
|
@ -42,47 +42,20 @@ 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
|
||||
|
||||
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.ospfd]
|
||||
|
||||
|
||||
class BFDProfTopo(Topo):
|
||||
"Test topology builder"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Create 6 routers
|
||||
for routern in range(1, 7):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
switch.add_link(tgen.gears["r5"])
|
||||
|
||||
switch = tgen.add_switch("s5")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r6"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(BFDProfTopo, mod.__name__)
|
||||
|
||||
topodef = {
|
||||
"s1": ("r1", "r2"),
|
||||
"s2": ("r2", "r3"),
|
||||
"s3": ("r3", "r4"),
|
||||
"s4": ("r4", "r5"),
|
||||
"s5": ("r1", "r6"),
|
||||
}
|
||||
tgen = Topogen(topodef, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -42,39 +42,17 @@ 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
|
||||
|
||||
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd]
|
||||
|
||||
|
||||
class BFDTopo(Topo):
|
||||
"Test topology builder"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Create 4 routers
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(BFDTopo, mod.__name__)
|
||||
topodef = {
|
||||
"s1": ("r1", "r2"),
|
||||
"s2": ("r2", "r3"),
|
||||
"s3": ("r2", "r4"),
|
||||
}
|
||||
tgen = Topogen(topodef, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -43,39 +43,17 @@ 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
|
||||
|
||||
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd, pytest.mark.ospfd]
|
||||
|
||||
|
||||
class BFDTopo(Topo):
|
||||
"Test topology builder"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Create 4 routers.
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(BFDTopo, mod.__name__)
|
||||
topodef = {
|
||||
"s1": ("r1", "r2"),
|
||||
"s2": ("r2", "r3"),
|
||||
"s3": ("r2", "r4"),
|
||||
}
|
||||
tgen = Topogen(topodef, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -42,39 +42,17 @@ 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
|
||||
|
||||
pytestmark = [pytest.mark.bfdd, pytest.mark.bgpd]
|
||||
|
||||
|
||||
class BFDTopo(Topo):
|
||||
"Test topology builder"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Create 4 routers
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(BFDTopo, mod.__name__)
|
||||
topodef = {
|
||||
"s1": ("r1", "r2"),
|
||||
"s2": ("r2", "r3"),
|
||||
"s3": ("r3", "r4"),
|
||||
}
|
||||
tgen = Topogen(topodef, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -44,38 +44,31 @@ 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.bfdd, pytest.mark.bgpd]
|
||||
|
||||
|
||||
class BFDTopo(Topo):
|
||||
"Test topology builder"
|
||||
def build_topo(tgen):
|
||||
# Create 4 routers
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
# Create 4 routers
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(BFDTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
@ -94,24 +87,14 @@ def setup_module(mod):
|
||||
|
||||
logger.info("Testing with VRF Namespace support")
|
||||
|
||||
cmds = [
|
||||
"if [ -e /var/run/netns/{0}-bfd-cust1 ] ; then ip netns del {0}-bfd-cust1 ; fi",
|
||||
"ip netns add {0}-bfd-cust1",
|
||||
"ip link set dev {0}-eth0 netns {0}-bfd-cust1 up",
|
||||
]
|
||||
cmds2 = [
|
||||
"ip link set dev {0}-eth1 netns {0}-bfd-cust1",
|
||||
"ip netns exec {0}-bfd-cust1 ip link set {0}-eth1 up",
|
||||
"ip link set dev {0}-eth2 netns {0}-bfd-cust1 up",
|
||||
]
|
||||
|
||||
for rname, router in router_list.items():
|
||||
# create VRF rx-bfd-cust1 and link rx-eth0 to rx-bfd-cust1
|
||||
for cmd in cmds:
|
||||
output = tgen.net[rname].cmd(cmd.format(rname))
|
||||
ns = "{}-bfd-cust1".format(rname)
|
||||
router.net.add_netns(ns)
|
||||
router.net.set_intf_netns(rname + "-eth0", ns, up=True)
|
||||
if rname == "r2":
|
||||
for cmd in cmds2:
|
||||
output = tgen.net[rname].cmd(cmd.format(rname))
|
||||
router.net.set_intf_netns(rname + "-eth1", ns, up=True)
|
||||
router.net.set_intf_netns(rname + "-eth2", ns, up=True)
|
||||
|
||||
for rname, router in router_list.items():
|
||||
router.load_config(
|
||||
@ -133,24 +116,15 @@ def setup_module(mod):
|
||||
def teardown_module(_mod):
|
||||
"Teardown the pytest environment"
|
||||
tgen = get_topogen()
|
||||
# move back rx-eth0 to default VRF
|
||||
# delete rx-vrf
|
||||
cmds = [
|
||||
"ip netns exec {0}-bfd-cust1 ip link set {0}-eth0 netns 1",
|
||||
"ip netns delete {0}-bfd-cust1",
|
||||
]
|
||||
cmds2 = [
|
||||
"ip netns exec {0}-bfd-cust1 ip link set {0}-eth1 netns 1",
|
||||
"ip netns exec {0}-cust2 ip link set {0}-eth1 netns 1",
|
||||
]
|
||||
|
||||
# Move interfaces out of vrf namespace and delete the namespace
|
||||
router_list = tgen.routers()
|
||||
for rname, router in router_list.items():
|
||||
if rname == "r2":
|
||||
for cmd in cmds2:
|
||||
tgen.net[rname].cmd(cmd.format(rname))
|
||||
for cmd in cmds:
|
||||
tgen.net[rname].cmd(cmd.format(rname))
|
||||
router.net.reset_intf_netns(rname + "-eth2")
|
||||
router.net.reset_intf_netns(rname + "-eth1")
|
||||
router.net.reset_intf_netns(rname + "-eth0")
|
||||
router.net.delete_netns("{}-bfd-cust1".format(rname))
|
||||
tgen.stop_topology()
|
||||
|
||||
|
||||
|
@ -34,7 +34,6 @@ router bgp 65031
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -44,26 +43,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -37,7 +37,6 @@ route-map aggr-rmap permit 10
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -47,26 +46,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -28,8 +28,6 @@ Test BGP aggregate address features.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -40,32 +38,26 @@ 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 mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class BgpAggregateAddressTopo1(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
r1 = tgen.add_router("r1")
|
||||
r2 = tgen.add_router("r2")
|
||||
peer1 = tgen.add_exabgp_peer("peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1")
|
||||
|
||||
r1 = tgen.add_router("r1")
|
||||
r2 = tgen.add_router("r2")
|
||||
peer1 = tgen.add_exabgp_peer(
|
||||
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
||||
)
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(peer1)
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(peer1)
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(r2)
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(r2)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(BgpAggregateAddressTopo1, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router = tgen.gears["r1"]
|
||||
|
@ -27,7 +27,6 @@ is continued to be processed, but AGGREGATOR attribute is discarded.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -37,28 +36,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class BgpAggregatorAsnZero(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
r1 = tgen.add_router("r1")
|
||||
peer1 = tgen.add_exabgp_peer("peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1")
|
||||
|
||||
r1 = tgen.add_router("r1")
|
||||
peer1 = tgen.add_exabgp_peer(
|
||||
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
||||
)
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(peer1)
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(peer1)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(BgpAggregatorAsnZero, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router = tgen.gears["r1"]
|
||||
|
@ -51,7 +51,6 @@ sys.path.append(os.path.join(CWD, "../lib/"))
|
||||
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from mininet.topo import Topo
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
|
||||
# Import topoJson from lib, to create topology and initial configuration
|
||||
@ -71,7 +70,6 @@ from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
clear_bgp_and_verify,
|
||||
verify_bgp_rib,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
@ -94,19 +92,11 @@ NETWORK = {"ipv4": "2.2.2.2/32", "ipv6": "22:22::2/128"}
|
||||
NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
|
||||
|
||||
|
||||
class BGPALLOWASIN(Topo):
|
||||
"""
|
||||
Test BGPALLOWASIN - topology 1
|
||||
def build_topo(tgen):
|
||||
"""Build function"""
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function"""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
@ -128,7 +118,7 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(BGPALLOWASIN, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
@ -251,9 +241,11 @@ def test_bgp_allowas_in_p0(request):
|
||||
protocol=protocol,
|
||||
expected=False,
|
||||
)
|
||||
assert result is not True, "Testcase {} : Failed \n"
|
||||
"Expected behavior: routes should not present in rib \n"
|
||||
"Error: {}".format(tc_name, result)
|
||||
assert result is not True, (
|
||||
"Testcase {} : Failed \n".format(tc_name)
|
||||
+ "Expected behavior: routes should not present in rib \n"
|
||||
+ "Error: {}".format(result)
|
||||
)
|
||||
|
||||
step("Configure allowas-in on R3 for R2.")
|
||||
step("We should see the prefix advertised from R1 in R3's BGP table.")
|
||||
@ -396,9 +388,11 @@ def test_bgp_allowas_in_per_addr_family_p0(request):
|
||||
result = verify_rib(
|
||||
tgen, "ipv6", dut, static_route_ipv6, protocol=protocol, expected=False
|
||||
)
|
||||
assert result is not True, "Testcase {} : Failed \n"
|
||||
"Expected behavior: routes are should not be present in ipv6 rib\n"
|
||||
" Error: {}".format(tc_name, result)
|
||||
assert result is not True, (
|
||||
"Testcase {} : Failed \n".format(tc_name)
|
||||
+ "Expected behavior: routes are should not be present in ipv6 rib\n"
|
||||
+ " Error: {}".format(result)
|
||||
)
|
||||
|
||||
step("Repeat the same test for IPv6 AFI.")
|
||||
step("Configure allowas-in on R3 for R2 under IPv6 addr-family only")
|
||||
@ -444,9 +438,11 @@ def test_bgp_allowas_in_per_addr_family_p0(request):
|
||||
result = verify_rib(
|
||||
tgen, "ipv4", dut, static_route_ipv4, protocol=protocol, expected=False
|
||||
)
|
||||
assert result is not True, "Testcase {} : Failed \n"
|
||||
"Expected behavior: routes should not be present in ipv4 rib\n"
|
||||
" Error: {}".format(tc_name, result)
|
||||
assert result is not True, (
|
||||
"Testcase {} : Failed \n".format(tc_name)
|
||||
+ "Expected behavior: routes should not be present in ipv4 rib\n"
|
||||
+ " Error: {}".format(result)
|
||||
)
|
||||
result = verify_rib(tgen, "ipv6", dut, static_route_ipv6, protocol=protocol)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
|
||||
|
||||
@ -598,9 +594,11 @@ def test_bgp_allowas_in_no_of_occurrences_p0(request):
|
||||
result = verify_rib(
|
||||
tgen, addr_type, dut, static_routes, protocol=protocol, expected=False
|
||||
)
|
||||
assert result is not True, "Testcase {} : Failed \n "
|
||||
"Expected behavior: routes are should not be present in rib\n"
|
||||
"Error: {}".format(tc_name, result)
|
||||
assert result is not True, (
|
||||
"Testcase {} : Failed \n ".format(tc_name)
|
||||
+ "Expected behavior: routes are should not be present in rib\n"
|
||||
+ "Error: {}".format(result)
|
||||
)
|
||||
|
||||
for addr_type in ADDR_TYPES:
|
||||
step('Configure "allowas-in 5" on R3 for R2.')
|
||||
|
@ -32,7 +32,6 @@ affected and should work.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -42,27 +41,22 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 4):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 4):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -27,7 +27,6 @@ is threated as withdrawal.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -37,28 +36,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class BgpAggregatorAsnZero(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
r1 = tgen.add_router("r1")
|
||||
peer1 = tgen.add_exabgp_peer("peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1")
|
||||
|
||||
r1 = tgen.add_router("r1")
|
||||
peer1 = tgen.add_exabgp_peer(
|
||||
"peer1", ip="10.0.0.2", defaultRoute="via 10.0.0.1"
|
||||
)
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(peer1)
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(peer1)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(BgpAggregatorAsnZero, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router = tgen.gears["r1"]
|
||||
|
@ -48,7 +48,6 @@ import os
|
||||
import sys
|
||||
import json
|
||||
import platform
|
||||
from functools import partial
|
||||
import pytest
|
||||
from time import sleep
|
||||
|
||||
@ -60,12 +59,9 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# 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
|
||||
|
||||
from lib.common_config import apply_raw_config
|
||||
|
||||
ERROR_LIST = ["Malformed", "Failure", "Unknown", "Incomplete"]
|
||||
|
||||
@ -75,75 +71,63 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
|
||||
class InvalidCLIError(Exception):
|
||||
"""Raise when the CLI command is wrong"""
|
||||
|
||||
pass
|
||||
|
||||
def build_topo(tgen):
|
||||
# Create routers
|
||||
tgen.add_router("R1")
|
||||
tgen.add_router("R2")
|
||||
tgen.add_router("R3")
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
"Test topology builder"
|
||||
# R1-R2 1
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
# R1-R3 1
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
|
||||
# This function only purpose is to define allocation and relationship
|
||||
# between routers, switches and hosts.
|
||||
#
|
||||
#
|
||||
# Create routers
|
||||
tgen.add_router("R1")
|
||||
tgen.add_router("R2")
|
||||
tgen.add_router("R3")
|
||||
# R2-R3 1
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
|
||||
# R1-R2 1
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
# R1-R2 2
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
|
||||
# R1-R3 1
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
# R1-R3 2
|
||||
switch = tgen.add_switch("s5")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
|
||||
# R2-R3 1
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
# R2-R3 2
|
||||
switch = tgen.add_switch("s6")
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
|
||||
# R1-R2 2
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
# R1-R2 3
|
||||
switch = tgen.add_switch("s7")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
|
||||
# R1-R3 2
|
||||
switch = tgen.add_switch("s5")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
# R1-R3 2
|
||||
switch = tgen.add_switch("s8")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
|
||||
# R2-R3 2
|
||||
switch = tgen.add_switch("s6")
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
|
||||
# R1-R2 3
|
||||
switch = tgen.add_switch("s7")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
|
||||
# R1-R3 2
|
||||
switch = tgen.add_switch("s8")
|
||||
switch.add_link(tgen.gears["R1"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
|
||||
# R2-R3 2
|
||||
switch = tgen.add_switch("s9")
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
# R2-R3 2
|
||||
switch = tgen.add_switch("s9")
|
||||
switch.add_link(tgen.gears["R2"])
|
||||
switch.add_link(tgen.gears["R3"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
tgen.start_topology()
|
||||
|
||||
|
@ -40,10 +40,11 @@ Test steps
|
||||
- Verify routes not installed in zebra when /32 routes received
|
||||
with loopback BGP session subnet
|
||||
"""
|
||||
# XXX clean up in later commit to avoid conflict on rebase
|
||||
# pylint: disable=C0413
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
from copy import deepcopy
|
||||
@ -55,53 +56,44 @@ sys.path.append(os.path.join(CWD, "../lib/"))
|
||||
|
||||
# Required to instantiate the topology builder class.
|
||||
|
||||
from lib.bgp import (
|
||||
clear_bgp_and_verify,
|
||||
create_router_bgp,
|
||||
modify_as_number,
|
||||
verify_as_numbers,
|
||||
verify_bgp_convergence,
|
||||
verify_bgp_rib,
|
||||
verify_bgp_timers_and_functionality,
|
||||
verify_router_id,
|
||||
)
|
||||
from lib.common_config import (
|
||||
addKernelRoute,
|
||||
apply_raw_config,
|
||||
check_address_types,
|
||||
create_prefix_lists,
|
||||
create_route_maps,
|
||||
create_static_routes,
|
||||
required_linux_kernel_version,
|
||||
reset_config_on_routers,
|
||||
start_topology,
|
||||
step,
|
||||
verify_admin_distance_for_static_routes,
|
||||
verify_bgp_community,
|
||||
verify_fib_routes,
|
||||
verify_rib,
|
||||
write_test_footer,
|
||||
write_test_header,
|
||||
)
|
||||
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
step,
|
||||
start_topology,
|
||||
write_test_header,
|
||||
write_test_footer,
|
||||
reset_config_on_routers,
|
||||
create_static_routes,
|
||||
verify_rib,
|
||||
verify_admin_distance_for_static_routes,
|
||||
check_address_types,
|
||||
apply_raw_config,
|
||||
addKernelRoute,
|
||||
verify_fib_routes,
|
||||
create_prefix_lists,
|
||||
create_route_maps,
|
||||
verify_bgp_community,
|
||||
required_linux_kernel_version,
|
||||
)
|
||||
from lib.topojson import build_config_from_json
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
verify_router_id,
|
||||
modify_as_number,
|
||||
verify_as_numbers,
|
||||
clear_bgp_and_verify,
|
||||
verify_bgp_timers_and_functionality,
|
||||
verify_bgp_rib,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology creation
|
||||
jsonFile = "{}/bgp_basic_functionality.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global Variable
|
||||
KEEPALIVETIMER = 2
|
||||
HOLDDOWNTIMER = 6
|
||||
@ -119,21 +111,6 @@ NETWORK = {
|
||||
}
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test BasicTopo - topology 1
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function"""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -153,7 +130,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/bgp_basic_functionality.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
@ -198,7 +178,7 @@ def teardown_module():
|
||||
|
||||
|
||||
def test_modify_and_delete_router_id(request):
|
||||
""" Test to modify, delete and verify router-id. """
|
||||
"""Test to modify, delete and verify router-id."""
|
||||
|
||||
tgen = get_topogen()
|
||||
if BGP_CONVERGENCE is not True:
|
||||
@ -316,11 +296,9 @@ def test_BGP_config_with_invalid_ASN_p2(request):
|
||||
},
|
||||
}
|
||||
result = modify_as_number(tgen, topo, input_dict)
|
||||
assert result is not True, (
|
||||
"Expected BGP config is not created because of invalid ASNs: {}".format(
|
||||
result
|
||||
)
|
||||
)
|
||||
assert (
|
||||
result is not True
|
||||
), "Expected BGP config is not created because of invalid ASNs: {}".format(result)
|
||||
|
||||
# Creating configuration from JSON
|
||||
reset_config_on_routers(tgen)
|
||||
@ -430,7 +408,7 @@ def test_bgp_timers_functionality(request):
|
||||
|
||||
|
||||
def test_static_routes(request):
|
||||
""" Test to create and verify static routes. """
|
||||
"""Test to create and verify static routes."""
|
||||
|
||||
tgen = get_topogen()
|
||||
if BGP_CONVERGENCE is not True:
|
||||
@ -493,7 +471,7 @@ def test_static_routes(request):
|
||||
|
||||
|
||||
def test_admin_distance_for_existing_static_routes(request):
|
||||
""" Test to modify and verify admin distance for existing static routes."""
|
||||
"""Test to modify and verify admin distance for existing static routes."""
|
||||
|
||||
tgen = get_topogen()
|
||||
if BGP_CONVERGENCE is not True:
|
||||
@ -528,7 +506,7 @@ def test_admin_distance_for_existing_static_routes(request):
|
||||
|
||||
|
||||
def test_advertise_network_using_network_command(request):
|
||||
""" Test advertise networks using network command."""
|
||||
"""Test advertise networks using network command."""
|
||||
|
||||
tgen = get_topogen()
|
||||
if BGP_CONVERGENCE is not True:
|
||||
@ -798,9 +776,13 @@ def test_BGP_attributes_with_vrf_default_keyword_p0(request):
|
||||
}
|
||||
|
||||
result = verify_bgp_rib(tgen, addr_type, dut, input_dict)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
result = verify_rib(tgen, addr_type, dut, input_dict)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
for addr_type in ADDR_TYPES:
|
||||
dut = "r4"
|
||||
@ -817,9 +799,13 @@ def test_BGP_attributes_with_vrf_default_keyword_p0(request):
|
||||
}
|
||||
|
||||
result = verify_bgp_rib(tgen, addr_type, dut, input_dict)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
result = verify_rib(tgen, addr_type, dut, input_dict)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
input_dict_4 = {"largeCommunity": "500:500:500", "community": "500:500"}
|
||||
|
||||
@ -1158,10 +1144,14 @@ def test_bgp_with_loopback_with_same_subnet_p1(request):
|
||||
dut = "r1"
|
||||
protocol = "bgp"
|
||||
for addr_type in ADDR_TYPES:
|
||||
result = verify_fib_routes(tgen, addr_type, dut, input_dict_r1)
|
||||
assert result is not True, "Testcase {} : Failed \n"
|
||||
"Expected behavior: routes should not present in fib \n"
|
||||
"Error: {}".format(tc_name, result)
|
||||
result = verify_fib_routes(
|
||||
tgen, addr_type, dut, input_dict_r1, expected=False
|
||||
) # pylint: disable=E1123
|
||||
assert result is not True, (
|
||||
"Testcase {} : Failed \n".format(tc_name)
|
||||
+ "Expected behavior: routes should not present in fib \n"
|
||||
+ "Error: {}".format(result)
|
||||
)
|
||||
|
||||
step("Verify Ipv4 and Ipv6 network installed in r3 RIB but not in FIB")
|
||||
input_dict_r3 = {
|
||||
@ -1175,10 +1165,14 @@ def test_bgp_with_loopback_with_same_subnet_p1(request):
|
||||
dut = "r3"
|
||||
protocol = "bgp"
|
||||
for addr_type in ADDR_TYPES:
|
||||
result = verify_fib_routes(tgen, addr_type, dut, input_dict_r1)
|
||||
assert result is not True, "Testcase {} : Failed \n"
|
||||
"Expected behavior: routes should not present in fib \n"
|
||||
"Error: {}".format(tc_name, result)
|
||||
result = verify_fib_routes(
|
||||
tgen, addr_type, dut, input_dict_r1, expected=False
|
||||
) # pylint: disable=E1123
|
||||
assert result is not True, (
|
||||
"Testcase {} : Failed \n".format(tc_name)
|
||||
+ "Expected behavior: routes should not present in fib \n"
|
||||
+ "Error: {}".format(result)
|
||||
)
|
||||
|
||||
write_test_footer(tc_name)
|
||||
|
||||
|
@ -36,35 +36,30 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
from lib.common_config import step
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -33,35 +33,28 @@ route-map test permit 10
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
sys.path.append(os.path.join(CWD, "../"))
|
||||
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -29,7 +29,6 @@ Following tests are covered to test bgp community functionality:
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -38,7 +37,6 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from mininet.topo import Topo
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
|
||||
# Import topoJson from lib, to create topology and initial configuration
|
||||
@ -60,23 +58,14 @@ from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
clear_bgp_and_verify,
|
||||
verify_bgp_rib,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
from copy import deepcopy
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology creation
|
||||
jsonFile = "{}/bgp_communities.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
BGP_CONVERGENCE = False
|
||||
ADDR_TYPES = check_address_types()
|
||||
@ -84,21 +73,6 @@ NETWORK = {"ipv4": "2.2.2.2/32", "ipv6": "22:22::2/128"}
|
||||
NEXT_HOP_IP = {}
|
||||
|
||||
|
||||
class BGPCOMMUNITIES(Topo):
|
||||
"""
|
||||
Test BGPCOMMUNITIES - topology 1
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function"""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -118,7 +92,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(BGPCOMMUNITIES, mod.__name__)
|
||||
json_file = "{}/bgp_communities.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
@ -340,14 +317,18 @@ def test_bgp_no_advertise_community_p0(request):
|
||||
)
|
||||
|
||||
result = verify_bgp_rib(tgen, addr_type, dut, input_dict, expected=False)
|
||||
assert result is not True, "Testcase {} : Failed \n "
|
||||
" Routes still present in R3 router. Error: {}".format(tc_name, result)
|
||||
assert result is not True, "Testcase {} : Failed \n ".format(
|
||||
tc_name
|
||||
) + " Routes still present in R3 router. Error: {}".format(result)
|
||||
|
||||
result = verify_rib(
|
||||
tgen, addr_type, dut, input_dict, protocol=protocol, expected=False
|
||||
)
|
||||
assert result is not True, "Testcase {} : Failed \n "
|
||||
" Routes still present in R3 router. Error: {}".format(tc_name, result)
|
||||
assert (
|
||||
result is not True
|
||||
), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
step("Remove and Add no advertise community")
|
||||
# Configure neighbor for route map
|
||||
@ -392,12 +373,18 @@ def test_bgp_no_advertise_community_p0(request):
|
||||
)
|
||||
|
||||
result = verify_bgp_rib(tgen, addr_type, dut, input_dict)
|
||||
assert result is True, "Testcase {} : Failed \n "
|
||||
" Routes still present in R3 router. Error: {}".format(tc_name, result)
|
||||
assert (
|
||||
result is True
|
||||
), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol)
|
||||
assert result is True, "Testcase {} : Failed \n "
|
||||
" Routes still present in R3 router. Error: {}".format(tc_name, result)
|
||||
assert (
|
||||
result is True
|
||||
), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
step("Repeat above steps when IBGP nbr configured between R1, R2 & R2, R3")
|
||||
topo1 = deepcopy(topo)
|
||||
@ -579,12 +566,18 @@ def test_bgp_no_advertise_community_p0(request):
|
||||
)
|
||||
|
||||
result = verify_bgp_rib(tgen, addr_type, dut, input_dict)
|
||||
assert result is True, "Testcase {} : Failed \n "
|
||||
" Routes still present in R3 router. Error: {}".format(tc_name, result)
|
||||
assert (
|
||||
result is True
|
||||
), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol)
|
||||
assert result is True, "Testcase {} : Failed \n "
|
||||
" Routes still present in R3 router. Error: {}".format(tc_name, result)
|
||||
assert (
|
||||
result is True
|
||||
), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
step("Remove and Add no advertise community")
|
||||
# Configure neighbor for route map
|
||||
@ -629,12 +622,18 @@ def test_bgp_no_advertise_community_p0(request):
|
||||
)
|
||||
|
||||
result = verify_bgp_rib(tgen, addr_type, dut, input_dict)
|
||||
assert result is True, "Testcase {} : Failed \n "
|
||||
" Routes still present in R3 router. Error: {}".format(tc_name, result)
|
||||
assert (
|
||||
result is True
|
||||
), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol)
|
||||
assert result is True, "Testcase {} : Failed \n "
|
||||
" Routes still present in R3 router. Error: {}".format(tc_name, result)
|
||||
assert (
|
||||
result is True
|
||||
), "Testcase {} : Failed \n Routes still present in R3 router. Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
write_test_footer(tc_name)
|
||||
|
||||
|
@ -31,7 +31,6 @@ Following tests are covered to test bgp community functionality:
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -40,7 +39,6 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from mininet.topo import Topo
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
|
||||
# Import topoJson from lib, to create topology and initial configuration
|
||||
@ -54,7 +52,6 @@ from lib.common_config import (
|
||||
check_address_types,
|
||||
step,
|
||||
create_route_maps,
|
||||
create_prefix_lists,
|
||||
create_route_maps,
|
||||
required_linux_kernel_version,
|
||||
)
|
||||
@ -63,24 +60,14 @@ from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
clear_bgp_and_verify,
|
||||
verify_bgp_rib,
|
||||
verify_bgp_community,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from copy import deepcopy
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology creation
|
||||
jsonFile = "{}/bgp_communities_topo2.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
BGP_CONVERGENCE = False
|
||||
ADDR_TYPES = check_address_types()
|
||||
@ -90,21 +77,6 @@ NETWORK = {
|
||||
}
|
||||
|
||||
|
||||
class BGPCOMMUNITIES(Topo):
|
||||
"""
|
||||
Test BGPCOMMUNITIES - topology 1
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function"""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -124,7 +96,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(BGPCOMMUNITIES, mod.__name__)
|
||||
json_file = "{}/bgp_communities_topo2.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
@ -292,7 +267,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request):
|
||||
input_dict_4,
|
||||
next_hop=topo["routers"]["r1"]["links"]["r2"][addr_type].split("/")[0],
|
||||
)
|
||||
assert result is True, "Testcase : Failed \n Error: {}".format(
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
@ -311,7 +286,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request):
|
||||
0
|
||||
],
|
||||
)
|
||||
assert result is True, "Testcase : Failed \n Error: {}".format(
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
else:
|
||||
@ -330,7 +305,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request):
|
||||
],
|
||||
expected=False,
|
||||
)
|
||||
assert result is not True, "Testcase : Failed \n Error: {}".format(
|
||||
assert result is not True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
@ -358,7 +333,9 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request):
|
||||
}
|
||||
}
|
||||
result = create_router_bgp(tgen, topo, input_dict_2)
|
||||
assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
step("Configure redistribute static")
|
||||
input_dict_2 = {
|
||||
@ -376,7 +353,9 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request):
|
||||
}
|
||||
}
|
||||
result = create_router_bgp(tgen, topo, input_dict_2)
|
||||
assert result is True, "Testcase : Failed \n Error: {}".format(tc_name, result)
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
step(
|
||||
"Verify that these prefixes, originated on R1, are now"
|
||||
@ -402,7 +381,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request):
|
||||
input_dict_4,
|
||||
next_hop=topo["routers"]["r1"]["links"]["r2"][addr_type].split("/")[0],
|
||||
)
|
||||
assert result is True, "Testcase : Failed \n Error: {}".format(
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
@ -413,7 +392,7 @@ def test_bgp_no_export_local_as_and_internet_communities_p0(request):
|
||||
input_dict_4,
|
||||
next_hop=topo["routers"]["r1"]["links"]["r3"][addr_type].split("/")[0],
|
||||
)
|
||||
assert result is True, "Testcase : Failed \n Error: {}".format(
|
||||
assert result is True, "Testcase {} : Failed \n Error: {}".format(
|
||||
tc_name, result
|
||||
)
|
||||
|
||||
|
@ -25,7 +25,6 @@ Test if BGP community alias is visible in CLI outputs
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -37,26 +36,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -53,8 +53,6 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import step
|
||||
from time import sleep
|
||||
@ -62,55 +60,52 @@ from time import sleep
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
tgen.add_router("z1")
|
||||
tgen.add_router("y1")
|
||||
tgen.add_router("y2")
|
||||
tgen.add_router("y3")
|
||||
tgen.add_router("x1")
|
||||
tgen.add_router("c1")
|
||||
|
||||
tgen.add_router("z1")
|
||||
tgen.add_router("y1")
|
||||
tgen.add_router("y2")
|
||||
tgen.add_router("y3")
|
||||
tgen.add_router("x1")
|
||||
tgen.add_router("c1")
|
||||
# 10.0.1.0/30
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["c1"])
|
||||
switch.add_link(tgen.gears["x1"])
|
||||
|
||||
# 10.0.1.0/30
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["c1"])
|
||||
switch.add_link(tgen.gears["x1"])
|
||||
# 10.0.2.0/30
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["x1"])
|
||||
switch.add_link(tgen.gears["y1"])
|
||||
|
||||
# 10.0.2.0/30
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["x1"])
|
||||
switch.add_link(tgen.gears["y1"])
|
||||
# 10.0.3.0/30
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["y1"])
|
||||
switch.add_link(tgen.gears["y2"])
|
||||
|
||||
# 10.0.3.0/30
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["y1"])
|
||||
switch.add_link(tgen.gears["y2"])
|
||||
# 10.0.4.0/30
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["y1"])
|
||||
switch.add_link(tgen.gears["y3"])
|
||||
|
||||
# 10.0.4.0/30
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["y1"])
|
||||
switch.add_link(tgen.gears["y3"])
|
||||
# 10.0.5.0/30
|
||||
switch = tgen.add_switch("s5")
|
||||
switch.add_link(tgen.gears["y2"])
|
||||
switch.add_link(tgen.gears["y3"])
|
||||
|
||||
# 10.0.5.0/30
|
||||
switch = tgen.add_switch("s5")
|
||||
switch.add_link(tgen.gears["y2"])
|
||||
switch.add_link(tgen.gears["y3"])
|
||||
# 10.0.6.0/30
|
||||
switch = tgen.add_switch("s6")
|
||||
switch.add_link(tgen.gears["y2"])
|
||||
switch.add_link(tgen.gears["z1"])
|
||||
|
||||
# 10.0.6.0/30
|
||||
switch = tgen.add_switch("s6")
|
||||
switch.add_link(tgen.gears["y2"])
|
||||
switch.add_link(tgen.gears["z1"])
|
||||
|
||||
# 10.0.7.0/30
|
||||
switch = tgen.add_switch("s7")
|
||||
switch.add_link(tgen.gears["y3"])
|
||||
switch.add_link(tgen.gears["z1"])
|
||||
# 10.0.7.0/30
|
||||
switch = tgen.add_switch("s7")
|
||||
switch.add_link(tgen.gears["y3"])
|
||||
switch.add_link(tgen.gears["z1"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -137,26 +137,22 @@ 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 mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class BgpConditionalAdvertisementTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
r1 = tgen.add_router("r1")
|
||||
r2 = tgen.add_router("r2")
|
||||
r3 = tgen.add_router("r3")
|
||||
|
||||
r1 = tgen.add_router("r1")
|
||||
r2 = tgen.add_router("r2")
|
||||
r3 = tgen.add_router("r3")
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(r2)
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(r1)
|
||||
switch.add_link(r2)
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(r2)
|
||||
switch.add_link(r3)
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(r2)
|
||||
switch.add_link(r3)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
@ -166,7 +162,7 @@ def setup_module(mod):
|
||||
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
tgen = Topogen(BgpConditionalAdvertisementTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -33,7 +33,6 @@ import os
|
||||
import sys
|
||||
import json
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
@ -41,31 +40,25 @@ CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
sys.path.append(os.path.join(CWD, "../"))
|
||||
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
from lib.common_config import step
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -25,7 +25,6 @@ Test if default-originate works without route-map.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -35,26 +34,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -25,7 +25,6 @@ Test if default-originate works with ONLY match operations.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -35,26 +34,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -27,7 +27,6 @@ to r2.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -37,27 +36,22 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
from lib.common_config import step
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -26,7 +26,6 @@ And verify if set operations work as well.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -36,27 +35,22 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -25,7 +25,6 @@ Test if default-originate works with ONLY set operations.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -35,26 +34,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -1,7 +1,9 @@
|
||||
!
|
||||
router bgp 65001
|
||||
timers 3 10
|
||||
no bgp ebgp-requires-policy
|
||||
neighbor 192.168.1.2 remote-as external
|
||||
neighbor 192.168.1.2 timers connect 5
|
||||
address-family ipv4 unicast
|
||||
neighbor 192.168.1.2 disable-addpath-rx
|
||||
exit-address-family
|
||||
|
@ -1,8 +1,12 @@
|
||||
router bgp 65002
|
||||
timers 3 10
|
||||
no bgp ebgp-requires-policy
|
||||
neighbor 192.168.1.1 remote-as external
|
||||
neighbor 192.168.1.1 timers connect 5
|
||||
neighbor 192.168.2.3 remote-as external
|
||||
neighbor 192.168.2.3 timers connect 5
|
||||
neighbor 192.168.2.4 remote-as external
|
||||
neighbor 192.168.2.4 timers connect 5
|
||||
address-family ipv4 unicast
|
||||
neighbor 192.168.1.1 addpath-tx-all-paths
|
||||
exit-address-family
|
||||
|
@ -1,6 +1,8 @@
|
||||
router bgp 65003
|
||||
timers 3 10
|
||||
no bgp ebgp-requires-policy
|
||||
neighbor 192.168.2.2 remote-as external
|
||||
neighbor 192.168.2.2 timers connect 5
|
||||
address-family ipv4 unicast
|
||||
redistribute connected
|
||||
exit-address-family
|
||||
|
@ -1,6 +1,8 @@
|
||||
router bgp 65004
|
||||
timers 3 10
|
||||
no bgp ebgp-requires-policy
|
||||
neighbor 192.168.2.2 remote-as external
|
||||
neighbor 192.168.2.2 timers connect 5
|
||||
address-family ipv4 unicast
|
||||
redistribute connected
|
||||
exit-address-family
|
||||
|
@ -25,7 +25,6 @@ Test if AddPath RX direction is not negotiated via AddPath capability.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -35,32 +34,27 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
from lib.common_config import step
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -36,7 +36,6 @@ Changed distance should reflect to RIB after changes.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -46,26 +45,21 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -26,7 +26,6 @@ sets `dont-capability-negotiate`.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -38,26 +37,13 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
|
||||
for routern in range(1, 3):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
topodef = {"s1": ("r1", "r2")}
|
||||
tgen = Topogen(topodef, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -36,7 +36,6 @@ common subnet with this address.
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -48,27 +47,22 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
# pylint: disable=C0413
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topolog import logger
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 4):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 4):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -44,7 +44,6 @@ Scenario 3:
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
@ -55,36 +54,32 @@ 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 mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 7):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 7):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
# Scenario 1.
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
# Scenario 1.
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
# Scenario 2.
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
# Scenario 2.
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
# Scenario 3.
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r5"])
|
||||
switch.add_link(tgen.gears["r6"])
|
||||
# Scenario 3.
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r5"])
|
||||
switch.add_link(tgen.gears["r6"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
exa-receive.py: Save received routes form ExaBGP into file
|
||||
"""
|
||||
|
||||
from sys import stdin, argv
|
||||
from datetime import datetime
|
||||
|
||||
# 1st arg is peer number
|
||||
peer = int(argv[1])
|
||||
|
||||
# When the parent dies we are seeing continual newlines, so we only access so many before stopping
|
||||
counter = 0
|
||||
|
||||
routesavefile = open("/tmp/peer%s-received.log" % peer, "w")
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = stdin.readline()
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H:%M:%S - ")
|
||||
routesavefile.write(timestamp + line)
|
||||
routesavefile.flush()
|
||||
|
||||
if line == "":
|
||||
counter += 1
|
||||
if counter > 100:
|
||||
break
|
||||
continue
|
||||
|
||||
counter = 0
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except IOError:
|
||||
# most likely a signal during readline
|
||||
pass
|
||||
|
||||
routesavefile.close()
|
@ -43,7 +43,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 +57,26 @@ total_ebgp_peers = 20
|
||||
#####################################################
|
||||
|
||||
|
||||
class BGPECMPTopo1(Topo):
|
||||
"BGP ECMP Topology 1"
|
||||
def build_topo(tgen):
|
||||
router = tgen.add_router("r1")
|
||||
|
||||
def build(self, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
# 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)
|
||||
|
||||
# Create the BGP router
|
||||
router = tgen.add_router("r1")
|
||||
# Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
|
||||
for peerNum in range(1, total_ebgp_peers + 1):
|
||||
swNum = (peerNum - 1) // 5 + 1
|
||||
|
||||
# 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)
|
||||
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
|
||||
)
|
||||
|
||||
# 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
|
||||
)
|
||||
|
||||
switch = tgen.gears["s{}".format(swNum)]
|
||||
switch.add_link(peer)
|
||||
switch = tgen.gears["s{}".format(swNum)]
|
||||
switch.add_link(peer)
|
||||
|
||||
|
||||
#####################################################
|
||||
@ -94,7 +87,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 +112,7 @@ def setup_module(module):
|
||||
|
||||
|
||||
def teardown_module(module):
|
||||
del module
|
||||
tgen = get_topogen()
|
||||
tgen.stop_topology()
|
||||
|
||||
|
@ -39,7 +39,6 @@ Following tests are covered to test ecmp functionality on EBGP.
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -50,7 +49,6 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
@ -65,21 +63,12 @@ from lib.common_config import (
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/ebgp_ecmp_topo2.json".format(CWD)
|
||||
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
NEXT_HOPS = {"ipv4": [], "ipv6": []}
|
||||
INTF_LIST_R3 = []
|
||||
@ -89,21 +78,6 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
|
||||
BGP_CONVERGENCE = False
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder.
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function."""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment.
|
||||
@ -125,7 +99,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/ebgp_ecmp_topo2.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
@ -332,7 +309,7 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
|
||||
@pytest.mark.parametrize("ecmp_num", ["8", "16", "32"])
|
||||
@pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
|
||||
def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
|
||||
""" Verify BGP table and RIB in DUT after clear BGP routes and neighbors"""
|
||||
"""Verify BGP table and RIB in DUT after clear BGP routes and neighbors"""
|
||||
|
||||
tc_name = request.node.name
|
||||
write_test_header(tc_name)
|
||||
|
@ -39,7 +39,6 @@ Following tests are covered to test ecmp functionality on EBGP.
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -50,7 +49,6 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
@ -65,21 +63,12 @@ from lib.common_config import (
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/ibgp_ecmp_topo2.json".format(CWD)
|
||||
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
NEXT_HOPS = {"ipv4": [], "ipv6": []}
|
||||
INTF_LIST_R3 = []
|
||||
@ -89,21 +78,6 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
|
||||
BGP_CONVERGENCE = False
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder.
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function."""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment.
|
||||
@ -125,7 +99,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/ibgp_ecmp_topo2.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
@ -333,7 +310,7 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
|
||||
@pytest.mark.parametrize("ecmp_num", ["8", "16", "32"])
|
||||
@pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
|
||||
def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
|
||||
""" Verify BGP table and RIB in DUT after clear BGP routes and neighbors"""
|
||||
"""Verify BGP table and RIB in DUT after clear BGP routes and neighbors"""
|
||||
|
||||
tc_name = request.node.name
|
||||
write_test_header(tc_name)
|
||||
|
@ -28,7 +28,6 @@ Following tests are covered to test ecmp functionality on iBGP.
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
from time import sleep
|
||||
|
||||
@ -39,39 +38,26 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
from lib.topogen import get_topogen
|
||||
from lib import topojson
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
write_test_header,
|
||||
write_test_footer,
|
||||
verify_rib,
|
||||
create_static_routes,
|
||||
check_address_types,
|
||||
interface_status,
|
||||
reset_config_on_routers,
|
||||
required_linux_kernel_version,
|
||||
shutdown_bringup_interface,
|
||||
apply_raw_config,
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.bgp import create_router_bgp, verify_bgp_convergence
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/ibgp_ecmp_topo3.json".format(CWD)
|
||||
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
NEXT_HOPS = {"ipv4": [], "ipv6": []}
|
||||
NETWORK = {"ipv4": "192.168.1.10/32", "ipv6": "fd00:0:0:1::10/128"}
|
||||
@ -79,45 +65,20 @@ NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
|
||||
BGP_CONVERGENCE = False
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder.
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function."""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment.
|
||||
|
||||
* `mod`: module name
|
||||
"""
|
||||
global NEXT_HOPS, INTF_LIST_R3, INTF_LIST_R2, TEST_STATIC
|
||||
global ADDR_TYPES
|
||||
|
||||
testsuite_run_time = time.asctime(time.localtime(time.time()))
|
||||
logger.info("Testsuite start time: {}".format(testsuite_run_time))
|
||||
logger.info("=" * 40)
|
||||
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
start_topology(tgen)
|
||||
|
||||
# Creating configuration from JSON
|
||||
build_config_from_json(tgen, topo)
|
||||
tgen = topojson.setup_module_from_json(mod.__file__)
|
||||
topo = tgen.json_topo
|
||||
|
||||
# Don't run this test if we have any failure.
|
||||
if tgen.routers_have_failure():
|
||||
@ -136,18 +97,7 @@ def setup_module(mod):
|
||||
|
||||
|
||||
def teardown_module():
|
||||
"""
|
||||
Teardown the pytest environment.
|
||||
|
||||
* `mod`: module name
|
||||
"""
|
||||
|
||||
logger.info("Running teardown_module to delete topology")
|
||||
|
||||
tgen = get_topogen()
|
||||
|
||||
# Stop toplogy and Remove tmp files
|
||||
tgen.stop_topology()
|
||||
get_topogen().stop_topology()
|
||||
|
||||
|
||||
def static_or_nw(tgen, topo, tc_name, test_type, dut):
|
||||
@ -221,12 +171,11 @@ def static_or_nw(tgen, topo, tc_name, test_type, dut):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_type", ["redist_static"])
|
||||
def test_ecmp_fast_convergence(request, test_type):
|
||||
def test_ecmp_fast_convergence(request, test_type, tgen, topo):
|
||||
"""This test is to verify bgp fast-convergence cli functionality"""
|
||||
|
||||
tc_name = request.node.name
|
||||
write_test_header(tc_name)
|
||||
tgen = get_topogen()
|
||||
|
||||
# Verifying RIB routes
|
||||
dut = "r3"
|
||||
@ -274,12 +223,12 @@ def test_ecmp_fast_convergence(request, test_type):
|
||||
|
||||
logger.info("Enable bgp fast-convergence cli")
|
||||
raw_config = {
|
||||
"r2": {
|
||||
"raw_config": [
|
||||
"router bgp {}".format(topo["routers"]["r2"]["bgp"]["local_as"]),
|
||||
"bgp fast-convergence",
|
||||
]
|
||||
}
|
||||
"r2": {
|
||||
"raw_config": [
|
||||
"router bgp {}".format(topo["routers"]["r2"]["bgp"]["local_as"]),
|
||||
"bgp fast-convergence",
|
||||
]
|
||||
}
|
||||
}
|
||||
result = apply_raw_config(tgen, raw_config)
|
||||
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
|
||||
|
@ -28,8 +28,10 @@ test_evpn_mh.py: Testing EVPN multihoming
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import subprocess
|
||||
from functools import partial
|
||||
|
||||
import pytest
|
||||
import json
|
||||
import platform
|
||||
@ -44,15 +46,12 @@ 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
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.pimd]
|
||||
|
||||
|
||||
#####################################################
|
||||
##
|
||||
## Network Topology Definition
|
||||
@ -61,7 +60,7 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.pimd]
|
||||
#####################################################
|
||||
|
||||
|
||||
class NetworkTopo(Topo):
|
||||
def build_topo(tgen):
|
||||
"""
|
||||
EVPN Multihoming Topology -
|
||||
1. Two level CLOS
|
||||
@ -70,110 +69,105 @@ class NetworkTopo(Topo):
|
||||
4. Two dual attached hosts per-rack - hostdx1, hostdx2
|
||||
"""
|
||||
|
||||
def build(self, **_opts):
|
||||
"Build function"
|
||||
tgen.add_router("spine1")
|
||||
tgen.add_router("spine2")
|
||||
tgen.add_router("torm11")
|
||||
tgen.add_router("torm12")
|
||||
tgen.add_router("torm21")
|
||||
tgen.add_router("torm22")
|
||||
tgen.add_router("hostd11")
|
||||
tgen.add_router("hostd12")
|
||||
tgen.add_router("hostd21")
|
||||
tgen.add_router("hostd22")
|
||||
|
||||
tgen = get_topogen(self)
|
||||
# On main router
|
||||
# First switch is for a dummy interface (for local network)
|
||||
|
||||
tgen.add_router("spine1")
|
||||
tgen.add_router("spine2")
|
||||
tgen.add_router("torm11")
|
||||
tgen.add_router("torm12")
|
||||
tgen.add_router("torm21")
|
||||
tgen.add_router("torm22")
|
||||
tgen.add_router("hostd11")
|
||||
tgen.add_router("hostd12")
|
||||
tgen.add_router("hostd21")
|
||||
tgen.add_router("hostd22")
|
||||
##################### spine1 ########################
|
||||
# spine1-eth0 is connected to torm11-eth0
|
||||
switch = tgen.add_switch("sw1")
|
||||
switch.add_link(tgen.gears["spine1"])
|
||||
switch.add_link(tgen.gears["torm11"])
|
||||
|
||||
# On main router
|
||||
# First switch is for a dummy interface (for local network)
|
||||
# spine1-eth1 is connected to torm12-eth0
|
||||
switch = tgen.add_switch("sw2")
|
||||
switch.add_link(tgen.gears["spine1"])
|
||||
switch.add_link(tgen.gears["torm12"])
|
||||
|
||||
##################### spine1 ########################
|
||||
# spine1-eth0 is connected to torm11-eth0
|
||||
switch = tgen.add_switch("sw1")
|
||||
switch.add_link(tgen.gears["spine1"])
|
||||
switch.add_link(tgen.gears["torm11"])
|
||||
# spine1-eth2 is connected to torm21-eth0
|
||||
switch = tgen.add_switch("sw3")
|
||||
switch.add_link(tgen.gears["spine1"])
|
||||
switch.add_link(tgen.gears["torm21"])
|
||||
|
||||
# spine1-eth1 is connected to torm12-eth0
|
||||
switch = tgen.add_switch("sw2")
|
||||
switch.add_link(tgen.gears["spine1"])
|
||||
switch.add_link(tgen.gears["torm12"])
|
||||
# spine1-eth3 is connected to torm22-eth0
|
||||
switch = tgen.add_switch("sw4")
|
||||
switch.add_link(tgen.gears["spine1"])
|
||||
switch.add_link(tgen.gears["torm22"])
|
||||
|
||||
# spine1-eth2 is connected to torm21-eth0
|
||||
switch = tgen.add_switch("sw3")
|
||||
switch.add_link(tgen.gears["spine1"])
|
||||
switch.add_link(tgen.gears["torm21"])
|
||||
##################### spine2 ########################
|
||||
# spine2-eth0 is connected to torm11-eth1
|
||||
switch = tgen.add_switch("sw5")
|
||||
switch.add_link(tgen.gears["spine2"])
|
||||
switch.add_link(tgen.gears["torm11"])
|
||||
|
||||
# spine1-eth3 is connected to torm22-eth0
|
||||
switch = tgen.add_switch("sw4")
|
||||
switch.add_link(tgen.gears["spine1"])
|
||||
switch.add_link(tgen.gears["torm22"])
|
||||
# spine2-eth1 is connected to torm12-eth1
|
||||
switch = tgen.add_switch("sw6")
|
||||
switch.add_link(tgen.gears["spine2"])
|
||||
switch.add_link(tgen.gears["torm12"])
|
||||
|
||||
##################### spine2 ########################
|
||||
# spine2-eth0 is connected to torm11-eth1
|
||||
switch = tgen.add_switch("sw5")
|
||||
switch.add_link(tgen.gears["spine2"])
|
||||
switch.add_link(tgen.gears["torm11"])
|
||||
# spine2-eth2 is connected to torm21-eth1
|
||||
switch = tgen.add_switch("sw7")
|
||||
switch.add_link(tgen.gears["spine2"])
|
||||
switch.add_link(tgen.gears["torm21"])
|
||||
|
||||
# spine2-eth1 is connected to torm12-eth1
|
||||
switch = tgen.add_switch("sw6")
|
||||
switch.add_link(tgen.gears["spine2"])
|
||||
switch.add_link(tgen.gears["torm12"])
|
||||
# spine2-eth3 is connected to torm22-eth1
|
||||
switch = tgen.add_switch("sw8")
|
||||
switch.add_link(tgen.gears["spine2"])
|
||||
switch.add_link(tgen.gears["torm22"])
|
||||
|
||||
# spine2-eth2 is connected to torm21-eth1
|
||||
switch = tgen.add_switch("sw7")
|
||||
switch.add_link(tgen.gears["spine2"])
|
||||
switch.add_link(tgen.gears["torm21"])
|
||||
##################### torm11 ########################
|
||||
# torm11-eth2 is connected to hostd11-eth0
|
||||
switch = tgen.add_switch("sw9")
|
||||
switch.add_link(tgen.gears["torm11"])
|
||||
switch.add_link(tgen.gears["hostd11"])
|
||||
|
||||
# spine2-eth3 is connected to torm22-eth1
|
||||
switch = tgen.add_switch("sw8")
|
||||
switch.add_link(tgen.gears["spine2"])
|
||||
switch.add_link(tgen.gears["torm22"])
|
||||
# torm11-eth3 is connected to hostd12-eth0
|
||||
switch = tgen.add_switch("sw10")
|
||||
switch.add_link(tgen.gears["torm11"])
|
||||
switch.add_link(tgen.gears["hostd12"])
|
||||
|
||||
##################### torm11 ########################
|
||||
# torm11-eth2 is connected to hostd11-eth0
|
||||
switch = tgen.add_switch("sw9")
|
||||
switch.add_link(tgen.gears["torm11"])
|
||||
switch.add_link(tgen.gears["hostd11"])
|
||||
##################### torm12 ########################
|
||||
# torm12-eth2 is connected to hostd11-eth1
|
||||
switch = tgen.add_switch("sw11")
|
||||
switch.add_link(tgen.gears["torm12"])
|
||||
switch.add_link(tgen.gears["hostd11"])
|
||||
|
||||
# torm11-eth3 is connected to hostd12-eth0
|
||||
switch = tgen.add_switch("sw10")
|
||||
switch.add_link(tgen.gears["torm11"])
|
||||
switch.add_link(tgen.gears["hostd12"])
|
||||
# torm12-eth3 is connected to hostd12-eth1
|
||||
switch = tgen.add_switch("sw12")
|
||||
switch.add_link(tgen.gears["torm12"])
|
||||
switch.add_link(tgen.gears["hostd12"])
|
||||
|
||||
##################### torm12 ########################
|
||||
# torm12-eth2 is connected to hostd11-eth1
|
||||
switch = tgen.add_switch("sw11")
|
||||
switch.add_link(tgen.gears["torm12"])
|
||||
switch.add_link(tgen.gears["hostd11"])
|
||||
##################### torm21 ########################
|
||||
# torm21-eth2 is connected to hostd21-eth0
|
||||
switch = tgen.add_switch("sw13")
|
||||
switch.add_link(tgen.gears["torm21"])
|
||||
switch.add_link(tgen.gears["hostd21"])
|
||||
|
||||
# torm12-eth3 is connected to hostd12-eth1
|
||||
switch = tgen.add_switch("sw12")
|
||||
switch.add_link(tgen.gears["torm12"])
|
||||
switch.add_link(tgen.gears["hostd12"])
|
||||
# torm21-eth3 is connected to hostd22-eth0
|
||||
switch = tgen.add_switch("sw14")
|
||||
switch.add_link(tgen.gears["torm21"])
|
||||
switch.add_link(tgen.gears["hostd22"])
|
||||
|
||||
##################### torm21 ########################
|
||||
# torm21-eth2 is connected to hostd21-eth0
|
||||
switch = tgen.add_switch("sw13")
|
||||
switch.add_link(tgen.gears["torm21"])
|
||||
switch.add_link(tgen.gears["hostd21"])
|
||||
##################### torm22 ########################
|
||||
# torm22-eth2 is connected to hostd21-eth1
|
||||
switch = tgen.add_switch("sw15")
|
||||
switch.add_link(tgen.gears["torm22"])
|
||||
switch.add_link(tgen.gears["hostd21"])
|
||||
|
||||
# torm21-eth3 is connected to hostd22-eth0
|
||||
switch = tgen.add_switch("sw14")
|
||||
switch.add_link(tgen.gears["torm21"])
|
||||
switch.add_link(tgen.gears["hostd22"])
|
||||
|
||||
##################### torm22 ########################
|
||||
# torm22-eth2 is connected to hostd21-eth1
|
||||
switch = tgen.add_switch("sw15")
|
||||
switch.add_link(tgen.gears["torm22"])
|
||||
switch.add_link(tgen.gears["hostd21"])
|
||||
|
||||
# torm22-eth3 is connected to hostd22-eth1
|
||||
switch = tgen.add_switch("sw16")
|
||||
switch.add_link(tgen.gears["torm22"])
|
||||
switch.add_link(tgen.gears["hostd22"])
|
||||
# torm22-eth3 is connected to hostd22-eth1
|
||||
switch = tgen.add_switch("sw16")
|
||||
switch.add_link(tgen.gears["torm22"])
|
||||
switch.add_link(tgen.gears["hostd22"])
|
||||
|
||||
|
||||
#####################################################
|
||||
@ -370,7 +364,7 @@ def config_hosts(tgen, hosts):
|
||||
|
||||
def setup_module(module):
|
||||
"Setup topology"
|
||||
tgen = Topogen(NetworkTopo, module.__name__)
|
||||
tgen = Topogen(build_topo, module.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
krel = platform.release()
|
||||
@ -599,21 +593,25 @@ def test_evpn_ead_update():
|
||||
def ping_anycast_gw(tgen):
|
||||
# ping the anycast gw from the local and remote hosts to populate
|
||||
# the mac address on the PEs
|
||||
python3_path = tgen.net.get_exec_path(["python3", "python"])
|
||||
script_path = os.path.abspath(os.path.join(CWD, "../lib/scapy_sendpkt.py"))
|
||||
intf = "torbond"
|
||||
ipaddr = "45.0.0.1"
|
||||
ping_cmd = [
|
||||
python3_path,
|
||||
script_path,
|
||||
"--imports=Ether,ARP",
|
||||
"--interface=" + intf,
|
||||
"'Ether(dst=\"ff:ff:ff:ff:ff:ff\")/ARP(pdst=\"{}\")'".format(ipaddr)
|
||||
'Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="{}")'.format(ipaddr),
|
||||
]
|
||||
for name in ("hostd11", "hostd21"):
|
||||
host = tgen.net[name]
|
||||
stdout = host.cmd(ping_cmd)
|
||||
host = tgen.net.hosts[name]
|
||||
_, stdout, _ = host.cmd_status(ping_cmd, warn=False, stderr=subprocess.STDOUT)
|
||||
stdout = stdout.strip()
|
||||
if stdout:
|
||||
host.logger.debug("%s: arping on %s for %s returned: %s", name, intf, ipaddr, stdout)
|
||||
host.logger.debug(
|
||||
"%s: arping on %s for %s returned: %s", name, intf, ipaddr, stdout
|
||||
)
|
||||
|
||||
|
||||
def check_mac(dut, vni, mac, m_type, esi, intf, ping_gw=False, tgen=None):
|
||||
|
@ -58,7 +58,7 @@ import pytest
|
||||
import time
|
||||
import platform
|
||||
|
||||
#Current Working Directory
|
||||
# Current Working Directory
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
sys.path.append(os.path.join(CWD, "../"))
|
||||
|
||||
@ -75,42 +75,35 @@ from lib.common_config import (
|
||||
)
|
||||
|
||||
# Required to instantiate the topology builder class.
|
||||
from mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
#Global variables
|
||||
PES = ['PE1', 'PE2']
|
||||
HOSTS = ['host1', 'host2']
|
||||
PE_SUFFIX = {'PE1': '1', 'PE2': '2'}
|
||||
HOST_SUFFIX = {'host1': '1', 'host2': '2'}
|
||||
# Global variables
|
||||
PES = ["PE1", "PE2"]
|
||||
HOSTS = ["host1", "host2"]
|
||||
PE_SUFFIX = {"PE1": "1", "PE2": "2"}
|
||||
HOST_SUFFIX = {"host1": "1", "host2": "2"}
|
||||
TRIGGERS = ["base", "no_rt5", "no_rt2"]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
"""Test topology builder"""
|
||||
def build_topo(tgen):
|
||||
# This function only purpose is to define allocation and relationship
|
||||
# between routers and add links.
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function"""
|
||||
tgen = get_topogen(self)
|
||||
# Create routers
|
||||
for pe in PES:
|
||||
tgen.add_router(pe)
|
||||
for host in HOSTS:
|
||||
tgen.add_router(host)
|
||||
|
||||
# This function only purpose is to define allocation and relationship
|
||||
# between routers and add links.
|
||||
krel = platform.release()
|
||||
logger.info("Kernel version " + krel)
|
||||
|
||||
# Create routers
|
||||
for pe in PES:
|
||||
tgen.add_router(pe)
|
||||
for host in HOSTS:
|
||||
tgen.add_router(host)
|
||||
|
||||
krel = platform.release()
|
||||
logger.info('Kernel version ' + krel)
|
||||
|
||||
#Add links
|
||||
tgen.add_link(tgen.gears['PE1'], tgen.gears['PE2'], 'PE1-eth0', 'PE2-eth0')
|
||||
tgen.add_link(tgen.gears['PE1'], tgen.gears['host1'], 'PE1-eth1', 'host1-eth0')
|
||||
tgen.add_link(tgen.gears['PE2'], tgen.gears['host2'], 'PE2-eth1', 'host2-eth0')
|
||||
# Add links
|
||||
tgen.add_link(tgen.gears["PE1"], tgen.gears["PE2"], "PE1-eth0", "PE2-eth0")
|
||||
tgen.add_link(tgen.gears["PE1"], tgen.gears["host1"], "PE1-eth1", "host1-eth0")
|
||||
tgen.add_link(tgen.gears["PE2"], tgen.gears["host2"], "PE2-eth1", "host2-eth0")
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
@ -123,17 +116,21 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
kernelv = platform.release()
|
||||
if topotest.version_cmp(kernelv, "4.15") < 0:
|
||||
logger.info("For EVPN, kernel version should be minimum 4.15. Kernel present {}".format(kernelv))
|
||||
logger.info(
|
||||
"For EVPN, kernel version should be minimum 4.15. Kernel present {}".format(
|
||||
kernelv
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
if topotest.version_cmp(kernelv, '4.15') == 0:
|
||||
if topotest.version_cmp(kernelv, "4.15") == 0:
|
||||
l3mdev_accept = 1
|
||||
logger.info('setting net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept))
|
||||
logger.info("setting net.ipv4.tcp_l3mdev_accept={}".format(l3mdev_accept))
|
||||
else:
|
||||
l3mdev_accept = 0
|
||||
|
||||
@ -142,47 +139,58 @@ def setup_module(mod):
|
||||
tgen.start_topology()
|
||||
|
||||
# Configure MAC address for hosts as these MACs are advertised with EVPN type-2 routes
|
||||
for (name, host) in tgen.gears.items():
|
||||
for name in tgen.gears:
|
||||
if name not in HOSTS:
|
||||
continue
|
||||
host = tgen.net[name]
|
||||
|
||||
host_mac = "1a:2b:3c:4d:5e:6{}".format(HOST_SUFFIX[name])
|
||||
host.run("ip link set dev {}-eth0 down").format(name)
|
||||
host.run("ip link set dev {0}-eth0 address {1}".format(name, host_mac))
|
||||
host.run("ip link set dev {}-eth0 up").format(name)
|
||||
host.cmd_raises("ip link set dev {}-eth0 down".format(name))
|
||||
host.cmd_raises("ip link set dev {0}-eth0 address {1}".format(name, host_mac))
|
||||
host.cmd_raises("ip link set dev {}-eth0 up".format(name))
|
||||
|
||||
# Configure PE VxLAN and Bridge interfaces
|
||||
for (name, pe) in tgen.gears.items():
|
||||
for name in tgen.gears:
|
||||
if name not in PES:
|
||||
continue
|
||||
pe = tgen.net[name]
|
||||
|
||||
vtep_ip = "10.100.0.{}".format(PE_SUFFIX[name])
|
||||
bridge_ip = "50.0.1.{}/24".format(PE_SUFFIX[name])
|
||||
bridge_ipv6 = "50:0:1::{}/48".format(PE_SUFFIX[name])
|
||||
|
||||
pe.run("ip link add vrf-blue type vrf table 10")
|
||||
pe.run("ip link set dev vrf-blue up")
|
||||
pe.run("ip link add vxlan100 type vxlan id 100 dstport 4789 local {}".format(vtep_ip))
|
||||
pe.run("ip link add name br100 type bridge stp_state 0")
|
||||
pe.run("ip link set dev vxlan100 master br100")
|
||||
pe.run("ip link set dev {}-eth1 master br100".format(name))
|
||||
pe.run("ip addr add {} dev br100".format(bridge_ip))
|
||||
pe.run("ip link set up dev br100")
|
||||
pe.run("ip link set up dev vxlan100")
|
||||
pe.run("ip link set up dev {}-eth1".format(name))
|
||||
pe.run("ip link set dev br100 master vrf-blue")
|
||||
pe.run("ip -6 addr add {} dev br100".format(bridge_ipv6))
|
||||
pe.cmd_raises("ip link add vrf-blue type vrf table 10")
|
||||
pe.cmd_raises("ip link set dev vrf-blue up")
|
||||
pe.cmd_raises(
|
||||
"ip link add vxlan100 type vxlan id 100 dstport 4789 local {}".format(
|
||||
vtep_ip
|
||||
)
|
||||
)
|
||||
pe.cmd_raises("ip link add name br100 type bridge stp_state 0")
|
||||
pe.cmd_raises("ip link set dev vxlan100 master br100")
|
||||
pe.cmd_raises("ip link set dev {}-eth1 master br100".format(name))
|
||||
pe.cmd_raises("ip addr add {} dev br100".format(bridge_ip))
|
||||
pe.cmd_raises("ip link set up dev br100")
|
||||
pe.cmd_raises("ip link set up dev vxlan100")
|
||||
pe.cmd_raises("ip link set up dev {}-eth1".format(name))
|
||||
pe.cmd_raises("ip link set dev br100 master vrf-blue")
|
||||
pe.cmd_raises("ip -6 addr add {} dev br100".format(bridge_ipv6))
|
||||
|
||||
pe.run("ip link add vxlan1000 type vxlan id 1000 dstport 4789 local {}".format(vtep_ip))
|
||||
pe.run("ip link add name br1000 type bridge stp_state 0")
|
||||
pe.run("ip link set dev vxlan1000 master br100")
|
||||
pe.run("ip link set up dev br1000")
|
||||
pe.run("ip link set up dev vxlan1000")
|
||||
pe.run("ip link set dev br1000 master vrf-blue")
|
||||
pe.cmd_raises(
|
||||
"ip link add vxlan1000 type vxlan id 1000 dstport 4789 local {}".format(
|
||||
vtep_ip
|
||||
)
|
||||
)
|
||||
pe.cmd_raises("ip link add name br1000 type bridge stp_state 0")
|
||||
pe.cmd_raises("ip link set dev vxlan1000 master br100")
|
||||
pe.cmd_raises("ip link set up dev br1000")
|
||||
pe.cmd_raises("ip link set up dev vxlan1000")
|
||||
pe.cmd_raises("ip link set dev br1000 master vrf-blue")
|
||||
|
||||
pe.run("sysctl -w net.ipv4.ip_forward=1")
|
||||
pe.run("sysctl -w net.ipv6.conf.all.forwarding=1")
|
||||
pe.run("sysctl -w net.ipv4.udp_l3mdev_accept={}".format(l3mdev_accept))
|
||||
pe.run("sysctl -w net.ipv4.tcp_l3mdev_accept={}".format(l3mdev_accept))
|
||||
pe.cmd_raises("sysctl -w net.ipv4.ip_forward=1")
|
||||
pe.cmd_raises("sysctl -w net.ipv6.conf.all.forwarding=1")
|
||||
pe.cmd_raises("sysctl -w net.ipv4.udp_l3mdev_accept={}".format(l3mdev_accept))
|
||||
pe.cmd_raises("sysctl -w net.ipv4.tcp_l3mdev_accept={}".format(l3mdev_accept))
|
||||
|
||||
# For all registred routers, load the zebra configuration file
|
||||
for (name, router) in tgen.routers().items():
|
||||
@ -198,6 +206,8 @@ def setup_module(mod):
|
||||
|
||||
logger.info("Running setup_module() done")
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
def teardown_module(mod):
|
||||
"""Teardown the pytest environment"""
|
||||
@ -226,18 +236,22 @@ def evpn_gateway_ip_show_op_check(trigger=" "):
|
||||
if trigger not in TRIGGERS:
|
||||
return "Unexpected trigger", "Unexpected trigger {}".format(trigger)
|
||||
|
||||
show_commands = {'bgp_vni_routes': 'show bgp l2vpn evpn route vni 100 json',
|
||||
'bgp_vrf_ipv4' : 'show bgp vrf vrf-blue ipv4 json',
|
||||
'bgp_vrf_ipv6' : 'show bgp vrf vrf-blue ipv6 json',
|
||||
'zebra_vrf_ipv4': 'show ip route vrf vrf-blue json',
|
||||
'zebra_vrf_ipv6': 'show ipv6 route vrf vrf-blue json'}
|
||||
show_commands = {
|
||||
"bgp_vni_routes": "show bgp l2vpn evpn route vni 100 json",
|
||||
"bgp_vrf_ipv4": "show bgp vrf vrf-blue ipv4 json",
|
||||
"bgp_vrf_ipv6": "show bgp vrf vrf-blue ipv6 json",
|
||||
"zebra_vrf_ipv4": "show ip route vrf vrf-blue json",
|
||||
"zebra_vrf_ipv6": "show ipv6 route vrf vrf-blue json",
|
||||
}
|
||||
|
||||
for (name, pe) in tgen.gears.items():
|
||||
if name not in PES:
|
||||
continue
|
||||
|
||||
for (cmd_key, command) in show_commands.items():
|
||||
expected_op_file = "{0}/{1}/{2}_{3}.json".format(CWD, name, cmd_key, trigger)
|
||||
expected_op_file = "{0}/{1}/{2}_{3}.json".format(
|
||||
CWD, name, cmd_key, trigger
|
||||
)
|
||||
expected_op = json.loads(open(expected_op_file).read())
|
||||
|
||||
test_func = partial(topotest.router_json_cmp, pe, command, expected_op)
|
||||
@ -258,6 +272,11 @@ def test_evpn_gateway_ip_basic_topo(request):
|
||||
tc_name = request.node.name
|
||||
write_test_header(tc_name)
|
||||
|
||||
# Temporarily Disabled
|
||||
tgen.set_error(
|
||||
"%s: Failing under new micronet framework, please debug and re-enable", tc_name
|
||||
)
|
||||
|
||||
kernelv = platform.release()
|
||||
if topotest.version_cmp(kernelv, "4.15") < 0:
|
||||
logger.info("For EVPN, kernel version should be minimum 4.15")
|
||||
@ -295,18 +314,22 @@ def test_evpn_gateway_ip_flap_rt5(request):
|
||||
if tgen.routers_have_failure():
|
||||
pytest.skip(tgen.errors)
|
||||
|
||||
h1 = tgen.gears['host1']
|
||||
h1 = tgen.gears["host1"]
|
||||
|
||||
step("Withdraw type-5 routes")
|
||||
|
||||
h1.run('vtysh -c "config t" \
|
||||
h1.run(
|
||||
'vtysh -c "config t" \
|
||||
-c "router bgp 111" \
|
||||
-c "address-family ipv4" \
|
||||
-c "no network 100.0.0.21/32"')
|
||||
h1.run('vtysh -c "config t" \
|
||||
-c "no network 100.0.0.21/32"'
|
||||
)
|
||||
h1.run(
|
||||
'vtysh -c "config t" \
|
||||
-c "router bgp 111" \
|
||||
-c "address-family ipv6" \
|
||||
-c "no network 100::21/128"')
|
||||
-c "no network 100::21/128"'
|
||||
)
|
||||
|
||||
result, assertmsg = evpn_gateway_ip_show_op_check("no_rt5")
|
||||
if result is not None:
|
||||
@ -315,14 +338,18 @@ def test_evpn_gateway_ip_flap_rt5(request):
|
||||
|
||||
step("Advertise type-5 routes again")
|
||||
|
||||
h1.run('vtysh -c "config t" \
|
||||
h1.run(
|
||||
'vtysh -c "config t" \
|
||||
-c "router bgp 111" \
|
||||
-c "address-family ipv4" \
|
||||
-c "network 100.0.0.21/32"')
|
||||
h1.run('vtysh -c "config t" \
|
||||
-c "network 100.0.0.21/32"'
|
||||
)
|
||||
h1.run(
|
||||
'vtysh -c "config t" \
|
||||
-c "router bgp 111" \
|
||||
-c "address-family ipv6" \
|
||||
-c "network 100::21/128"')
|
||||
-c "network 100::21/128"'
|
||||
)
|
||||
|
||||
result, assertmsg = evpn_gateway_ip_show_op_check("base")
|
||||
if result is not None:
|
||||
@ -335,8 +362,8 @@ def test_evpn_gateway_ip_flap_rt5(request):
|
||||
|
||||
def test_evpn_gateway_ip_flap_rt2(request):
|
||||
"""
|
||||
Withdraw EVPN type-2 routes and check O/Ps at PE1 and PE2
|
||||
"""
|
||||
Withdraw EVPN type-2 routes and check O/Ps at PE1 and PE2
|
||||
"""
|
||||
tgen = get_topogen()
|
||||
tc_name = request.node.name
|
||||
write_test_header(tc_name)
|
||||
@ -350,12 +377,11 @@ def test_evpn_gateway_ip_flap_rt2(request):
|
||||
if tgen.routers_have_failure():
|
||||
pytest.skip(tgen.errors)
|
||||
|
||||
|
||||
step("Shut down VxLAN interface at PE1 which results in withdraw of type-2 routes")
|
||||
|
||||
pe1 = tgen.gears['PE1']
|
||||
pe1 = tgen.net["PE1"]
|
||||
|
||||
pe1.run('ip link set dev vxlan100 down')
|
||||
pe1.cmd_raises("ip link set dev vxlan100 down")
|
||||
|
||||
result, assertmsg = evpn_gateway_ip_show_op_check("no_rt2")
|
||||
if result is not None:
|
||||
@ -364,7 +390,7 @@ def test_evpn_gateway_ip_flap_rt2(request):
|
||||
|
||||
step("Bring up VxLAN interface at PE1 and advertise type-2 routes again")
|
||||
|
||||
pe1.run('ip link set dev vxlan100 up')
|
||||
pe1.cmd_raises("ip link set dev vxlan100 up")
|
||||
|
||||
result, assertmsg = evpn_gateway_ip_show_op_check("base")
|
||||
if result is not None:
|
||||
@ -382,6 +408,7 @@ def test_memory_leak():
|
||||
|
||||
tgen.report_memory_leaks()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = ["-s"] + sys.argv[1:]
|
||||
sys.exit(pytest.main(args))
|
||||
|
@ -28,8 +28,6 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
from functools import partial
|
||||
import pytest
|
||||
import platform
|
||||
|
||||
@ -44,35 +42,31 @@ 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]
|
||||
|
||||
class BGPEVPNTopo(Topo):
|
||||
"Test topology builder"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
"Build function"
|
||||
|
||||
tgen.add_router("r1")
|
||||
tgen.add_router("r2")
|
||||
tgen.add_router("r1")
|
||||
tgen.add_router("r2")
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
|
||||
tgen = Topogen(BGPEVPNTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
@ -97,12 +91,6 @@ def setup_module(mod):
|
||||
"ip link set dev loop101 master {}-vrf-101",
|
||||
"ip link set dev loop101 up",
|
||||
]
|
||||
cmds_netns = [
|
||||
"ip netns add {}-vrf-101",
|
||||
"ip link add loop101 type dummy",
|
||||
"ip link set dev loop101 netns {}-vrf-101",
|
||||
"ip netns exec {}-vrf-101 ip link set dev loop101 up",
|
||||
]
|
||||
|
||||
cmds_r2 = [ # config routing 101
|
||||
"ip link add name bridge-101 up type bridge stp_state 0",
|
||||
@ -113,40 +101,47 @@ def setup_module(mod):
|
||||
"ip link set vxlan-101 up type bridge_slave learning off flood off mcast_flood off",
|
||||
]
|
||||
|
||||
cmds_r1_netns_method3 = [
|
||||
"ip link add name vxlan-{1} type vxlan id {1} dstport 4789 dev {0}-eth0 local 192.168.100.21",
|
||||
"ip link set dev vxlan-{1} netns {0}-vrf-{1}",
|
||||
"ip netns exec {0}-vrf-{1} ip li set dev lo up",
|
||||
"ip netns exec {0}-vrf-{1} ip link add name bridge-{1} up type bridge stp_state 0",
|
||||
"ip netns exec {0}-vrf-{1} ip link set dev vxlan-{1} master bridge-{1}",
|
||||
"ip netns exec {0}-vrf-{1} ip link set bridge-{1} up",
|
||||
"ip netns exec {0}-vrf-{1} ip link set vxlan-{1} up",
|
||||
]
|
||||
# cmds_r1_netns_method3 = [
|
||||
# "ip link add name vxlan-{1} type vxlan id {1} dstport 4789 dev {0}-eth0 local 192.168.100.21",
|
||||
# "ip link set dev vxlan-{1} netns {0}-vrf-{1}",
|
||||
# "ip netns exec {0}-vrf-{1} ip li set dev lo up",
|
||||
# "ip netns exec {0}-vrf-{1} ip link add name bridge-{1} up type bridge stp_state 0",
|
||||
# "ip netns exec {0}-vrf-{1} ip link set dev vxlan-{1} master bridge-{1}",
|
||||
# "ip netns exec {0}-vrf-{1} ip link set bridge-{1} up",
|
||||
# "ip netns exec {0}-vrf-{1} ip link set vxlan-{1} up",
|
||||
# ]
|
||||
|
||||
router = tgen.gears["r1"]
|
||||
for cmd in cmds_netns:
|
||||
logger.info("cmd to r1: " + cmd)
|
||||
output = router.run(cmd.format("r1"))
|
||||
logger.info("result: " + output)
|
||||
|
||||
ns = "r1-vrf-101"
|
||||
tgen.net["r1"].add_netns(ns)
|
||||
tgen.net["r1"].cmd_raises("ip link add loop101 type dummy")
|
||||
tgen.net["r1"].set_intf_netns("loop101", ns, up=True)
|
||||
|
||||
router = tgen.gears["r2"]
|
||||
for cmd in cmds_vrflite:
|
||||
logger.info("cmd to r2: " + cmd.format("r2"))
|
||||
output = router.run(cmd.format("r2"))
|
||||
output = router.cmd_raises(cmd.format("r2"))
|
||||
logger.info("result: " + output)
|
||||
|
||||
for cmd in cmds_r2:
|
||||
logger.info("cmd to r2: " + cmd.format("r2"))
|
||||
output = router.run(cmd.format("r2"))
|
||||
output = router.cmd_raises(cmd.format("r2"))
|
||||
logger.info("result: " + output)
|
||||
|
||||
router = tgen.gears["r1"]
|
||||
bridge_id = "101"
|
||||
for cmd in cmds_r1_netns_method3:
|
||||
logger.info("cmd to r1: " + cmd.format("r1", bridge_id))
|
||||
output = router.run(cmd.format("r1", bridge_id))
|
||||
logger.info("result: " + output)
|
||||
router = tgen.gears["r1"]
|
||||
tgen.net["r1"].cmd_raises(
|
||||
"ip link add name vxlan-101 type vxlan id 101 dstport 4789 dev r1-eth0 local 192.168.100.21"
|
||||
)
|
||||
tgen.net["r1"].set_intf_netns("vxlan-101", "r1-vrf-101", up=True)
|
||||
tgen.net["r1"].cmd_raises("ip -n r1-vrf-101 link set lo up")
|
||||
tgen.net["r1"].cmd_raises(
|
||||
"ip -n r1-vrf-101 link add name bridge-101 up type bridge stp_state 0"
|
||||
)
|
||||
tgen.net["r1"].cmd_raises(
|
||||
"ip -n r1-vrf-101 link set dev vxlan-101 master bridge-101"
|
||||
)
|
||||
tgen.net["r1"].cmd_raises("ip -n r1-vrf-101 link set bridge-101 up")
|
||||
tgen.net["r1"].cmd_raises("ip -n r1-vrf-101 link set vxlan-101 up")
|
||||
|
||||
for rname, router in router_list.items():
|
||||
if rname == "r1":
|
||||
@ -170,12 +165,8 @@ def setup_module(mod):
|
||||
def teardown_module(_mod):
|
||||
"Teardown the pytest environment"
|
||||
tgen = get_topogen()
|
||||
cmds_rx_netns = ["ip netns del {}-vrf-101"]
|
||||
|
||||
router = tgen.gears["r1"]
|
||||
for cmd in cmds_rx_netns:
|
||||
logger.info("cmd to r1: " + cmd.format("r1"))
|
||||
output = router.run(cmd.format("r1"))
|
||||
tgen.net["r1"].delete_netns("r1-vrf-101")
|
||||
tgen.stop_topology()
|
||||
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
"vtepIp":"10.10.10.10",
|
||||
"mcastGroup":"0.0.0.0",
|
||||
"advertiseGatewayMacip":"No",
|
||||
"numMacs":6,
|
||||
"numArpNd":6,
|
||||
"numRemoteVteps":[
|
||||
"10.30.30.30"
|
||||
]
|
||||
|
@ -6,8 +6,6 @@
|
||||
"vtepIp":"10.30.30.30",
|
||||
"mcastGroup":"0.0.0.0",
|
||||
"advertiseGatewayMacip":"No",
|
||||
"numMacs":6,
|
||||
"numArpNd":6,
|
||||
"numRemoteVteps":[
|
||||
"10.10.10.10"
|
||||
]
|
||||
|
@ -43,54 +43,49 @@ 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, pytest.mark.ospfd]
|
||||
|
||||
|
||||
class TemplateTopo(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 routers
|
||||
tgen.add_router("P1")
|
||||
tgen.add_router("PE1")
|
||||
tgen.add_router("PE2")
|
||||
tgen.add_router("host1")
|
||||
tgen.add_router("host2")
|
||||
|
||||
# This function only purpose is to define allocation and relationship
|
||||
# between routers, switches and hosts.
|
||||
#
|
||||
#
|
||||
# Create routers
|
||||
tgen.add_router("P1")
|
||||
tgen.add_router("PE1")
|
||||
tgen.add_router("PE2")
|
||||
tgen.add_router("host1")
|
||||
tgen.add_router("host2")
|
||||
# Host1-PE1
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["host1"])
|
||||
switch.add_link(tgen.gears["PE1"])
|
||||
|
||||
# Host1-PE1
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["host1"])
|
||||
switch.add_link(tgen.gears["PE1"])
|
||||
# PE1-P1
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["PE1"])
|
||||
switch.add_link(tgen.gears["P1"])
|
||||
|
||||
# PE1-P1
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["PE1"])
|
||||
switch.add_link(tgen.gears["P1"])
|
||||
# P1-PE2
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["P1"])
|
||||
switch.add_link(tgen.gears["PE2"])
|
||||
|
||||
# P1-PE2
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["P1"])
|
||||
switch.add_link(tgen.gears["PE2"])
|
||||
|
||||
# PE2-host2
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["PE2"])
|
||||
switch.add_link(tgen.gears["host2"])
|
||||
# PE2-host2
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["PE2"])
|
||||
switch.add_link(tgen.gears["host2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
tgen.start_topology()
|
||||
|
||||
@ -156,6 +151,17 @@ def show_vni_json_elide_ifindex(pe, vni, expected):
|
||||
return topotest.json_cmp(output_json, expected)
|
||||
|
||||
|
||||
def check_vni_macs_present(tgen, router, vni, maclist):
|
||||
result = router.vtysh_cmd("show evpn mac vni {} json".format(vni), isjson=True)
|
||||
for rname, ifname in maclist:
|
||||
m = tgen.net.macs[(rname, ifname)]
|
||||
if m not in result["macs"]:
|
||||
return "MAC ({}) for interface {} on {} missing on {} from {}".format(
|
||||
m, ifname, rname, router.name, json.dumps(result, indent=4)
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
def test_pe1_converge_evpn():
|
||||
"Wait for protocol convergence"
|
||||
|
||||
@ -169,10 +175,20 @@ def test_pe1_converge_evpn():
|
||||
expected = json.loads(open(json_file).read())
|
||||
|
||||
test_func = partial(show_vni_json_elide_ifindex, pe1, 101, expected)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=125, wait=1)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=45, wait=1)
|
||||
assertmsg = '"{}" JSON output mismatches'.format(pe1.name)
|
||||
assert result is None, assertmsg
|
||||
# tgen.mininet_cli()
|
||||
|
||||
test_func = partial(
|
||||
check_vni_macs_present,
|
||||
tgen,
|
||||
pe1,
|
||||
101,
|
||||
(("host1", "host1-eth0"), ("host2", "host2-eth0")),
|
||||
)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
|
||||
if result:
|
||||
logger.warning("%s", result)
|
||||
assert None, '"{}" missing expected MACs'.format(pe1.name)
|
||||
|
||||
|
||||
def test_pe2_converge_evpn():
|
||||
@ -188,10 +204,21 @@ def test_pe2_converge_evpn():
|
||||
expected = json.loads(open(json_file).read())
|
||||
|
||||
test_func = partial(show_vni_json_elide_ifindex, pe2, 101, expected)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=125, wait=1)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=45, wait=1)
|
||||
assertmsg = '"{}" JSON output mismatches'.format(pe2.name)
|
||||
assert result is None, assertmsg
|
||||
# tgen.mininet_cli()
|
||||
|
||||
test_func = partial(
|
||||
check_vni_macs_present,
|
||||
tgen,
|
||||
pe2,
|
||||
101,
|
||||
(("host1", "host1-eth0"), ("host2", "host2-eth0")),
|
||||
)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
|
||||
if result:
|
||||
logger.warning("%s", result)
|
||||
assert None, '"{}" missing expected MACs'.format(pe2.name)
|
||||
|
||||
|
||||
def mac_learn_test(host, local):
|
||||
@ -262,7 +289,7 @@ def test_learning_pe2():
|
||||
|
||||
|
||||
def test_local_remote_mac_pe1():
|
||||
" Test MAC transfer PE1 local and PE2 remote"
|
||||
"Test MAC transfer PE1 local and PE2 remote"
|
||||
|
||||
tgen = get_topogen()
|
||||
# Don't run this test if we have any failure.
|
||||
@ -275,7 +302,7 @@ def test_local_remote_mac_pe1():
|
||||
|
||||
|
||||
def test_local_remote_mac_pe2():
|
||||
" Test MAC transfer PE2 local and PE1 remote"
|
||||
"Test MAC transfer PE2 local and PE1 remote"
|
||||
|
||||
tgen = get_topogen()
|
||||
# Don't run this test if we have any failure.
|
||||
|
@ -45,7 +45,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, pytest.mark.ospfd]
|
||||
|
||||
@ -56,40 +55,48 @@ pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
|
||||
#####################################################
|
||||
|
||||
|
||||
class BGPFeaturesTopo1(Topo):
|
||||
"BGP Features Topology 1"
|
||||
def build_topo(tgen):
|
||||
for rtrNum in range(1, 6):
|
||||
tgen.add_router("r{}".format(rtrNum))
|
||||
|
||||
def build(self, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
# create ExaBGP peers
|
||||
for peer_num in range(1, 5):
|
||||
tgen.add_exabgp_peer(
|
||||
"peer{}".format(peer_num),
|
||||
ip="192.168.101.{}".format(peer_num + 2),
|
||||
defaultRoute="via 192.168.101.1",
|
||||
)
|
||||
|
||||
# Create the routers
|
||||
for rtrNum in range(1, 6):
|
||||
tgen.add_router("r{}".format(rtrNum))
|
||||
# Setup Switches and connections
|
||||
for swNum in range(1, 11):
|
||||
tgen.add_switch("sw{}".format(swNum))
|
||||
|
||||
# Setup Switches and connections
|
||||
for swNum in range(1, 11):
|
||||
tgen.add_switch("sw{}".format(swNum))
|
||||
# Add connections to stub switches
|
||||
tgen.gears["r1"].add_link(tgen.gears["sw6"])
|
||||
tgen.gears["r2"].add_link(tgen.gears["sw7"])
|
||||
tgen.gears["r3"].add_link(tgen.gears["sw8"])
|
||||
tgen.gears["r4"].add_link(tgen.gears["sw9"])
|
||||
tgen.gears["r5"].add_link(tgen.gears["sw10"])
|
||||
|
||||
# Add connections to stub switches
|
||||
tgen.gears["r1"].add_link(tgen.gears["sw6"])
|
||||
tgen.gears["r2"].add_link(tgen.gears["sw7"])
|
||||
tgen.gears["r3"].add_link(tgen.gears["sw8"])
|
||||
tgen.gears["r4"].add_link(tgen.gears["sw9"])
|
||||
tgen.gears["r5"].add_link(tgen.gears["sw10"])
|
||||
# Add connections to R1-R2-R3 core
|
||||
tgen.gears["r1"].add_link(tgen.gears["sw1"])
|
||||
tgen.gears["r1"].add_link(tgen.gears["sw3"])
|
||||
tgen.gears["r2"].add_link(tgen.gears["sw1"])
|
||||
tgen.gears["r2"].add_link(tgen.gears["sw2"])
|
||||
tgen.gears["r3"].add_link(tgen.gears["sw2"])
|
||||
tgen.gears["r3"].add_link(tgen.gears["sw3"])
|
||||
|
||||
# Add connections to R1-R2-R3 core
|
||||
tgen.gears["r1"].add_link(tgen.gears["sw1"])
|
||||
tgen.gears["r1"].add_link(tgen.gears["sw3"])
|
||||
tgen.gears["r2"].add_link(tgen.gears["sw1"])
|
||||
tgen.gears["r2"].add_link(tgen.gears["sw2"])
|
||||
tgen.gears["r3"].add_link(tgen.gears["sw2"])
|
||||
tgen.gears["r3"].add_link(tgen.gears["sw3"])
|
||||
# Add connections to external R4/R5 Routers
|
||||
tgen.gears["r1"].add_link(tgen.gears["sw4"])
|
||||
tgen.gears["r4"].add_link(tgen.gears["sw4"])
|
||||
tgen.gears["r2"].add_link(tgen.gears["sw5"])
|
||||
tgen.gears["r5"].add_link(tgen.gears["sw5"])
|
||||
|
||||
# Add connections to external R4/R5 Routers
|
||||
tgen.gears["r1"].add_link(tgen.gears["sw4"])
|
||||
tgen.gears["r4"].add_link(tgen.gears["sw4"])
|
||||
tgen.gears["r2"].add_link(tgen.gears["sw5"])
|
||||
tgen.gears["r5"].add_link(tgen.gears["sw5"])
|
||||
# Add ExaBGP peers to sw4
|
||||
tgen.gears["peer1"].add_link(tgen.gears["sw4"])
|
||||
tgen.gears["peer2"].add_link(tgen.gears["sw4"])
|
||||
tgen.gears["peer3"].add_link(tgen.gears["sw4"])
|
||||
tgen.gears["peer4"].add_link(tgen.gears["sw4"])
|
||||
|
||||
|
||||
#####################################################
|
||||
@ -100,7 +107,7 @@ class BGPFeaturesTopo1(Topo):
|
||||
|
||||
|
||||
def setup_module(module):
|
||||
tgen = Topogen(BGPFeaturesTopo1, module.__name__)
|
||||
tgen = Topogen(build_topo, module.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
# Starting Routers
|
||||
|
@ -54,7 +54,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 +64,8 @@ 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]
|
||||
@ -82,24 +78,18 @@ pytestmark = [pytest.mark.bgpd]
|
||||
#####################################################
|
||||
|
||||
|
||||
class BGPFLOWSPECTopo1(Topo):
|
||||
"BGP EBGP Flowspec Topology 1"
|
||||
def build_topo(tgen):
|
||||
tgen.add_router("r1")
|
||||
|
||||
def build(self, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
# Setup Control Path Switch 1. r1-eth0
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["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"])
|
||||
|
||||
## 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)
|
||||
|
||||
|
||||
#####################################################
|
||||
@ -110,7 +100,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
|
||||
|
@ -89,9 +89,7 @@ Basic Common Test steps for all the test case below :
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import inspect
|
||||
import pytest
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -101,15 +99,13 @@ sys.path.append(os.path.join("../lib/"))
|
||||
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from lib.topolog import logger
|
||||
|
||||
# Required to instantiate the topology builder class.
|
||||
from mininet.topo import Topo
|
||||
|
||||
# Import topoJson from lib, to create topology and initial configuration
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
from lib.bgp import (
|
||||
clear_bgp,
|
||||
verify_bgp_rib,
|
||||
@ -117,7 +113,6 @@ from lib.bgp import (
|
||||
create_router_bgp,
|
||||
verify_r_bit,
|
||||
verify_f_bit,
|
||||
verify_graceful_restart_timers,
|
||||
verify_bgp_convergence,
|
||||
verify_bgp_convergence_from_running_config,
|
||||
)
|
||||
@ -135,22 +130,12 @@ from lib.common_config import (
|
||||
shutdown_bringup_interface,
|
||||
step,
|
||||
get_frr_ipv6_linklocal,
|
||||
create_route_maps,
|
||||
required_linux_kernel_version,
|
||||
)
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/bgp_gr_topojson_topo1.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
logger.info("Could not read file:", jsonFile)
|
||||
|
||||
|
||||
# Global variables
|
||||
NEXT_HOP_IP = {"ipv4": "192.168.1.10", "ipv6": "fd00:0:0:1::10"}
|
||||
NEXT_HOP_IP_1 = {"ipv4": "192.168.0.1", "ipv6": "fd00::1"}
|
||||
@ -160,28 +145,6 @@ GR_RESTART_TIMER = 20
|
||||
PREFERRED_NEXT_HOP = "link_local"
|
||||
|
||||
|
||||
class GenerateTopo(Topo):
|
||||
"""
|
||||
Test topology builder
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# This function only purpose is to create topology
|
||||
# as defined in input json file.
|
||||
#
|
||||
# Create topology (setup module)
|
||||
# Creating 2 routers topology, r1, r2in IBGP
|
||||
# Bring up topology
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -203,7 +166,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(GenerateTopo, mod.__name__)
|
||||
json_file = "{}/bgp_gr_topojson_topo1.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
|
@ -84,11 +84,9 @@ TC_30:
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
from time import sleep
|
||||
from copy import deepcopy
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -97,15 +95,13 @@ sys.path.append(os.path.join("../lib/"))
|
||||
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib import topotest
|
||||
from lib.topogen import Topogen, TopoRouter, get_topogen
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from lib.topolog import logger
|
||||
|
||||
# Required to instantiate the topology builder class.
|
||||
from mininet.topo import Topo
|
||||
|
||||
# Import topoJson from lib, to create topology and initial configuration
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
from lib.bgp import (
|
||||
clear_bgp,
|
||||
verify_bgp_rib,
|
||||
@ -131,24 +127,14 @@ from lib.common_config import (
|
||||
check_address_types,
|
||||
write_test_footer,
|
||||
check_router_status,
|
||||
shutdown_bringup_interface,
|
||||
step,
|
||||
get_frr_ipv6_linklocal,
|
||||
create_route_maps,
|
||||
required_linux_kernel_version,
|
||||
)
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/bgp_gr_topojson_topo2.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
logger.info("Could not read file:", jsonFile)
|
||||
|
||||
# Global variables
|
||||
BGP_CONVERGENCE = False
|
||||
GR_RESTART_TIMER = 5
|
||||
@ -159,28 +145,6 @@ NEXT_HOP_4 = ["192.168.1.1", "192.168.4.2"]
|
||||
NEXT_HOP_6 = ["fd00:0:0:1::1", "fd00:0:0:4::2"]
|
||||
|
||||
|
||||
class GenerateTopo(Topo):
|
||||
"""
|
||||
Test topology builder
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# This function only purpose is to create topology
|
||||
# as defined in input json file.
|
||||
#
|
||||
# Create topology (setup module)
|
||||
# Creating 2 routers topology, r1, r2in IBGP
|
||||
# Bring up topology
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -202,7 +166,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(GenerateTopo, mod.__name__)
|
||||
json_file = "{}/bgp_gr_topojson_topo2.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
@ -847,7 +814,11 @@ def test_BGP_GR_10_p2(request):
|
||||
configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r3")
|
||||
|
||||
for addr_type in ADDR_TYPES:
|
||||
step("Verifying GR config and operational state for addr_type {}".format(addr_type))
|
||||
step(
|
||||
"Verifying GR config and operational state for addr_type {}".format(
|
||||
addr_type
|
||||
)
|
||||
)
|
||||
|
||||
result = verify_graceful_restart(
|
||||
tgen, topo, addr_type, input_dict, dut="r1", peer="r3"
|
||||
@ -872,7 +843,12 @@ def test_BGP_GR_10_p2(request):
|
||||
|
||||
# verify multi address family
|
||||
result = verify_gr_address_family(
|
||||
tgen, topo, addr_type, "ipv4Unicast", dut="r1", peer="r3",
|
||||
tgen,
|
||||
topo,
|
||||
addr_type,
|
||||
"ipv4Unicast",
|
||||
dut="r1",
|
||||
peer="r3",
|
||||
)
|
||||
assert result is True, "Testcase {} : Failed \n Error {}".format(
|
||||
tc_name, result
|
||||
@ -880,7 +856,12 @@ def test_BGP_GR_10_p2(request):
|
||||
|
||||
# verify multi address family
|
||||
result = verify_gr_address_family(
|
||||
tgen, topo, addr_type, "ipv6Unicast", dut="r1", peer="r3",
|
||||
tgen,
|
||||
topo,
|
||||
addr_type,
|
||||
"ipv6Unicast",
|
||||
dut="r1",
|
||||
peer="r3",
|
||||
)
|
||||
assert result is True, "Testcase {} : Failed \n Error {}".format(
|
||||
tc_name, result
|
||||
@ -888,7 +869,12 @@ def test_BGP_GR_10_p2(request):
|
||||
|
||||
# verify multi address family
|
||||
result = verify_gr_address_family(
|
||||
tgen, topo, addr_type, "ipv4Unicast", dut="r3", peer="r1",
|
||||
tgen,
|
||||
topo,
|
||||
addr_type,
|
||||
"ipv4Unicast",
|
||||
dut="r3",
|
||||
peer="r1",
|
||||
)
|
||||
assert result is True, "Testcase {} : Failed \n Error {}".format(
|
||||
tc_name, result
|
||||
@ -896,7 +882,12 @@ def test_BGP_GR_10_p2(request):
|
||||
|
||||
# verify multi address family
|
||||
result = verify_gr_address_family(
|
||||
tgen, topo, addr_type, "ipv6Unicast", dut="r3", peer="r1",
|
||||
tgen,
|
||||
topo,
|
||||
addr_type,
|
||||
"ipv6Unicast",
|
||||
dut="r3",
|
||||
peer="r1",
|
||||
)
|
||||
assert result is True, "Testcase {} : Failed \n Error {}".format(
|
||||
tc_name, result
|
||||
@ -1677,7 +1668,12 @@ def test_BGP_GR_26_p2(request):
|
||||
|
||||
# verify multi address family
|
||||
result = verify_gr_address_family(
|
||||
tgen, topo, addr_type, "ipv4Unicast", dut="r1", peer="r3",
|
||||
tgen,
|
||||
topo,
|
||||
addr_type,
|
||||
"ipv4Unicast",
|
||||
dut="r1",
|
||||
peer="r3",
|
||||
)
|
||||
assert result is True, "Testcase {} : Failed \n Error {}".format(
|
||||
tc_name, result
|
||||
@ -1685,7 +1681,12 @@ def test_BGP_GR_26_p2(request):
|
||||
|
||||
# verify multi address family
|
||||
result = verify_gr_address_family(
|
||||
tgen, topo, addr_type, "ipv6Unicast", dut="r1", peer="r3",
|
||||
tgen,
|
||||
topo,
|
||||
addr_type,
|
||||
"ipv6Unicast",
|
||||
dut="r1",
|
||||
peer="r3",
|
||||
)
|
||||
assert result is True, "Testcase {} : Failed \n Error {}".format(
|
||||
tc_name, result
|
||||
@ -1693,7 +1694,12 @@ def test_BGP_GR_26_p2(request):
|
||||
|
||||
# verify multi address family
|
||||
result = verify_gr_address_family(
|
||||
tgen, topo, addr_type, "ipv4Unicast", dut="r3", peer="r1",
|
||||
tgen,
|
||||
topo,
|
||||
addr_type,
|
||||
"ipv4Unicast",
|
||||
dut="r3",
|
||||
peer="r1",
|
||||
)
|
||||
assert result is True, "Testcase {} : Failed \n Error {}".format(
|
||||
tc_name, result
|
||||
@ -1701,7 +1707,12 @@ def test_BGP_GR_26_p2(request):
|
||||
|
||||
# verify multi address family
|
||||
result = verify_gr_address_family(
|
||||
tgen, topo, addr_type, "ipv6Unicast", dut="r3", peer="r1",
|
||||
tgen,
|
||||
topo,
|
||||
addr_type,
|
||||
"ipv6Unicast",
|
||||
dut="r3",
|
||||
peer="r1",
|
||||
)
|
||||
assert result is True, "Testcase {} : Failed \n Error {}".format(
|
||||
tc_name, result
|
||||
|
@ -60,9 +60,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import pytest
|
||||
import functools
|
||||
import platform
|
||||
from functools import partial
|
||||
|
||||
@ -73,33 +71,29 @@ 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 mininet.topo import Topo
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
class TemplateTopo(Topo):
|
||||
def build(self, *_args, **_opts):
|
||||
tgen = get_topogen(self)
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 6):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
for routern in range(1, 6):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
switch = tgen.add_switch("s3")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r4"])
|
||||
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r5"])
|
||||
switch = tgen.add_switch("s4")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r5"])
|
||||
|
||||
|
||||
def _run_cmd_and_check(router, cmd, results_file, retries=100, intvl=0.5):
|
||||
@ -110,7 +104,7 @@ def _run_cmd_and_check(router, cmd, results_file, retries=100, intvl=0.5):
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(TemplateTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -31,7 +31,6 @@ Following tests are covered to test ecmp functionality on BGP GSHUT.
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -42,17 +41,13 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
from time import sleep
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
write_test_header,
|
||||
write_test_footer,
|
||||
verify_rib,
|
||||
create_static_routes,
|
||||
check_address_types,
|
||||
interface_status,
|
||||
reset_config_on_routers,
|
||||
step,
|
||||
get_frr_ipv6_linklocal,
|
||||
@ -62,30 +57,21 @@ from lib.common_config import (
|
||||
start_router,
|
||||
create_route_maps,
|
||||
create_bgp_community_lists,
|
||||
delete_route_maps,
|
||||
required_linux_kernel_version,
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
clear_bgp,
|
||||
verify_bgp_rib,
|
||||
verify_bgp_attributes,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/ebgp_gshut_topo1.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
logger.info("Could not read file:", jsonFile)
|
||||
|
||||
# Global variables
|
||||
NETWORK = {"ipv4": "100.0.10.1/32", "ipv6": "1::1/128"}
|
||||
NEXT_HOP_IP_1 = {"ipv4": "10.0.2.1", "ipv6": "fd00:0:0:1::1"}
|
||||
@ -94,28 +80,6 @@ PREFERRED_NEXT_HOP = "link_local"
|
||||
BGP_CONVERGENCE = False
|
||||
|
||||
|
||||
class GenerateTopo(Topo):
|
||||
"""
|
||||
Test topology builder
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# This function only purpose is to create topology
|
||||
# as defined in input json file.
|
||||
#
|
||||
# Create topology (setup module)
|
||||
# Creating 2 routers topology, r1, r2in IBGP
|
||||
# Bring up topology
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -137,7 +101,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(GenerateTopo, mod.__name__)
|
||||
json_file = "{}/ebgp_gshut_topo1.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
@ -349,7 +316,13 @@ def test_verify_graceful_shutdown_functionality_with_eBGP_peers_p0(request):
|
||||
step("local pref for routes coming from R1 is set to 0.")
|
||||
|
||||
for addr_type in ADDR_TYPES:
|
||||
rmap_dict = {"r1": {"route_maps": {"GSHUT-OUT": [{"set": {"locPrf": 0}}],}}}
|
||||
rmap_dict = {
|
||||
"r1": {
|
||||
"route_maps": {
|
||||
"GSHUT-OUT": [{"set": {"locPrf": 0}}],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static_routes = [NETWORK[addr_type]]
|
||||
result = verify_bgp_attributes(
|
||||
|
@ -31,7 +31,6 @@ Following tests are covered to test ecmp functionality on BGP GSHUT.
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
@ -42,50 +41,32 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
from time import sleep
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
write_test_header,
|
||||
write_test_footer,
|
||||
verify_rib,
|
||||
create_static_routes,
|
||||
check_address_types,
|
||||
interface_status,
|
||||
reset_config_on_routers,
|
||||
step,
|
||||
get_frr_ipv6_linklocal,
|
||||
kill_router_daemons,
|
||||
start_router_daemons,
|
||||
stop_router,
|
||||
start_router,
|
||||
create_route_maps,
|
||||
create_bgp_community_lists,
|
||||
delete_route_maps,
|
||||
required_linux_kernel_version,
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
clear_bgp,
|
||||
verify_bgp_rib,
|
||||
verify_bgp_attributes,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/ibgp_gshut_topo1.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
logger.info("Could not read file:", jsonFile)
|
||||
|
||||
# Global variables
|
||||
NETWORK = {"ipv4": "100.0.10.1/32", "ipv6": "1::1/128"}
|
||||
NEXT_HOP_IP_1 = {"ipv4": "10.0.3.1", "ipv6": "fd00:0:0:3::1"}
|
||||
@ -94,28 +75,6 @@ PREFERRED_NEXT_HOP = "link_local"
|
||||
BGP_CONVERGENCE = False
|
||||
|
||||
|
||||
class GenerateTopo(Topo):
|
||||
"""
|
||||
Test topology builder
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# This function only purpose is to create topology
|
||||
# as defined in input json file.
|
||||
#
|
||||
# Create topology (setup module)
|
||||
# Creating 2 routers topology, r1, r2in IBGP
|
||||
# Bring up topology
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -137,7 +96,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(GenerateTopo, mod.__name__)
|
||||
json_file = "{}/ibgp_gshut_topo1.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
@ -351,7 +313,13 @@ def test_verify_graceful_shutdown_functionality_with_iBGP_peers_p0(request):
|
||||
step("local pref for routes coming from R1 is set to 0.")
|
||||
|
||||
for addr_type in ADDR_TYPES:
|
||||
rmap_dict = {"r1": {"route_maps": {"GSHUT-OUT": [{"set": {"locPrf": 0}}],}}}
|
||||
rmap_dict = {
|
||||
"r1": {
|
||||
"route_maps": {
|
||||
"GSHUT-OUT": [{"set": {"locPrf": 0}}],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static_routes = [NETWORK[addr_type]]
|
||||
result = verify_bgp_attributes(
|
||||
@ -537,7 +505,13 @@ def test_verify_deleting_re_adding_route_map_with_iBGP_peers_p0(request):
|
||||
step("local pref for routes coming from R1 is set to 0.")
|
||||
|
||||
for addr_type in ADDR_TYPES:
|
||||
rmap_dict = {"r1": {"route_maps": {"GSHUT-OUT": [{"set": {"locPrf": 0}}],}}}
|
||||
rmap_dict = {
|
||||
"r1": {
|
||||
"route_maps": {
|
||||
"GSHUT-OUT": [{"set": {"locPrf": 0}}],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static_routes = [NETWORK[addr_type]]
|
||||
result = verify_bgp_attributes(
|
||||
|
@ -25,11 +25,8 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
from copy import deepcopy
|
||||
import ipaddr
|
||||
from re import search as re_search
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -39,40 +36,28 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
write_test_header,
|
||||
get_frr_ipv6_linklocal,
|
||||
write_test_footer,
|
||||
create_prefix_lists,
|
||||
verify_rib,
|
||||
create_static_routes,
|
||||
check_address_types,
|
||||
reset_config_on_routers,
|
||||
step,
|
||||
create_route_maps,
|
||||
create_interfaces_cfg,
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
clear_bgp_and_verify,
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
verify_bgp_rib,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
# Global variables
|
||||
topo = None
|
||||
# Reading the data from JSON File for topology creation
|
||||
jsonFile = "{}/rfc5549_ebgp_ibgp_nbr.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
NETWORK = {
|
||||
@ -121,21 +106,6 @@ unchange is configure on EBGP peers
|
||||
"""
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder.
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function."""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""Set up the pytest environment."""
|
||||
|
||||
@ -147,7 +117,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/rfc5549_ebgp_ibgp_nbr.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
|
@ -25,12 +25,7 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
import datetime
|
||||
from copy import deepcopy
|
||||
import ipaddr
|
||||
from re import search as re_search
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -40,44 +35,28 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
write_test_header,
|
||||
write_test_footer,
|
||||
create_prefix_lists,
|
||||
get_frr_ipv6_linklocal,
|
||||
verify_rib,
|
||||
create_static_routes,
|
||||
check_address_types,
|
||||
reset_config_on_routers,
|
||||
step,
|
||||
create_route_maps,
|
||||
addKernelRoute,
|
||||
kill_router_daemons,
|
||||
start_router_daemons,
|
||||
create_interfaces_cfg,
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
clear_bgp_and_verify,
|
||||
clear_bgp,
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
verify_bgp_rib,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
# Global variables
|
||||
topo = None
|
||||
# Reading the data from JSON File for topology creation
|
||||
jsonFile = "{}/rfc5549_ebgp_nbr.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
NETWORK = {
|
||||
@ -137,21 +116,6 @@ TC32. Verify IPv4 route received with IPv6 nexthop can be advertised to
|
||||
"""
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder.
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function."""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""Set up the pytest environment."""
|
||||
global topo, ADDR_TYPES
|
||||
@ -163,7 +127,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/rfc5549_ebgp_nbr.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
|
@ -25,11 +25,7 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
import ipaddr
|
||||
from copy import deepcopy
|
||||
from re import search as re_search
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -37,12 +33,10 @@ sys.path.append(os.path.join(CWD, "../"))
|
||||
sys.path.append(os.path.join(CWD, "../../"))
|
||||
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
write_test_header,
|
||||
start_topology,
|
||||
create_route_maps,
|
||||
write_test_footer,
|
||||
start_router,
|
||||
stop_router,
|
||||
@ -51,24 +45,15 @@ from lib.common_config import (
|
||||
check_address_types,
|
||||
reset_config_on_routers,
|
||||
step,
|
||||
shutdown_bringup_interface,
|
||||
create_interfaces_cfg,
|
||||
get_frr_ipv6_linklocal,
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import clear_bgp, verify_bgp_convergence, create_router_bgp, verify_bgp_rib
|
||||
from lib.bgp import create_router_bgp, verify_bgp_convergence, verify_bgp_rib
|
||||
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
# Global variables
|
||||
topo = None
|
||||
# Reading the data from JSON File for topology creation
|
||||
jsonFile = "{}/rfc5549_ebgp_unnumbered_nbr.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
NO_OF_RTES = 2
|
||||
@ -124,21 +109,6 @@ shut / no shut of nexthop and BGP peer interfaces
|
||||
"""
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder.
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function."""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""Set up the pytest environment."""
|
||||
global topo, ADDR_TYPES
|
||||
@ -150,7 +120,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/rfc5549_ebgp_unnumbered_nbr.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
|
@ -25,11 +25,8 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
from copy import deepcopy
|
||||
import ipaddr
|
||||
from re import search as re_search
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -39,7 +36,6 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
@ -49,31 +45,21 @@ from lib.common_config import (
|
||||
create_prefix_lists,
|
||||
verify_rib,
|
||||
create_static_routes,
|
||||
check_address_types,
|
||||
reset_config_on_routers,
|
||||
step,
|
||||
create_route_maps,
|
||||
create_interfaces_cfg,
|
||||
get_frr_ipv6_linklocal,
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import (
|
||||
clear_bgp_and_verify,
|
||||
verify_bgp_convergence,
|
||||
create_router_bgp,
|
||||
verify_bgp_rib,
|
||||
)
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
# Global variables
|
||||
topo = None
|
||||
# Reading the data from JSON File for topology creation
|
||||
jsonFile = "{}/rfc5549_ibgp_nbr.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
NETWORK = {
|
||||
@ -121,21 +107,6 @@ TESTCASES = """
|
||||
"""
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder.
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function."""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""Set up the pytest environment."""
|
||||
|
||||
@ -147,7 +118,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/rfc5549_ibgp_nbr.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
|
@ -25,10 +25,7 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
import pytest
|
||||
import ipaddr
|
||||
from re import search as re_search
|
||||
|
||||
# Save the Current Working Directory to find configuration files.
|
||||
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -38,13 +35,11 @@ sys.path.append(os.path.join(CWD, "../../"))
|
||||
# pylint: disable=C0413
|
||||
# Import topogen and topotest helpers
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
write_test_header,
|
||||
write_test_footer,
|
||||
create_interfaces_cfg,
|
||||
verify_rib,
|
||||
create_static_routes,
|
||||
check_address_types,
|
||||
@ -53,18 +48,11 @@ from lib.common_config import (
|
||||
get_frr_ipv6_linklocal,
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import clear_bgp, verify_bgp_convergence, create_router_bgp
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.bgp import create_router_bgp, verify_bgp_convergence
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
# Global variables
|
||||
topo = None
|
||||
# Reading the data from JSON File for topology creation
|
||||
jsonFile = "{}/rfc5549_ibgp_unnumbered_nbr.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
|
||||
# Global variables
|
||||
@ -107,21 +95,6 @@ TESTCASES = """
|
||||
"""
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder.
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function."""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""Set up the pytest environment."""
|
||||
|
||||
@ -133,7 +106,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/rfc5549_ibgp_unnumbered_nbr.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
# to start deamons and then start routers
|
||||
|
@ -43,31 +43,26 @@ 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]
|
||||
|
||||
|
||||
class BGPIPV6RTADVTopo(Topo):
|
||||
"Test topology builder"
|
||||
def build_topo(tgen):
|
||||
"Build function"
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
# Create 2 routers.
|
||||
tgen.add_router("r1")
|
||||
tgen.add_router("r2")
|
||||
|
||||
# Create 2 routers.
|
||||
tgen.add_router("r1")
|
||||
tgen.add_router("r2")
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"Sets up the pytest environment"
|
||||
tgen = Topogen(BGPIPV6RTADVTopo, mod.__name__)
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
@ -74,68 +74,59 @@ 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")
|
||||
# check for mpls
|
||||
if tgen.hasmpls != True:
|
||||
logger.info("MPLS not available, tests will be skipped")
|
||||
return
|
||||
for routern in range(2, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
# Create CE routers
|
||||
for routern in range(1, 4):
|
||||
tgen.add_router("ce{}".format(routern))
|
||||
|
||||
# This function only purpose is to define allocation and relationship
|
||||
# between routers, switches and hosts.
|
||||
#
|
||||
# Create P/PE routers
|
||||
tgen.add_router("r1")
|
||||
# check for mpls
|
||||
if tgen.hasmpls != True:
|
||||
logger.info("MPLS not available, tests will be skipped")
|
||||
return
|
||||
for routern in range(2, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
# Create CE routers
|
||||
for routern in range(1, 4):
|
||||
tgen.add_router("ce{}".format(routern))
|
||||
# CE/PE links
|
||||
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
|
||||
tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
|
||||
tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
|
||||
|
||||
# CE/PE links
|
||||
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
|
||||
tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
|
||||
tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
|
||||
# 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")
|
||||
|
||||
# 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[1] = tgen.add_switch("sw2")
|
||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
||||
switch[1] = tgen.add_switch("sw2")
|
||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
||||
|
||||
|
||||
def ltemplatePreRouterStartHook():
|
||||
@ -146,10 +137,6 @@ def ltemplatePreRouterStartHook():
|
||||
if tgen.hasmpls != True:
|
||||
logger.info("MPLS not available, skipping setup")
|
||||
return False
|
||||
# check for normal init
|
||||
if len(tgen.net) == 1:
|
||||
logger.info("Topology not configured, skipping setup")
|
||||
return False
|
||||
# configure r2 mpls interfaces
|
||||
intfs = ["lo", "r2-eth0", "r2-eth1", "r2-eth2"]
|
||||
for intf in intfs:
|
||||
|
@ -74,75 +74,67 @@ r3-eth1 .3 | | .3 r3-eth0 | .4 r4-eth0
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import pytest
|
||||
import platform
|
||||
|
||||
# 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
|
||||
# check for mpls
|
||||
tgen.add_router("r1")
|
||||
if tgen.hasmpls != True:
|
||||
logger.info("MPLS not available, tests will be skipped")
|
||||
return
|
||||
mach = platform.machine()
|
||||
krel = platform.release()
|
||||
if mach[:1] == "a" and topotest.version_cmp(krel, "4.11") < 0:
|
||||
logger.info("Need Kernel version 4.11 to run on arm processor")
|
||||
return
|
||||
for routern in range(2, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
# Create CE routers
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("ce{}".format(routern))
|
||||
|
||||
# This function only purpose is to define allocation and relationship
|
||||
# between routers, switches and hosts.
|
||||
#
|
||||
# Create P/PE routers
|
||||
# check for mpls
|
||||
tgen.add_router("r1")
|
||||
if tgen.hasmpls != True:
|
||||
logger.info("MPLS not available, tests will be skipped")
|
||||
return
|
||||
mach = platform.machine()
|
||||
krel = platform.release()
|
||||
if mach[:1] == "a" and topotest.version_cmp(krel, "4.11") < 0:
|
||||
logger.info("Need Kernel version 4.11 to run on arm processor")
|
||||
return
|
||||
for routern in range(2, 5):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
# Create CE routers
|
||||
for routern in range(1, 5):
|
||||
tgen.add_router("ce{}".format(routern))
|
||||
# CE/PE links
|
||||
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
|
||||
tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
|
||||
tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
|
||||
tgen.add_link(tgen.gears["ce4"], tgen.gears["r4"], "ce4-eth0", "r4-eth5")
|
||||
|
||||
# CE/PE links
|
||||
tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
|
||||
tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
|
||||
tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
|
||||
tgen.add_link(tgen.gears["ce4"], tgen.gears["r4"], "ce4-eth0", "r4-eth5")
|
||||
# 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")
|
||||
|
||||
# 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[1] = tgen.add_switch("sw2")
|
||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
||||
switch[1] = tgen.add_switch("sw2")
|
||||
switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
|
||||
switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
|
||||
|
||||
|
||||
def ltemplatePreRouterStartHook():
|
||||
@ -155,10 +147,6 @@ def ltemplatePreRouterStartHook():
|
||||
if tgen.hasmpls != True:
|
||||
logger.info("MPLS not available, skipping setup")
|
||||
return False
|
||||
# check for normal init
|
||||
if len(tgen.net) == 1:
|
||||
logger.info("Topology not configured, skipping setup")
|
||||
return False
|
||||
# trace errors/unexpected output
|
||||
cc.resetCounts()
|
||||
# configure r2 mpls interfaces
|
||||
|
@ -1,4 +1,4 @@
|
||||
from lib.lutil import luCommand
|
||||
from lib.lutil import luCommand, luLast
|
||||
|
||||
rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"]
|
||||
for rtr in rtrs:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from lib.lutil import luCommand
|
||||
from lib.lutil import luCommand, luLast
|
||||
|
||||
ret = luCommand(
|
||||
"ce1",
|
||||
|
@ -1,4 +1,4 @@
|
||||
from lib.lutil import luCommand
|
||||
from lib.lutil import luCommand, luLast
|
||||
|
||||
num = 50000
|
||||
b = int(num / (256 * 256))
|
||||
|
@ -93,16 +93,6 @@ def test_check_linux_mpls():
|
||||
ltemplateTest("scripts/check_linux_mpls.py", False, CliOnFail, CheckFunc)
|
||||
|
||||
|
||||
def test_notification_check():
|
||||
CliOnFail = None
|
||||
# For debugging, uncomment the next line
|
||||
# CliOnFail = 'tgen.mininet_cli'
|
||||
CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')"
|
||||
# uncomment next line to start cli *before* script is run
|
||||
# CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
|
||||
ltemplateTest("scripts/notification_check.py", False, CliOnFail, CheckFunc)
|
||||
|
||||
|
||||
def test_check_scale_up():
|
||||
CliOnFail = None
|
||||
# For debugging, uncomment the next line
|
||||
@ -113,16 +103,6 @@ def test_check_scale_up():
|
||||
ltemplateTest("scripts/scale_up.py", False, CliOnFail, CheckFunc)
|
||||
|
||||
|
||||
def test_notification_check():
|
||||
CliOnFail = None
|
||||
# For debugging, uncomment the next line
|
||||
# CliOnFail = 'tgen.mininet_cli'
|
||||
CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')"
|
||||
# uncomment next line to start cli *before* script is run
|
||||
# CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
|
||||
ltemplateTest("scripts/notification_check.py", False, CliOnFail, CheckFunc)
|
||||
|
||||
|
||||
def test_check_scale_down():
|
||||
CliOnFail = None
|
||||
# For debugging, uncomment the next line
|
||||
@ -133,16 +113,6 @@ def test_check_scale_down():
|
||||
ltemplateTest("scripts/scale_down.py", False, CliOnFail, CheckFunc)
|
||||
|
||||
|
||||
def test_notification_check():
|
||||
CliOnFail = None
|
||||
# For debugging, uncomment the next line
|
||||
# CliOnFail = 'tgen.mininet_cli'
|
||||
CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')"
|
||||
# uncomment next line to start cli *before* script is run
|
||||
# CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
|
||||
ltemplateTest("scripts/notification_check.py", False, CliOnFail, CheckFunc)
|
||||
|
||||
|
||||
def SKIP_test_cleanup_all():
|
||||
CliOnFail = None
|
||||
# For debugging, uncomment the next line
|
||||
|
@ -12,7 +12,7 @@
|
||||
"lo_prefix": {
|
||||
"ipv4": "1.0.",
|
||||
"v4mask": 32,
|
||||
"ipv6": "2001:DB8:F::",
|
||||
"ipv6": "2001:db8:f::",
|
||||
"v6mask": 128
|
||||
},
|
||||
"routers": {
|
||||
|
@ -50,11 +50,9 @@ import pytest
|
||||
import time
|
||||
from os import path as os_path
|
||||
import sys
|
||||
from json import load as json_load
|
||||
|
||||
# Required to instantiate the topology builder class.
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
@ -71,7 +69,7 @@ from lib.common_config import (
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
@ -81,13 +79,6 @@ CWD = os_path.dirname(os_path.realpath(__file__))
|
||||
sys.path.append(os_path.join(CWD, "../"))
|
||||
sys.path.append(os_path.join(CWD, "../lib/"))
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/bgp_large_community_topo_1.json".format(CWD)
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json_load(topoJson)
|
||||
except IOError:
|
||||
logger.info("Could not read file:", jsonFile)
|
||||
|
||||
# Global variables
|
||||
bgp_convergence = False
|
||||
@ -124,22 +115,6 @@ STANDARD_COMM = {
|
||||
}
|
||||
|
||||
|
||||
class CreateTopo(Topo):
|
||||
"""
|
||||
Test topology builder
|
||||
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"""Build function"""
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -159,7 +134,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(CreateTopo, mod.__name__)
|
||||
json_file = "{}/bgp_large_community_topo_1.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
|
@ -61,7 +61,6 @@ Following tests are covered:
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import pytest
|
||||
import time
|
||||
|
||||
@ -74,7 +73,6 @@ sys.path.append(os.path.join(CWD, "../lib/"))
|
||||
# Import topogen and topotest helpers
|
||||
# Import topoJson from lib, to create topology and initial configuration
|
||||
from lib.topogen import Topogen, get_topogen
|
||||
from mininet.topo import Topo
|
||||
|
||||
from lib.common_config import (
|
||||
start_topology,
|
||||
@ -83,7 +81,6 @@ from lib.common_config import (
|
||||
reset_config_on_routers,
|
||||
create_route_maps,
|
||||
create_bgp_community_lists,
|
||||
create_prefix_lists,
|
||||
verify_bgp_community,
|
||||
step,
|
||||
verify_create_community_list,
|
||||
@ -95,41 +92,18 @@ from lib.common_config import (
|
||||
)
|
||||
from lib.topolog import logger
|
||||
from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify
|
||||
from lib.topojson import build_topo_from_json, build_config_from_json
|
||||
from lib.topojson import build_config_from_json
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
# Reading the data from JSON File for topology and configuration creation
|
||||
jsonFile = "{}/bgp_large_community_topo_2.json".format(CWD)
|
||||
|
||||
try:
|
||||
with open(jsonFile, "r") as topoJson:
|
||||
topo = json.load(topoJson)
|
||||
except IOError:
|
||||
assert False, "Could not read file {}".format(jsonFile)
|
||||
|
||||
# Global variables
|
||||
bgp_convergence = False
|
||||
|
||||
NETWORKS = {"ipv4": ["200.50.2.0/32"], "ipv6": ["1::1/128"]}
|
||||
|
||||
|
||||
class GenerateTopo(Topo):
|
||||
"""
|
||||
Test topology builder
|
||||
|
||||
* `Topo`: Topology object
|
||||
"""
|
||||
|
||||
def build(self, *_args, **_opts):
|
||||
"Build function"
|
||||
tgen = get_topogen(self)
|
||||
|
||||
# Building topology from json file
|
||||
build_topo_from_json(tgen, topo)
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
"""
|
||||
Sets up the pytest environment
|
||||
@ -149,7 +123,10 @@ def setup_module(mod):
|
||||
logger.info("Running setup_module to create topology")
|
||||
|
||||
# This function initiates the topology build with Topogen...
|
||||
tgen = Topogen(GenerateTopo, mod.__name__)
|
||||
json_file = "{}/bgp_large_community_topo_2.json".format(CWD)
|
||||
tgen = Topogen(json_file, mod.__name__)
|
||||
global topo
|
||||
topo = tgen.json_topo
|
||||
# ... and here it calls Mininet initialization functions.
|
||||
|
||||
# Starting topology, create tmp files which are loaded to routers
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user