27
27
"""
28
28
29
29
import json
30
+ import functools
30
31
import os
31
32
import sys
32
33
import pytest
@@ -123,8 +124,6 @@ def test_bgp_convergence():
123
124
if tgen .routers_have_failure ():
124
125
pytest .skip (tgen .errors )
125
126
126
- topotest .sleep (20 , 'waiting for bgp convergence' )
127
-
128
127
# Expected result
129
128
router = tgen .gears ['r1' ]
130
129
if router .has_version ('<' , '3.0' ):
@@ -134,12 +133,9 @@ def test_bgp_convergence():
134
133
135
134
expected = json .loads (open (reffile ).read ())
136
135
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 )
143
139
assertmsg = 'BGP router network did not converge'
144
140
assert res is None , assertmsg
145
141
@@ -164,11 +160,9 @@ def test_bgp_ecmp():
164
160
peer = {'multipath' : True , 'valid' : True }
165
161
expect ['routes' ][netkey ].append (peer )
166
162
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 )
172
166
assertmsg = 'expected multipath routes in "show ip bgp" output'
173
167
assert res is None , assertmsg
174
168
0 commit comments