mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 04:26:12 +00:00
tests: Use run_and_expect() for rip_topo1
Avoid checking once and failing immediately. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
parent
5b28833d38
commit
3349754a80
@ -19,6 +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__))))
|
||||
@ -258,24 +259,7 @@ def test_zebra_ipv4_routingTable():
|
||||
global fatal_error
|
||||
net = get_topogen().net
|
||||
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
pytest.skip(fatal_error)
|
||||
|
||||
thisDir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
# Verify OSPFv3 Routing Table
|
||||
print("\n\n** Verifing Zebra IPv4 Routing Table")
|
||||
print("******************************************\n")
|
||||
failures = 0
|
||||
for i in range(1, 4):
|
||||
refTableFile = "%s/r%s/show_ip_route.ref" % (thisDir, i)
|
||||
if os.path.isfile(refTableFile):
|
||||
# Read expected result from file
|
||||
expected = open(refTableFile).read().rstrip()
|
||||
# Fix newlines (make them all the same)
|
||||
expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
def _verify_ip_route(expected):
|
||||
# Actual output from router
|
||||
actual = (
|
||||
net["r%s" % i]
|
||||
@ -287,29 +271,31 @@ def test_zebra_ipv4_routingTable():
|
||||
# Fix newlines (make them all the same)
|
||||
actual = ("\n".join(actual.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
# Generate Diff
|
||||
diff = topotest.get_textdiff(
|
||||
return topotest.get_textdiff(
|
||||
actual,
|
||||
expected,
|
||||
title1="actual Zebra IPv4 routing table",
|
||||
title2="expected Zebra IPv4 routing table",
|
||||
)
|
||||
|
||||
# Empty string if it matches, otherwise diff contains unified diff
|
||||
if diff:
|
||||
sys.stderr.write(
|
||||
"r%s failed Zebra IPv4 Routing Table Check:\n%s\n" % (i, diff)
|
||||
)
|
||||
failures += 1
|
||||
else:
|
||||
print("r%s ok" % i)
|
||||
# Skip if previous fatal error condition is raised
|
||||
if fatal_error != "":
|
||||
pytest.skip(fatal_error)
|
||||
|
||||
assert (
|
||||
failures == 0
|
||||
), "Zebra IPv4 Routing Table verification failed for router r%s:\n%s" % (
|
||||
i,
|
||||
diff,
|
||||
)
|
||||
thisDir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
print("\n\n** Verifing Zebra IPv4 Routing Table")
|
||||
print("******************************************\n")
|
||||
for i in range(1, 4):
|
||||
refTableFile = "%s/r%s/show_ip_route.ref" % (thisDir, i)
|
||||
if os.path.isfile(refTableFile):
|
||||
expected = open(refTableFile).read().rstrip()
|
||||
# Fix newlines (make them all the same)
|
||||
expected = ("\n".join(expected.splitlines()) + "\n").splitlines(1)
|
||||
|
||||
test_func = functools.partial(_verify_ip_route, expected)
|
||||
success, _ = topotest.run_and_expect(test_func, "", count=30, wait=1)
|
||||
assert success, "Failed verifying IPv4 routes for r{}".format(i)
|
||||
|
||||
# Make sure that all daemons are still running
|
||||
for i in range(1, 4):
|
||||
|
Loading…
Reference in New Issue
Block a user