mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 02:46:26 +00:00
bgp-ecmp-topo1: remove sleep and reduce code
Use new standardized code to test router output and remove the convergence sleep. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
parent
38b291bca0
commit
ab4d1656b5
@ -27,6 +27,7 @@ test_bgp_ecmp_topo1.py: Test BGP topology with ECMP (Equal Cost MultiPath).
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import functools
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import pytest
|
import pytest
|
||||||
@ -123,8 +124,6 @@ def test_bgp_convergence():
|
|||||||
if tgen.routers_have_failure():
|
if tgen.routers_have_failure():
|
||||||
pytest.skip(tgen.errors)
|
pytest.skip(tgen.errors)
|
||||||
|
|
||||||
topotest.sleep(20, 'waiting for bgp convergence')
|
|
||||||
|
|
||||||
# Expected result
|
# Expected result
|
||||||
router = tgen.gears['r1']
|
router = tgen.gears['r1']
|
||||||
if router.has_version('<', '3.0'):
|
if router.has_version('<', '3.0'):
|
||||||
@ -134,12 +133,9 @@ def test_bgp_convergence():
|
|||||||
|
|
||||||
expected = json.loads(open(reffile).read())
|
expected = json.loads(open(reffile).read())
|
||||||
|
|
||||||
# Define test function and call it
|
test_func = functools.partial(
|
||||||
def _convergence_test():
|
topotest.router_json_cmp, router, 'show ip bgp summary json', expected)
|
||||||
output = router.vtysh_cmd('show ip bgp summary json', isjson=True)
|
_, res = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
|
||||||
return topotest.json_cmp(output, expected)
|
|
||||||
|
|
||||||
_, res = topotest.run_and_expect(_convergence_test, None, count=10, wait=1)
|
|
||||||
assertmsg = 'BGP router network did not converge'
|
assertmsg = 'BGP router network did not converge'
|
||||||
assert res is None, assertmsg
|
assert res is None, assertmsg
|
||||||
|
|
||||||
@ -164,11 +160,9 @@ def test_bgp_ecmp():
|
|||||||
peer = {'multipath': True, 'valid': True}
|
peer = {'multipath': True, 'valid': True}
|
||||||
expect['routes'][netkey].append(peer)
|
expect['routes'][netkey].append(peer)
|
||||||
|
|
||||||
def _output_cmp():
|
test_func = functools.partial(topotest.router_json_cmp,
|
||||||
output = tgen.gears['r1'].vtysh_cmd('show ip bgp json', isjson=True)
|
tgen.gears['r1'], 'show ip bgp json', expect)
|
||||||
return topotest.json_cmp(output, expect)
|
_, res = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
|
||||||
|
|
||||||
_, res = topotest.run_and_expect(_output_cmp, None, count=20, wait=3)
|
|
||||||
assertmsg = 'expected multipath routes in "show ip bgp" output'
|
assertmsg = 'expected multipath routes in "show ip bgp" output'
|
||||||
assert res is None, assertmsg
|
assert res is None, assertmsg
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user