diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:56:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:56:23 +0000 |
commit | c15d6efd40655f717841d00839a43df1ead5cb26 (patch) | |
tree | 35d579f9a19170e2b39085669ca92533c2d161b4 /tests/topotests/mgmt_oper/oper.py | |
parent | Adding upstream version 10.0.1. (diff) | |
download | frr-upstream.tar.xz frr-upstream.zip |
Adding upstream version 10.1.upstream/10.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/mgmt_oper/oper.py')
-rw-r--r-- | tests/topotests/mgmt_oper/oper.py | 92 |
1 files changed, 49 insertions, 43 deletions
diff --git a/tests/topotests/mgmt_oper/oper.py b/tests/topotests/mgmt_oper/oper.py index 0f6c3cd..162c1eb 100644 --- a/tests/topotests/mgmt_oper/oper.py +++ b/tests/topotests/mgmt_oper/oper.py @@ -62,7 +62,8 @@ def disable_debug(router): router.vtysh_cmd("no debug northbound callbacks configuration") -def do_oper_test(tgen, query_results): +@retry(retry_timeout=30, initial_wait=1) +def _do_oper_test(tgen, qr): r1 = tgen.gears["r1"].net qcmd = ( @@ -73,50 +74,55 @@ def do_oper_test(tgen, query_results): r"""| sed -e 's/"if-index": [0-9][0-9]*/"if-index": "rubout"/'""" r"""| sed -e 's/"id": [0-9][0-9]*/"id": "rubout"/'""" ) - - doreset = True + # Don't use this for now. dd_json_cmp = None - for qr in query_results: - step(f"Perform query '{qr[0]}'", reset=doreset) - if doreset: - doreset = False - expected = open(qr[1], encoding="ascii").read() - output = r1.cmd_nostatus(qcmd.format(qr[0], qr[2] if len(qr) > 2 else "")) - - try: - ojson = json.loads(output) - except json.decoder.JSONDecodeError as error: - logging.error("Error decoding json: %s\noutput:\n%s", error, output) - raise - - try: - ejson = json.loads(expected) - except json.decoder.JSONDecodeError as error: - logging.error( - "Error decoding json exp result: %s\noutput:\n%s", error, expected + + expected = open(qr[1], encoding="ascii").read() + output = r1.cmd_nostatus(qcmd.format(qr[0], qr[2] if len(qr) > 2 else "")) + + try: + ojson = json.loads(output) + except json.decoder.JSONDecodeError as error: + logging.error("Error decoding json: %s\noutput:\n%s", error, output) + raise + + try: + ejson = json.loads(expected) + except json.decoder.JSONDecodeError as error: + logging.error( + "Error decoding json exp result: %s\noutput:\n%s", error, expected + ) + raise + + if dd_json_cmp: + cmpout = json_cmp(ojson, ejson, exact_match=True) + if cmpout: + logging.warning( + "-------DIFF---------\n%s\n---------DIFF----------", + pprint.pformat(cmpout), ) - raise - - if dd_json_cmp: - cmpout = json_cmp(ojson, ejson, exact_match=True) - if cmpout: - logging.warning( - "-------DIFF---------\n%s\n---------DIFF----------", - pprint.pformat(cmpout), - ) - else: - cmpout = tt_json_cmp(ojson, ejson, exact=True) - if cmpout: - logging.warning( - "-------EXPECT--------\n%s\n------END-EXPECT------", - json.dumps(ejson, indent=4), - ) - logging.warning( - "--------GOT----------\n%s\n-------END-GOT--------", - json.dumps(ojson, indent=4), - ) - - assert cmpout is None + else: + cmpout = tt_json_cmp(ojson, ejson, exact=True) + if cmpout: + logging.warning( + "-------EXPECT--------\n%s\n------END-EXPECT------", + json.dumps(ejson, indent=4), + ) + logging.warning( + "--------GOT----------\n%s\n-------END-GOT--------", + json.dumps(ojson, indent=4), + ) + + assert cmpout is None + + +def do_oper_test(tgen, query_results): + reset = True + for qr in query_results: + step(f"Perform query '{qr[0]}'", reset=reset) + if reset: + reset = False + _do_oper_test(tgen, qr) def get_ip_networks(super_prefix, count): |