tests: Modify topotests to include write-multiplier config

Modify both the default and vrf ospf6 topologies to include a test
where write-multiplier is configured to a non-default value and
the ospf6 neighbors are reset then checked.
Run black on both test files.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
This commit is contained in:
Pat Ruddy 2021-05-25 10:39:03 +01:00
parent 44db98df2a
commit d01673b4cd
2 changed files with 71 additions and 11 deletions

View File

@ -360,6 +360,36 @@ def test_linux_ipv6_kernel_routingTable():
) )
def test_ospfv3_routingTable_write_multiplier():
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
# For debugging, uncomment the next line
# tgen.mininet_cli()
# Modify R1 write muliplier and reset the interfaces
r1 = tgen.gears["r1"]
r1.vtysh_cmd("conf t\nrouter ospf6\n write-multiplier 100")
r1.vtysh_cmd("clear ipv6 ospf interface r1-stubnet")
r1.vtysh_cmd("clear ipv6 ospf interface r1-sw5")
# Verify OSPFv3 Routing Table
for router, rnode in tgen.routers().items():
logger.info('Waiting for router "%s" convergence', router)
# Load expected results from the command
reffile = os.path.join(CWD, "{}/show_ipv6_route.ref".format(router))
expected = open(reffile).read()
# Run test function until we get an result. Wait at most 60 seconds.
test_func = partial(compare_show_ipv6, router, expected)
result, diff = topotest.run_and_expect(test_func, "", count=120, wait=0.5)
assert result, "OSPFv3 did not converge on {}:\n{}".format(router, diff)
def test_shutdown_check_stderr(): def test_shutdown_check_stderr():
tgen = get_topogen() tgen = get_topogen()

View File

@ -5,7 +5,7 @@
# Part of NetDEF Topology Tests # Part of NetDEF Topology Tests
# #
# Copyright (c) 2021 by Niral Networks, Inc. ("Niral Networks") # Copyright (c) 2021 by Niral Networks, Inc. ("Niral Networks")
# Used Copyright (c) 2016 by Network Device Education Foundation, # Used Copyright (c) 2016 by Network Device Education Foundation,
# Inc. ("NetDEF") in this file. # Inc. ("NetDEF") in this file.
# #
# Permission to use, copy, modify, and/or distribute this software # Permission to use, copy, modify, and/or distribute this software
@ -179,13 +179,9 @@ def setup_module(mod):
"ip link set {0}-stubnet master {0}-cust1", "ip link set {0}-stubnet master {0}-cust1",
] ]
cmds1 = [ cmds1 = ["ip link set {0}-sw5 master {0}-cust1"]
"ip link set {0}-sw5 master {0}-cust1",
]
cmds2 = [ cmds2 = ["ip link set {0}-sw6 master {0}-cust1"]
"ip link set {0}-sw6 master {0}-cust1",
]
# For all registered routers, load the zebra configuration file # For all registered routers, load the zebra configuration file
for rname, router in tgen.routers().items(): for rname, router in tgen.routers().items():
@ -219,6 +215,7 @@ def teardown_module(mod):
tgen = get_topogen() tgen = get_topogen()
tgen.stop_topology() tgen.stop_topology()
def test_wait_protocol_convergence(): def test_wait_protocol_convergence():
"Wait for OSPFv3 to converge" "Wait for OSPFv3 to converge"
tgen = get_topogen() tgen = get_topogen()
@ -261,7 +258,7 @@ def compare_show_ipv6_vrf(rname, expected):
# Use the vtysh output, with some masking to make comparison easy # Use the vtysh output, with some masking to make comparison easy
vrf_name = "{0}-cust1".format(rname) vrf_name = "{0}-cust1".format(rname)
current = topotest.ip6_route_zebra(tgen.gears[rname], vrf_name) current = topotest.ip6_route_zebra(tgen.gears[rname], vrf_name)
# Use just the 'O'spf lines of the output # Use just the 'O'spf lines of the output
linearr = [] linearr = []
for line in current.splitlines(): for line in current.splitlines():
@ -331,7 +328,11 @@ def test_linux_ipv6_kernel_routingTable():
for i in range(1, 5): for i in range(1, 5):
# Actual output from router # Actual output from router
actual = tgen.gears["r{}".format(i)].run("ip -6 route show vrf r{}-cust1".format(i)).rstrip() actual = (
tgen.gears["r{}".format(i)]
.run("ip -6 route show vrf r{}-cust1".format(i))
.rstrip()
)
if "nhid" in actual: if "nhid" in actual:
refTableFile = os.path.join(CWD, "r{}/ip_6_address.nhg.ref".format(i)) refTableFile = os.path.join(CWD, "r{}/ip_6_address.nhg.ref".format(i))
else: else:
@ -362,9 +363,9 @@ def test_linux_ipv6_kernel_routingTable():
"unreachable fe80::/64 " "unreachable fe80::/64 "
): ):
continue continue
if 'anycast' in line: if "anycast" in line:
continue continue
if 'multicast' in line: if "multicast" in line:
continue continue
filtered_lines.append(line) filtered_lines.append(line)
actual = "\n".join(filtered_lines).splitlines(1) actual = "\n".join(filtered_lines).splitlines(1)
@ -398,6 +399,35 @@ def test_linux_ipv6_kernel_routingTable():
) )
def test_ospfv3_routingTable_write_multiplier():
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
# For debugging, uncomment the next line
# tgen.mininet_cli()
# Modify R1 write muliplier and reset the interfaces
r1 = tgen.gears["r1"]
r1.vtysh_cmd("conf t\nrouter ospf6 vrf r1-cust1 \n write-multiplier 100")
r1.vtysh_cmd("clear ipv6 ospf interface r1-stubnet")
r1.vtysh_cmd("clear ipv6 ospf interface r1-sw5")
# Verify OSPFv3 Routing Table
for router, rnode in tgen.routers().iteritems():
logger.info('Waiting for router "%s" convergence', router)
# Load expected results from the command
reffile = os.path.join(CWD, "{}/show_ipv6_vrf_route.ref".format(router))
expected = open(reffile).read()
# Run test function until we get an result. Wait at most 60 seconds.
test_func = partial(compare_show_ipv6_vrf, router, expected)
result, diff = topotest.run_and_expect(test_func, "", count=120, wait=0.5)
assert result, "OSPFv3 did not converge on {}:\n{}".format(router, diff)
def test_shutdown_check_stderr(): def test_shutdown_check_stderr():
tgen = get_topogen() tgen = get_topogen()