From 9b3fd1ef696ad5a66c159009abf397a4f50492c5 Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Mon, 17 Apr 2023 01:36:46 -0400 Subject: [PATCH] tests: use a more specific xpath for finding the route JSON data Rather than requesting the data for the entire model, just request the route data for the specific prefix. This also tests the xpath code (which was previously broken). Signed-off-by: Christian Hopps --- .../topotests/rip_allow_ecmp/test_rip_allow_ecmp.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/topotests/rip_allow_ecmp/test_rip_allow_ecmp.py b/tests/topotests/rip_allow_ecmp/test_rip_allow_ecmp.py index b0ba146984..acc0aea9e8 100644 --- a/tests/topotests/rip_allow_ecmp/test_rip_allow_ecmp.py +++ b/tests/topotests/rip_allow_ecmp/test_rip_allow_ecmp.py @@ -52,9 +52,17 @@ def test_rip_allow_ecmp(): r1 = tgen.gears["r1"] def _show_rip_routes(): - output = json.loads( - r1.vtysh_cmd("show yang operational-data /frr-ripd:ripd ripd") + xpath = ( + "/frr-ripd:ripd/instance[vrf='default']" + "/state/routes/route[prefix='10.10.10.1/32']" ) + try: + output = json.loads( + r1.vtysh_cmd(f"show yang operational-data {xpath} ripd") + ) + except Exception: + return False + try: output = output["frr-ripd:ripd"]["instance"][0]["state"]["routes"] except KeyError: -- 2.39.5