Skip to content

Commit

Permalink
fix: return all BGP neighbors for config reload (#15634)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyw233 authored and mssonicbld committed Nov 21, 2024
1 parent a25ec62 commit 5d42372
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/common/config_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def _config_reload_cmd_wrapper(cmd, executable):
time.sleep(wait)

if wait_for_bgp:
bgp_neighbors = sonic_host.get_bgp_neighbors_per_asic()
bgp_neighbors = sonic_host.get_bgp_neighbors_per_asic(state="all")
pytest_assert(
wait_until(wait + 120, 10, 0, sonic_host.check_bgp_session_state_all_asics, bgp_neighbors),
"Not all bgp sessions are established after config reload",
Expand Down
12 changes: 7 additions & 5 deletions tests/common/devices/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,17 +549,19 @@ def get_bgp_neighbors_per_asic(self, state="established"):
Get a diction of BGP neighbor states
Args:
state: BGP session state, return neighbor IP of sessions that match this state
state: BGP session state, return neighbor IP of sessions that match this state. If state is "all",
return all neighbors regardless of state.
Returns: dictionary {namespace: { (neighbor_ip : info_dict)* }}
"""
bgp_neigh = {}
for asic in self.asics:
bgp_neigh[asic.namespace] = {}
bgp_info = asic.bgp_facts()["ansible_facts"]["bgp_neighbors"]
for k, v in list(bgp_info.items()):
if v["state"] != state:
bgp_info.pop(k)
if state != "all":
for k, v in list(bgp_info.items()):
if v["state"] != state:
bgp_info.pop(k)
bgp_neigh[asic.namespace].update(bgp_info)

return bgp_neigh
Expand Down Expand Up @@ -598,7 +600,7 @@ def check_bgp_session_state_all_asics(self, bgp_neighbors, state="established"):
"""
for asic in self.asics:
if asic.namespace in bgp_neighbors:
neigh_ips = [k.lower() for k, v in list(bgp_neighbors[asic.namespace].items()) if v["state"] == state]
neigh_ips = [k.lower() for k, v in list(bgp_neighbors[asic.namespace].items())]
if not asic.check_bgp_session_state(neigh_ips, state):
return False
return True
Expand Down

0 comments on commit 5d42372

Please sign in to comment.