diff --git a/tests/common/config_reload.py b/tests/common/config_reload.py index 0b0fe7c2768..b6e2542bece 100644 --- a/tests/common/config_reload.py +++ b/tests/common/config_reload.py @@ -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", diff --git a/tests/common/devices/multi_asic.py b/tests/common/devices/multi_asic.py index 6f541c201af..d879e468481 100644 --- a/tests/common/devices/multi_asic.py +++ b/tests/common/devices/multi_asic.py @@ -549,7 +549,8 @@ 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)* }} """ @@ -557,9 +558,10 @@ def get_bgp_neighbors_per_asic(self, state="established"): 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 @@ -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