summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2018-08-04 10:14:37 -0300
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-11-27 20:22:14 -0500
commitab4d1656b5947722fbc9f6dbed71e8865db9eeec (patch)
tree47b7145867b58c520bf4a72dd619a293cf8e58e7
parent38b291bca052275fe0cc3e0a9fc06451b4d93ebb (diff)
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>
-rwxr-xr-xtests/topotests/bgp-ecmp-topo1/test_bgp_ecmp_topo1.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/tests/topotests/bgp-ecmp-topo1/test_bgp_ecmp_topo1.py b/tests/topotests/bgp-ecmp-topo1/test_bgp_ecmp_topo1.py
index 9bd660b750..d5c51ce276 100755
--- a/tests/topotests/bgp-ecmp-topo1/test_bgp_ecmp_topo1.py
+++ b/tests/topotests/bgp-ecmp-topo1/test_bgp_ecmp_topo1.py
@@ -27,6 +27,7 @@ test_bgp_ecmp_topo1.py: Test BGP topology with ECMP (Equal Cost MultiPath).
"""
import json
+import functools
import os
import sys
import pytest
@@ -123,8 +124,6 @@ def test_bgp_convergence():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- topotest.sleep(20, 'waiting for bgp convergence')
-
# Expected result
router = tgen.gears['r1']
if router.has_version('<', '3.0'):
@@ -134,12 +133,9 @@ def test_bgp_convergence():
expected = json.loads(open(reffile).read())
- # Define test function and call it
- def _convergence_test():
- output = router.vtysh_cmd('show ip bgp summary json', isjson=True)
- return topotest.json_cmp(output, expected)
-
- _, res = topotest.run_and_expect(_convergence_test, None, count=10, wait=1)
+ test_func = functools.partial(
+ topotest.router_json_cmp, router, 'show ip bgp summary json', expected)
+ _, res = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assertmsg = 'BGP router network did not converge'
assert res is None, assertmsg
@@ -164,11 +160,9 @@ def test_bgp_ecmp():
peer = {'multipath': True, 'valid': True}
expect['routes'][netkey].append(peer)
- def _output_cmp():
- output = tgen.gears['r1'].vtysh_cmd('show ip bgp json', isjson=True)
- return topotest.json_cmp(output, expect)
-
- _, res = topotest.run_and_expect(_output_cmp, None, count=20, wait=3)
+ test_func = functools.partial(topotest.router_json_cmp,
+ tgen.gears['r1'], 'show ip bgp json', expect)
+ _, res = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
assertmsg = 'expected multipath routes in "show ip bgp" output'
assert res is None, assertmsg