mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 22:29:23 +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 sys
|
||||||
import pytest
|
import pytest
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
import functools
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
from lib import topotest
|
from lib import topotest
|
||||||
@ -273,6 +273,27 @@ def test_zebra_ipv6_routingTable():
|
|||||||
global fatal_error
|
global fatal_error
|
||||||
net = get_topogen().net
|
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
|
# Skip if previous fatal error condition is raised
|
||||||
if fatal_error != "":
|
if fatal_error != "":
|
||||||
pytest.skip(fatal_error)
|
pytest.skip(fatal_error)
|
||||||
@ -291,42 +312,9 @@ def test_zebra_ipv6_routingTable():
|
|||||||
# Fix newlines (make them all the same)
|
# Fix newlines (make them all the same)
|
||||||
expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
|
expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
|
||||||
|
|
||||||
# Actual output from router
|
test_func = functools.partial(_verify_ip_route, expected)
|
||||||
actual = (
|
success, _ = topotest.run_and_expect(test_func, "", count=30, wait=1)
|
||||||
net["r%s" % i]
|
assert success, "Failed verifying IPv6 routes for r{}".format(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,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make sure that all daemons are running
|
# Make sure that all daemons are running
|
||||||
for i in range(1, 4):
|
for i in range(1, 4):
|
||||||
|
Loading…
Reference in New Issue
Block a user