mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 03:28:31 +00:00
Merge pull request #8295 from opensourcerouting/ospf6-topo-stabilize
topotest: stabilize OSPFv3 topology
This commit is contained in:
commit
1832ff8b49
@ -1,9 +0,0 @@
|
|||||||
!
|
|
||||||
router ospf6
|
|
||||||
router-id 10.0.255.1
|
|
||||||
redistribute kernel
|
|
||||||
redistribute connected
|
|
||||||
redistribute static
|
|
||||||
interface r1-eth0 area 0.0.0.0
|
|
||||||
interface r1-eth1 area 0.0.0.0
|
|
||||||
!
|
|
@ -1,9 +0,0 @@
|
|||||||
!
|
|
||||||
router ospf6
|
|
||||||
router-id 10.0.255.2
|
|
||||||
redistribute kernel
|
|
||||||
redistribute connected
|
|
||||||
redistribute static
|
|
||||||
interface r2-eth0 area 0.0.0.0
|
|
||||||
interface r2-eth1 area 0.0.0.0
|
|
||||||
!
|
|
@ -1,10 +0,0 @@
|
|||||||
!
|
|
||||||
router ospf6
|
|
||||||
router-id 10.0.255.3
|
|
||||||
redistribute kernel
|
|
||||||
redistribute connected
|
|
||||||
redistribute static
|
|
||||||
interface r3-eth0 area 0.0.0.0
|
|
||||||
interface r3-eth1 area 0.0.0.0
|
|
||||||
interface r3-eth2 area 0.0.0.1
|
|
||||||
!
|
|
@ -1,9 +0,0 @@
|
|||||||
!
|
|
||||||
router ospf6
|
|
||||||
router-id 10.0.255.4
|
|
||||||
redistribute kernel
|
|
||||||
redistribute connected
|
|
||||||
redistribute static
|
|
||||||
interface r4-eth0 area 0.0.0.1
|
|
||||||
interface r4-eth1 area 0.0.0.1
|
|
||||||
!
|
|
@ -93,8 +93,6 @@ def setup_module(mod):
|
|||||||
tgen.start_topology()
|
tgen.start_topology()
|
||||||
|
|
||||||
ospf6_config = "ospf6d.conf"
|
ospf6_config = "ospf6d.conf"
|
||||||
if tgen.gears["r1"].has_version("<", "4.0"):
|
|
||||||
ospf6_config = "ospf6d.conf-pre-v4"
|
|
||||||
|
|
||||||
router_list = tgen.routers()
|
router_list = tgen.routers()
|
||||||
for rname, router in router_list.items():
|
for rname, router in router_list.items():
|
||||||
@ -118,6 +116,78 @@ def teardown_module(mod):
|
|||||||
tgen.stop_topology()
|
tgen.stop_topology()
|
||||||
|
|
||||||
|
|
||||||
|
def test_wait_protocol_convergence():
|
||||||
|
"Wait for OSPFv2/OSPFv3 to converge"
|
||||||
|
tgen = get_topogen()
|
||||||
|
if tgen.routers_have_failure():
|
||||||
|
pytest.skip(tgen.errors)
|
||||||
|
|
||||||
|
logger.info("waiting for protocols to converge")
|
||||||
|
|
||||||
|
def expect_ospfv2_neighbor_full(router, neighbor):
|
||||||
|
"Wait until OSPFv2 convergence."
|
||||||
|
logger.info("waiting OSPFv2 router '{}'".format(router))
|
||||||
|
|
||||||
|
def run_command_and_expect():
|
||||||
|
"""
|
||||||
|
Function that runs command and expect the following outcomes:
|
||||||
|
* Full/DR
|
||||||
|
* Full/DROther
|
||||||
|
* Full/Backup
|
||||||
|
"""
|
||||||
|
result = tgen.gears[router].vtysh_cmd('show ip ospf neighbor json',
|
||||||
|
isjson=True)
|
||||||
|
if topotest.json_cmp(result, {"neighbors": {neighbor: [
|
||||||
|
{"state": "Full/DR"}]}}) is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if topotest.json_cmp(result, {"neighbors": {neighbor: [
|
||||||
|
{"state": "Full/DROther"}]}}) is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return topotest.json_cmp(result, {"neighbors": {neighbor: [
|
||||||
|
{"state": "Full/Backup"}]}})
|
||||||
|
|
||||||
|
_, result = topotest.run_and_expect(run_command_and_expect, None,
|
||||||
|
count=130, wait=1)
|
||||||
|
assertmsg = '"{}" convergence failure'.format(router)
|
||||||
|
assert result is None, assertmsg
|
||||||
|
|
||||||
|
|
||||||
|
def expect_ospfv3_neighbor_full(router, neighbor):
|
||||||
|
"Wait until OSPFv3 convergence."
|
||||||
|
logger.info("waiting OSPFv3 router '{}'".format(router))
|
||||||
|
test_func = partial(
|
||||||
|
topotest.router_json_cmp,
|
||||||
|
tgen.gears[router],
|
||||||
|
"show ipv6 ospf6 neighbor json",
|
||||||
|
{"neighbors": [{"neighborId": neighbor, "state": "Full"}]},
|
||||||
|
)
|
||||||
|
_, result = topotest.run_and_expect(test_func, None, count=130, wait=1)
|
||||||
|
assertmsg = '"{}" convergence failure'.format(router)
|
||||||
|
assert result is None, assertmsg
|
||||||
|
|
||||||
|
# Wait for OSPFv2 convergence
|
||||||
|
expect_ospfv2_neighbor_full("r1", "10.0.255.2")
|
||||||
|
expect_ospfv2_neighbor_full("r1", "10.0.255.3")
|
||||||
|
expect_ospfv2_neighbor_full("r2", "10.0.255.1")
|
||||||
|
expect_ospfv2_neighbor_full("r2", "10.0.255.3")
|
||||||
|
expect_ospfv2_neighbor_full("r3", "10.0.255.1")
|
||||||
|
expect_ospfv2_neighbor_full("r3", "10.0.255.2")
|
||||||
|
expect_ospfv2_neighbor_full("r3", "10.0.255.4")
|
||||||
|
expect_ospfv2_neighbor_full("r4", "10.0.255.3")
|
||||||
|
|
||||||
|
# Wait for OSPFv3 convergence
|
||||||
|
expect_ospfv3_neighbor_full("r1", "10.0.255.2")
|
||||||
|
expect_ospfv3_neighbor_full("r1", "10.0.255.3")
|
||||||
|
expect_ospfv3_neighbor_full("r2", "10.0.255.1")
|
||||||
|
expect_ospfv3_neighbor_full("r2", "10.0.255.3")
|
||||||
|
expect_ospfv3_neighbor_full("r3", "10.0.255.1")
|
||||||
|
expect_ospfv3_neighbor_full("r3", "10.0.255.2")
|
||||||
|
expect_ospfv3_neighbor_full("r3", "10.0.255.4")
|
||||||
|
expect_ospfv3_neighbor_full("r4", "10.0.255.3")
|
||||||
|
|
||||||
|
|
||||||
def compare_show_ipv6_ospf6(rname, expected):
|
def compare_show_ipv6_ospf6(rname, expected):
|
||||||
"""
|
"""
|
||||||
Calls 'show ipv6 ospf6 route' for router `rname` and compare the obtained
|
Calls 'show ipv6 ospf6 route' for router `rname` and compare the obtained
|
||||||
|
@ -11,9 +11,13 @@ debug ospf6 flooding
|
|||||||
!
|
!
|
||||||
interface r1-stubnet
|
interface r1-stubnet
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
interface r1-sw5
|
interface r1-sw5
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
router ospf6
|
router ospf6
|
||||||
ospf6 router-id 10.0.0.1
|
ospf6 router-id 10.0.0.1
|
||||||
|
@ -11,9 +11,13 @@ debug ospf6 flooding
|
|||||||
!
|
!
|
||||||
interface r2-stubnet
|
interface r2-stubnet
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
interface r2-sw5
|
interface r2-sw5
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
router ospf6
|
router ospf6
|
||||||
ospf6 router-id 10.0.0.2
|
ospf6 router-id 10.0.0.2
|
||||||
|
@ -11,12 +11,18 @@ debug ospf6 flooding
|
|||||||
!
|
!
|
||||||
interface r3-stubnet
|
interface r3-stubnet
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
interface r3-sw5
|
interface r3-sw5
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
interface r3-sw6
|
interface r3-sw6
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
router ospf6
|
router ospf6
|
||||||
ospf6 router-id 10.0.0.3
|
ospf6 router-id 10.0.0.3
|
||||||
|
@ -11,9 +11,13 @@ debug ospf6 flooding
|
|||||||
!
|
!
|
||||||
interface r4-stubnet
|
interface r4-stubnet
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
interface r4-sw6
|
interface r4-sw6
|
||||||
ipv6 ospf6 network broadcast
|
ipv6 ospf6 network broadcast
|
||||||
|
ipv6 ospf6 hello-interval 2
|
||||||
|
ipv6 ospf6 dead-interval 10
|
||||||
!
|
!
|
||||||
router ospf6
|
router ospf6
|
||||||
ospf6 router-id 10.0.0.4
|
ospf6 router-id 10.0.0.4
|
||||||
|
@ -185,70 +185,38 @@ def teardown_module(mod):
|
|||||||
tgen.stop_topology()
|
tgen.stop_topology()
|
||||||
|
|
||||||
|
|
||||||
def test_ospf6_converged():
|
def test_wait_protocol_convergence():
|
||||||
|
"Wait for OSPFv3 to converge"
|
||||||
tgen = get_topogen()
|
tgen = get_topogen()
|
||||||
|
|
||||||
# Don't run this test if we have any failure.
|
|
||||||
if tgen.routers_have_failure():
|
if tgen.routers_have_failure():
|
||||||
pytest.skip(tgen.errors)
|
pytest.skip(tgen.errors)
|
||||||
|
|
||||||
# For debugging, uncomment the next line
|
logger.info("waiting for protocols to converge")
|
||||||
# tgen.mininet_cli()
|
|
||||||
|
|
||||||
# Wait for OSPF6 to converge (All Neighbors in either Full or TwoWay State)
|
def expect_neighbor_full(router, neighbor):
|
||||||
logger.info("Waiting for OSPF6 convergence")
|
"Wait until OSPFv3 convergence."
|
||||||
|
logger.info("waiting OSPFv3 router '{}'".format(router))
|
||||||
|
test_func = partial(
|
||||||
|
topotest.router_json_cmp,
|
||||||
|
tgen.gears[router],
|
||||||
|
"show ipv6 ospf6 neighbor json",
|
||||||
|
{"neighbors": [{"neighborId": neighbor, "state": "Full"}]},
|
||||||
|
)
|
||||||
|
_, result = topotest.run_and_expect(test_func, None, count=130, wait=1)
|
||||||
|
assertmsg = '"{}" convergence failure'.format(router)
|
||||||
|
assert result is None, assertmsg
|
||||||
|
|
||||||
# Set up for regex
|
expect_neighbor_full("r1", "10.0.0.2")
|
||||||
pat1 = re.compile("^[0-9]")
|
expect_neighbor_full("r1", "10.0.0.3")
|
||||||
pat2 = re.compile("Full")
|
|
||||||
|
|
||||||
timeout = 60
|
expect_neighbor_full("r2", "10.0.0.1")
|
||||||
while timeout > 0:
|
expect_neighbor_full("r2", "10.0.0.3")
|
||||||
logger.info("Timeout in %s: " % timeout),
|
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
# Look for any node not yet converged
|
expect_neighbor_full("r3", "10.0.0.1")
|
||||||
for router, rnode in tgen.routers().items():
|
expect_neighbor_full("r3", "10.0.0.2")
|
||||||
resStr = rnode.vtysh_cmd("show ipv6 ospf neigh")
|
expect_neighbor_full("r3", "10.0.0.4")
|
||||||
|
|
||||||
isConverged = False
|
expect_neighbor_full("r4", "10.0.0.3")
|
||||||
|
|
||||||
for line in resStr.splitlines():
|
|
||||||
res1 = pat1.match(line)
|
|
||||||
if res1:
|
|
||||||
isConverged = True
|
|
||||||
res2 = pat2.search(line)
|
|
||||||
|
|
||||||
if res2 == None:
|
|
||||||
isConverged = False
|
|
||||||
break
|
|
||||||
|
|
||||||
if isConverged == False:
|
|
||||||
logger.info("Waiting for {}".format(router))
|
|
||||||
sys.stdout.flush()
|
|
||||||
break
|
|
||||||
|
|
||||||
if isConverged:
|
|
||||||
logger.info("Done")
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
sleep(5)
|
|
||||||
timeout -= 5
|
|
||||||
|
|
||||||
if timeout == 0:
|
|
||||||
# Bail out with error if a router fails to converge
|
|
||||||
ospfStatus = rnode.vtysh_cmd("show ipv6 ospf neigh")
|
|
||||||
assert False, "OSPFv6 did not converge:\n{}".format(ospfStatus)
|
|
||||||
|
|
||||||
logger.info("OSPFv3 converged.")
|
|
||||||
|
|
||||||
# For debugging, uncomment the next line
|
|
||||||
# tgen.mininet_cli()
|
|
||||||
|
|
||||||
# Make sure that all daemons are still running
|
|
||||||
if tgen.routers_have_failure():
|
|
||||||
assert tgen.errors == "", tgen.errors
|
|
||||||
|
|
||||||
|
|
||||||
def compare_show_ipv6(rname, expected):
|
def compare_show_ipv6(rname, expected):
|
||||||
|
Loading…
Reference in New Issue
Block a user