From 650e0d1bb8aa85383c2ce8a37461ad25f2c1975e Mon Sep 17 00:00:00 2001 From: Pat Ruddy Date: Thu, 6 May 2021 14:36:52 +0100 Subject: [PATCH] tests: fix intermittent key error in bgp-auth topotest There is a rare case where with prefix peers the peer is completely absent from the json output when checking the peer state resulting in a python key error. Check key exists before checking the state. Signed-off-by: Pat Ruddy --- tests/topotests/bgp-auth/test_bgp_auth.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/topotests/bgp-auth/test_bgp_auth.py b/tests/topotests/bgp-auth/test_bgp_auth.py index 521ca332d0..b2cdef1c93 100644 --- a/tests/topotests/bgp-auth/test_bgp_auth.py +++ b/tests/topotests/bgp-auth/test_bgp_auth.py @@ -357,9 +357,10 @@ def check_neigh_state(router, peer, state, vrf=""): "show bgp vrf {} neighbors {} json".format(vrf, peer) ) neigh_output_json = json.loads(neigh_output) - if neigh_output_json[peer]["bgpState"] == state: - matched = True - break + if peer in neigh_output_json.keys(): + if neigh_output_json[peer]["bgpState"] == state: + matched = True + break count += 1 sleep(1) -- 2.39.5