]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: fix intermittent key error in bgp-auth topotest 8640/head
authorPat Ruddy <pat@voltanet.io>
Thu, 6 May 2021 13:36:52 +0000 (14:36 +0100)
committerPat Ruddy <pat@voltanet.io>
Thu, 6 May 2021 13:36:52 +0000 (14:36 +0100)
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 <pat@voltanet.io>
tests/topotests/bgp-auth/test_bgp_auth.py

index 521ca332d006cf0c1294bc9d0c79baca08b80a2a..b2cdef1c9302e102e36e5c273f88271bb7d6439b 100644 (file)
@@ -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)