diff options
| author | Christian Hopps <chopps@labn.net> | 2021-09-06 04:16:15 -0400 |
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2021-09-08 15:25:52 -0400 |
| commit | 1375385adf6bfd89d0bcffeec85596783addda0a (patch) | |
| tree | ca541b178cb49d12c6956e5ea93fd38d74212de2 /tests/topotests/lib/topotest.py | |
| parent | 75ec7bdb5dfc8c68ee8c50d19ac456ccd002b2bc (diff) | |
tests: increase wait and update test
Modernize the test a bit, generate expected results rather than load from
file, and add a general json_cmp with retry function and use it.
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'tests/topotests/lib/topotest.py')
| -rw-r--r-- | tests/topotests/lib/topotest.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index b6f55664a6..7541d506cb 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -439,6 +439,19 @@ def run_and_expect_type(func, etype, count=20, wait=3, avalue=None): return (False, result) +def router_json_cmp_retry(router, cmd, data, exact=False, retry_timeout=10.0): + """ + Runs `cmd` that returns JSON data (normally the command ends with 'json') + and compare with `data` contents. Retry by default for 10 seconds + """ + + def test_func(): + return router_json_cmp(router, cmd, data, exact) + + ok, _ = run_and_expect(test_func, None, int(retry_timeout), 1) + return ok + + def int2dpid(dpid): "Converting Integer to DPID" |
