mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-04 11:33:48 +00:00
tests: Use run_and_expect() for ripng_topo1
Avoid checking once and failing immediately. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
parent
3349754a80
commit
717f180a49
@ -19,7 +19,7 @@ import re
|
||||
import sys
|
||||
import pytest
|
||||
from time import sleep
|
||||
|
||||
import functools
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from lib import topotest
|
||||
@ -273,6 +273,27 @@ def test_zebra_ipv6_routingTable():
|
||||
global fatal_error
|
||||
net = get_topogen().net
|
||||
|
||||
def _verify_ip_route(expected):
|
||||
# Actual output from router
|
||||
actual = (
|
||||
net["r%s" % i]
|
||||
.cmd('vtysh -c "show ipv6 route" 2> /dev/null | grep "^R"')
|
||||
.rstrip()
|
||||
)
|
||||
# Mask out Link-Local mac address portion. They are random...
|
||||
actual = re.sub(r" fe80::[0-9a-f:]+", " fe80::XXXX:XXXX:XXXX:XXXX", actual)
|
||||
# Drop timers on end of line
|
||||
actual = re.sub(r", [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", "", actual)
|
||||
# Fix newlines (make them all the same)
|
||||
actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
return topotest.get_textdiff(
|
||||
actual,
|
||||
expected,
|
||||
title1="actual Zebra IPv6 routing table",
|
||||
title2="expected Zebra IPv6 routing table",
|
||||
)
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
pytest.skip(fatal_error)
|
||||
@ -291,42 +312,9 @@ def test_zebra_ipv6_routingTable():
|
||||
# Fix newlines (make them all the same)
|
||||
expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
# Actual output from router
|
||||
actual = (
|
||||
net["r%s" % i]
|
||||
.cmd('vtysh -c "show ipv6 route" 2> /dev/null | grep "^R"')
|
||||
.rstrip()
|
||||
)
|
||||
# Mask out Link-Local mac address portion. They are random...
|
||||
actual = re.sub(r" fe80::[0-9a-f:]+", " fe80::XXXX:XXXX:XXXX:XXXX", actual)
|
||||
# Drop timers on end of line
|
||||
actual = re.sub(r", [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", "", actual)
|
||||
# Fix newlines (make them all the same)
|
||||
actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
# Generate Diff
|
||||
diff = topotest.get_textdiff(
|
||||
actual,
|
||||
expected,
|
||||
title1="actual Zebra IPv6 routing table",
|
||||
title2="expected Zebra IPv6 routing table",
|
||||
)
|
||||
|
||||
# Empty string if it matches, otherwise diff contains unified diff
|
||||
if diff:
|
||||
sys.stderr.write(
|
||||
"r%s failed Zebra IPv6 Routing Table Check:\n%s\n" % (i, diff)
|
||||
)
|
||||
failures += 1
|
||||
else:
|
||||
print("r%s ok" % i)
|
||||
|
||||
assert (
|
||||
failures == 0
|
||||
), "Zebra IPv6 Routing Table verification failed for router r%s:\n%s" % (
|
||||
i,
|
||||
diff,
|
||||
)
|
||||
test_func = functools.partial(_verify_ip_route, expected)
|
||||
success, _ = topotest.run_and_expect(test_func, "", count=30, wait=1)
|
||||
assert success, "Failed verifying IPv6 routes for r{}".format(i)
|
||||
|
||||
# Make sure that all daemons are running
|
||||
for i in range(1, 4):
|
||||
|
Loading…
Reference in New Issue
Block a user