#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
#
# test_bfd_topo1.py
# Copyright (c) 2018 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_bfd_topo1.py: Test the FRR BFD daemon.
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()
test_func = partial(
topotest.router_json_cmp, router, "show bfd peers json", expected
)
- _, result = topotest.run_and_expect(test_func, None, count=8, wait=0.5)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg
test_func = partial(
topotest.router_json_cmp, router, "show ip bgp json", expected
)
- _, res = topotest.run_and_expect(test_func, None, count=3, wait=1)
+ _, res = topotest.run_and_expect(test_func, None, count=5, wait=1)
assertmsg = "{}: bgp did not converge".format(router.name)
assert res is None, assertmsg