mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-22 21:51:54 +00:00
isis-topo1: use run_and_expect
Use `run_and_expect` instead of manually implementing this code in the test. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
parent
5cffda1882
commit
9e2201b8aa
@ -27,6 +27,7 @@ test_isis_topo1.py: Test ISIS topology.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
import functools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -133,26 +134,21 @@ def test_isis_convergence():
|
|||||||
# open('/tmp/{}_topology.json'.format(rname), 'w').write(
|
# open('/tmp/{}_topology.json'.format(rname), 'w').write(
|
||||||
# json.dumps(show_isis_topology(router), indent=2, sort_keys=True)
|
# json.dumps(show_isis_topology(router), indent=2, sort_keys=True)
|
||||||
# )
|
# )
|
||||||
wait = 90
|
|
||||||
startt = time.time()
|
for rname, router in tgen.routers().iteritems():
|
||||||
loop = True
|
filename = '{0}/{1}/{1}_topology.json'.format(CWD, rname)
|
||||||
done = False
|
expected = json.loads(open(filename).read())
|
||||||
while loop and not done:
|
|
||||||
delta = time.time() - startt
|
def compare_isis_topology(router, expected):
|
||||||
loop = delta < wait
|
"Helper function to test ISIS topology convergence."
|
||||||
done = True
|
|
||||||
for rname, router in tgen.routers().iteritems():
|
|
||||||
filename = '{0}/{1}/{1}_topology.json'.format(CWD, rname)
|
|
||||||
expected = json.loads(open(filename, 'r').read())
|
|
||||||
actual = show_isis_topology(router)
|
actual = show_isis_topology(router)
|
||||||
if topotest.json_cmp(actual, expected) != None:
|
return topotest.json_cmp(actual, expected)
|
||||||
done = False
|
|
||||||
if loop == False:
|
test_func = functools.partial(compare_isis_topology, router, expected)
|
||||||
assertmsg = "Router '%s' topology mismatch after +%4.2f secs" % (rname, delta)
|
(result, diff) = topotest.run_and_expect(test_func, None,
|
||||||
assert topotest.json_cmp(actual, expected) is None, assertmsg
|
wait=0.5, count=120)
|
||||||
if loop and not done:
|
assert result, 'ISIS did not converge on {}:\n{}'.format(rname, diff)
|
||||||
time.sleep (0.5)
|
|
||||||
logger.info("ISIS protocol converged after +%4.2f secs" % (delta))
|
|
||||||
|
|
||||||
def test_isis_route_installation():
|
def test_isis_route_installation():
|
||||||
"Check whether all expected routes are present"
|
"Check whether all expected routes are present"
|
||||||
|
Loading…
Reference in New Issue
Block a user