summaryrefslogtreecommitdiffstats
path: root/tests/topotests/bgp_ipv6_rtadv
diff options
context:
space:
mode:
authorreformat <reformat@nobody.nobody>2020-04-03 13:05:24 +0200
committerDonatas Abraitis <donatas.abraitis@gmail.com>2020-04-03 18:41:28 +0200
commit787e762445d50ca5b52fafcf8dd6de08ab90916f (patch)
treeafaad3d41a83da180d5fc8bbc7b23d02da7c4dbd /tests/topotests/bgp_ipv6_rtadv
parentMerge pull request #6071 from ton31337/feature/rfc6286 (diff)
downloadfrr-787e762445d50ca5b52fafcf8dd6de08ab90916f.tar.xz
frr-787e762445d50ca5b52fafcf8dd6de08ab90916f.zip
tests: Run python formatter (black) for topotests
Mostly ' => ", whitespace changes. Using https://github.com/psf/black Signed-off-by: reformat <reformat@nobody.nobody>
Diffstat (limited to 'tests/topotests/bgp_ipv6_rtadv')
-rw-r--r--tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py56
1 files changed, 32 insertions, 24 deletions
diff --git a/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py b/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py
index 6cf223af4..10b2f3595 100644
--- a/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py
+++ b/tests/topotests/bgp_ipv6_rtadv/test_bgp_ipv6_rtadv.py
@@ -34,7 +34,7 @@ import pytest
# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.join(CWD, '../'))
+sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
@@ -48,17 +48,19 @@ from mininet.topo import Topo
class BGPIPV6RTADVTopo(Topo):
"Test topology builder"
+
def build(self, *_args, **_opts):
"Build function"
tgen = get_topogen(self)
# Create 2 routers.
- 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'])
def setup_module(mod):
"Sets up the pytest environment"
@@ -69,17 +71,16 @@ def setup_module(mod):
for rname, router in router_list.iteritems():
router.load_config(
- TopoRouter.RD_ZEBRA,
- os.path.join(CWD, '{}/zebra.conf'.format(rname))
+ TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
)
router.load_config(
- TopoRouter.RD_BGP,
- os.path.join(CWD, '{}/bgpd.conf'.format(rname))
+ TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
)
# Initialize all routers.
tgen.start_router()
+
def teardown_module(_mod):
"Teardown the pytest environment"
tgen = get_topogen()
@@ -99,44 +100,51 @@ def test_protocols_convergence():
# Check IPv4 routing tables.
logger.info("Checking IPv4 routes for convergence")
for router in tgen.routers().values():
- json_file = '{}/{}/ipv4_routes.json'.format(CWD, router.name)
+ json_file = "{}/{}/ipv4_routes.json".format(CWD, router.name)
if not os.path.isfile(json_file):
- logger.info('skipping file {}'.format(json_file))
+ logger.info("skipping file {}".format(json_file))
continue
expected = json.loads(open(json_file).read())
- test_func = partial(topotest.router_json_cmp,
- router, 'show ip route json'.format(router.name), expected)
- _, result = topotest.run_and_expect(test_func, None, count=160,
- wait=0.5)
+ test_func = partial(
+ topotest.router_json_cmp,
+ router,
+ "show ip route json".format(router.name),
+ expected,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=160, wait=0.5)
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg
# Check IPv6 routing tables.
logger.info("Checking IPv6 routes for convergence")
for router in tgen.routers().values():
- json_file = '{}/{}/ipv6_routes.json'.format(CWD, router.name)
+ json_file = "{}/{}/ipv6_routes.json".format(CWD, router.name)
if not os.path.isfile(json_file):
- logger.info('skipping file {}'.format(json_file))
+ logger.info("skipping file {}".format(json_file))
continue
expected = json.loads(open(json_file).read())
- test_func = partial(topotest.router_json_cmp,
- router, 'show ipv6 route json'.format(router.name), expected)
- _, result = topotest.run_and_expect(test_func, None, count=160,
- wait=0.5)
+ test_func = partial(
+ topotest.router_json_cmp,
+ router,
+ "show ipv6 route json".format(router.name),
+ expected,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=160, wait=0.5)
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg
+
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')
+ pytest.skip("Memory leak test/report is disabled")
tgen.report_memory_leaks()
-if __name__ == '__main__':
+if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))