From 3aefe207973641c013c0c937eb3e5c792a172729 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Wed, 6 Dec 2017 16:08:20 -0200 Subject: [PATCH] isis-topo1: import topology Signed-off-by: Rafael Zalamena --- tests/topotests/isis-topo1/__init__.py | 0 tests/topotests/isis-topo1/r1/isisd.conf | 10 ++ tests/topotests/isis-topo1/r1/zebra.conf | 7 + tests/topotests/isis-topo1/r2/isisd.conf | 10 ++ tests/topotests/isis-topo1/r2/zebra.conf | 7 + tests/topotests/isis-topo1/r3/isisd.conf | 15 ++ tests/topotests/isis-topo1/r3/zebra.conf | 10 ++ tests/topotests/isis-topo1/r4/isisd.conf | 15 ++ tests/topotests/isis-topo1/r4/zebra.conf | 10 ++ tests/topotests/isis-topo1/r5/isisd.conf | 15 ++ tests/topotests/isis-topo1/r5/zebra.conf | 10 ++ tests/topotests/isis-topo1/test_isis_topo1.py | 131 ++++++++++++++++++ 12 files changed, 240 insertions(+) create mode 100644 tests/topotests/isis-topo1/__init__.py create mode 100644 tests/topotests/isis-topo1/r1/isisd.conf create mode 100644 tests/topotests/isis-topo1/r1/zebra.conf create mode 100644 tests/topotests/isis-topo1/r2/isisd.conf create mode 100644 tests/topotests/isis-topo1/r2/zebra.conf create mode 100644 tests/topotests/isis-topo1/r3/isisd.conf create mode 100644 tests/topotests/isis-topo1/r3/zebra.conf create mode 100644 tests/topotests/isis-topo1/r4/isisd.conf create mode 100644 tests/topotests/isis-topo1/r4/zebra.conf create mode 100644 tests/topotests/isis-topo1/r5/isisd.conf create mode 100644 tests/topotests/isis-topo1/r5/zebra.conf create mode 100644 tests/topotests/isis-topo1/test_isis_topo1.py diff --git a/tests/topotests/isis-topo1/__init__.py b/tests/topotests/isis-topo1/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/topotests/isis-topo1/r1/isisd.conf b/tests/topotests/isis-topo1/r1/isisd.conf new file mode 100644 index 0000000000..00e9211740 --- /dev/null +++ b/tests/topotests/isis-topo1/r1/isisd.conf @@ -0,0 +1,10 @@ +hostname r1 +interface r1-eth0 + ip router isis 1 + isis circuit-type level-2-only +! +router isis 1 + net 10.0000.0000.0000.0000.0000.0000.0000.0000.0000.00 + metric-style wide + redistribute ipv4 connected level-2 +! diff --git a/tests/topotests/isis-topo1/r1/zebra.conf b/tests/topotests/isis-topo1/r1/zebra.conf new file mode 100644 index 0000000000..57ee2ef0d0 --- /dev/null +++ b/tests/topotests/isis-topo1/r1/zebra.conf @@ -0,0 +1,7 @@ +hostname r1 +interface r1-eth0 + ip address 10.0.20.2/24 +! +interface lo + ip address 10.254.0.1/32 +! diff --git a/tests/topotests/isis-topo1/r2/isisd.conf b/tests/topotests/isis-topo1/r2/isisd.conf new file mode 100644 index 0000000000..6ddd15a105 --- /dev/null +++ b/tests/topotests/isis-topo1/r2/isisd.conf @@ -0,0 +1,10 @@ +hostname r2 +interface r2-eth0 + ip router isis 1 + isis circuit-type level-2-only +! +router isis 1 + net 10.0000.0000.0000.0000.0000.0000.0000.0000.0001.00 + metric-style wide + redistribute ipv4 connected level-2 +! diff --git a/tests/topotests/isis-topo1/r2/zebra.conf b/tests/topotests/isis-topo1/r2/zebra.conf new file mode 100644 index 0000000000..3e58360c51 --- /dev/null +++ b/tests/topotests/isis-topo1/r2/zebra.conf @@ -0,0 +1,7 @@ +hostname r2 +interface r2-eth0 + ip address 10.0.21.2/24 +! +interface lo + ip address 10.254.0.2/32 +! diff --git a/tests/topotests/isis-topo1/r3/isisd.conf b/tests/topotests/isis-topo1/r3/isisd.conf new file mode 100644 index 0000000000..08fc51def0 --- /dev/null +++ b/tests/topotests/isis-topo1/r3/isisd.conf @@ -0,0 +1,15 @@ +hostname r3 +interface r3-eth0 + ip router isis 1 + isis circuit-type level-2-only +! +interface r3-eth1 + ip router isis 1 + isis circuit-type level-1 +! +router isis 1 + net 10.0000.0000.0000.0000.0000.0000.0000.0000.0002.00 + metric-style wide + redistribute ipv4 connected level-1 + redistribute ipv4 connected level-2 +! diff --git a/tests/topotests/isis-topo1/r3/zebra.conf b/tests/topotests/isis-topo1/r3/zebra.conf new file mode 100644 index 0000000000..603488e90c --- /dev/null +++ b/tests/topotests/isis-topo1/r3/zebra.conf @@ -0,0 +1,10 @@ +hostname r3 +interface r3-eth0 + ip address 10.0.20.1/24 +! +interface r3-eth1 + ip address 10.0.10.2/24 +! +interface lo + ip address 10.254.0.3/32 +! diff --git a/tests/topotests/isis-topo1/r4/isisd.conf b/tests/topotests/isis-topo1/r4/isisd.conf new file mode 100644 index 0000000000..7b561449b3 --- /dev/null +++ b/tests/topotests/isis-topo1/r4/isisd.conf @@ -0,0 +1,15 @@ +hostname r4 +interface r4-eth0 + ip router isis 1 + isis circuit-type level-2-only +! +interface r4-eth1 + ip router isis 1 + isis circuit-type level-1 +! +router isis 1 + net 10.0000.0000.0000.0000.0000.0000.0000.0000.0004.00 + metric-style wide + redistribute ipv4 connected level-1 + redistribute ipv4 connected level-2 +! diff --git a/tests/topotests/isis-topo1/r4/zebra.conf b/tests/topotests/isis-topo1/r4/zebra.conf new file mode 100644 index 0000000000..9aa9786220 --- /dev/null +++ b/tests/topotests/isis-topo1/r4/zebra.conf @@ -0,0 +1,10 @@ +hostname r4 +interface r4-eth0 + ip address 10.0.21.1/24 +! +interface r4-eth1 + ip address 10.0.11.2/24 +! +interface lo + ip address 10.254.0.4/32 +! diff --git a/tests/topotests/isis-topo1/r5/isisd.conf b/tests/topotests/isis-topo1/r5/isisd.conf new file mode 100644 index 0000000000..4bd0c0b6af --- /dev/null +++ b/tests/topotests/isis-topo1/r5/isisd.conf @@ -0,0 +1,15 @@ +hostname r5 +interface r5-eth0 + ip router isis 1 + isis circuit-type level-1 +! +interface r5-eth1 + ip router isis 1 + isis circuit-type level-1 +! +router isis 1 + net 10.0000.0000.0000.0000.0000.0000.0000.0000.0005.00 + metric-style wide + is-type level-1 + redistribute ipv4 connected level-1 +! diff --git a/tests/topotests/isis-topo1/r5/zebra.conf b/tests/topotests/isis-topo1/r5/zebra.conf new file mode 100644 index 0000000000..0992da78df --- /dev/null +++ b/tests/topotests/isis-topo1/r5/zebra.conf @@ -0,0 +1,10 @@ +hostname r5 +interface r5-eth0 + ip address 10.0.10.1/24 +! +interface r5-eth1 + ip address 10.0.11.1/24 +! +interface lo + ip address 10.254.0.5/32 +! diff --git a/tests/topotests/isis-topo1/test_isis_topo1.py b/tests/topotests/isis-topo1/test_isis_topo1.py new file mode 100644 index 0000000000..38308510df --- /dev/null +++ b/tests/topotests/isis-topo1/test_isis_topo1.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python + +# +# test_isis_topo1.py +# Part of NetDEF Topology Tests +# +# Copyright (c) 2017 by +# Network Device Education Foundation, Inc. ("NetDEF") +# +# Permission to use, copy, modify, and/or distribute this software +# for any purpose with or without fee is hereby granted, provided +# that the above copyright notice and this permission notice appear +# in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. +# + +""" +test_isis_topo1.py: Test ISIS topology. +""" + +import os +import sys +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 + + +class ISISTopo1(Topo): + "Simple two layer ISIS topology" + def build(self, *_args, **_opts): + "Build function" + tgen = get_topogen(self) + + # Add ISIS routers: + # r1 r2 + # | sw1 | sw2 + # r3 r4 + # | | + # sw3 sw4 + # \ / + # r5 + for routern in range(1, 6): + tgen.add_router('r{}'.format(routern)) + + # r1 <- sw1 -> r3 + sw = tgen.add_switch('sw1') + sw.add_link(tgen.gears['r1']) + sw.add_link(tgen.gears['r3']) + + # r2 <- sw2 -> r4 + sw = tgen.add_switch('sw2') + sw.add_link(tgen.gears['r2']) + sw.add_link(tgen.gears['r4']) + + # r3 <- sw3 -> r5 + sw = tgen.add_switch('sw3') + sw.add_link(tgen.gears['r3']) + sw.add_link(tgen.gears['r5']) + + # r4 <- sw4 -> r5 + sw = tgen.add_switch('sw4') + sw.add_link(tgen.gears['r4']) + sw.add_link(tgen.gears['r5']) + + +def setup_module(mod): + "Sets up the pytest environment" + tgen = Topogen(ISISTopo1, mod.__name__) + tgen.start_topology() + + # For all registered routers, load the zebra configuration file + for rname, router in tgen.routers().iteritems(): + router.load_config( + TopoRouter.RD_ZEBRA, + os.path.join(CWD, '{}/zebra.conf'.format(rname)) + ) + router.load_config( + TopoRouter.RD_ISIS, + os.path.join(CWD, '{}/isisd.conf'.format(rname)) + ) + + # After loading the configurations, this function loads configured daemons. + tgen.start_router() + + +def teardown_module(mod): + "Teardown the pytest environment" + tgen = get_topogen() + + # This function tears down the whole topology. + tgen.stop_topology() + + +def test_isis_convergence(): + "Wait for the protocol to converge before starting to test" + tgen = get_topogen() + # Don't run this test if we have any failure. + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + topotest.sleep(10, "waiting for ISIS protocol to converge") + + +def test_memory_leak(): + "Run the memory leak test and report results." + tgen = get_topogen() + if not tgen.is_memleak_enabled(): + pytest.skip('Memory leak test/report is disabled') + + tgen.report_memory_leaks() + + +if __name__ == '__main__': + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) -- 2.39.5