Skip to content

Commit a4581f5

Browse files
committed
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>
1 parent 6978006 commit a4581f5

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

bgp-ecmp-topo1/test_bgp_ecmp_topo1.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"""
2828

2929
import json
30+
import functools
3031
import os
3132
import sys
3233
import pytest
@@ -123,8 +124,6 @@ def test_bgp_convergence():
123124
if tgen.routers_have_failure():
124125
pytest.skip(tgen.errors)
125126

126-
topotest.sleep(20, 'waiting for bgp convergence')
127-
128127
# Expected result
129128
router = tgen.gears['r1']
130129
if router.has_version('<', '3.0'):
@@ -134,12 +133,9 @@ def test_bgp_convergence():
134133

135134
expected = json.loads(open(reffile).read())
136135

137-
# Define test function and call it
138-
def _convergence_test():
139-
output = router.vtysh_cmd('show ip bgp summary json', isjson=True)
140-
return topotest.json_cmp(output, expected)
141-
142-
_, res = topotest.run_and_expect(_convergence_test, None, count=10, wait=1)
136+
test_func = functools.partial(
137+
topotest.router_json_cmp, router, 'show ip bgp summary json', expected)
138+
_, res = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
143139
assertmsg = 'BGP router network did not converge'
144140
assert res is None, assertmsg
145141

@@ -164,11 +160,9 @@ def test_bgp_ecmp():
164160
peer = {'multipath': True, 'valid': True}
165161
expect['routes'][netkey].append(peer)
166162

167-
def _output_cmp():
168-
output = tgen.gears['r1'].vtysh_cmd('show ip bgp json', isjson=True)
169-
return topotest.json_cmp(output, expect)
170-
171-
_, res = topotest.run_and_expect(_output_cmp, None, count=20, wait=3)
163+
test_func = functools.partial(topotest.router_json_cmp,
164+
tgen.gears['r1'], 'show ip bgp json', expect)
165+
_, res = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
172166
assertmsg = 'expected multipath routes in "show ip bgp" output'
173167
assert res is None, assertmsg
174168

0 commit comments

Comments
 (0)