Skip to content

Commit 9a5d8a2

Browse files
authored
Fix test_bgp_gr_helper.py for v6 topo (sonic-net#21453)
Skip v4 neighbors and checks for v6 topo Delete test_bgp_gr_helper.py xfail for v6 topo Signed-off-by: markxiao <[email protected]>
1 parent d9d12a8 commit 9a5d8a2

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

tests/bgp/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,13 @@ def restore_nbr_gr(node=None, results=None):
186186
err_msg = "not all bgp sessions are up after enable graceful restart"
187187

188188
is_backend_topo = "backend" in tbinfo["topo"]["name"]
189-
if not is_backend_topo and res and not wait_until(100, 5, 0, duthost.check_bgp_default_route):
189+
is_v6_topo = is_ipv6_only_topology(tbinfo)
190+
if not is_backend_topo and res and not wait_until(100, 5, 0, duthost.check_bgp_default_route, ipv4=not is_v6_topo):
190191
res = False
191-
err_msg = "ipv4 or ipv6 bgp default route not available"
192+
if is_v6_topo:
193+
err_msg = "ipv6 bgp default route not available for v6 topology"
194+
else:
195+
err_msg = "ipv4 or ipv6 bgp default route not available"
192196

193197
if not res:
194198
# Disable graceful restart in case of failure

tests/bgp/test_bgp_gr_helper.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from tests.common.helpers.assertions import pytest_assert
88
from tests.common.utilities import wait_until
99
from tests.common.utilities import is_ipv4_address
10+
from tests.common.utilities import is_ipv6_only_topology
1011

1112

1213
pytestmark = [
@@ -108,22 +109,33 @@ def _verify_prefix_counters_from_neighbor_after_graceful_restart(duthost, bgp_ne
108109
portchannels = config_facts.get('PORTCHANNEL_MEMBER', {})
109110
dev_nbrs = config_facts.get('DEVICE_NEIGHBOR', {})
110111
configurations = tbinfo['topo']['properties']['configuration_properties']
111-
exabgp_ips = [configurations['common']['nhipv4'], configurations['common']['nhipv6']]
112-
exabgp_sessions = ['exabgp_v4', 'exabgp_v6']
112+
is_v6_topo = is_ipv6_only_topology(tbinfo)
113+
if is_v6_topo:
114+
exabgp_ips = [configurations['common']['nhipv6']]
115+
exabgp_sessions = ['exabgp_v6']
116+
else:
117+
exabgp_ips = [configurations['common']['nhipv4'], configurations['common']['nhipv6']]
118+
exabgp_sessions = ['exabgp_v4', 'exabgp_v6']
113119

114120
# select neighbor to test
115-
if duthost.check_bgp_default_route():
121+
if duthost.check_bgp_default_route(ipv4=not is_v6_topo):
116122
# if default route is present, select from default route nexthops
117-
rtinfo_v4 = duthost.get_ip_route_info(ipaddress.ip_network("0.0.0.0/0"))
118-
rtinfo_v6 = duthost.get_ip_route_info(ipaddress.ip_network("::/0"))
123+
if is_v6_topo:
124+
rtinfo_v6 = duthost.get_ip_route_info(ipaddress.ip_network("::/0"))
125+
ifnames_v6 = [nh[1] for nh in rtinfo_v6['nexthops']]
126+
127+
test_interface = ifnames_v6[0]
128+
else:
129+
rtinfo_v4 = duthost.get_ip_route_info(ipaddress.ip_network("0.0.0.0/0"))
130+
rtinfo_v6 = duthost.get_ip_route_info(ipaddress.ip_network("::/0"))
119131

120-
ifnames_v4 = [nh[1] for nh in rtinfo_v4['nexthops']]
121-
ifnames_v6 = [nh[1] for nh in rtinfo_v6['nexthops']]
132+
ifnames_v4 = [nh[1] for nh in rtinfo_v4['nexthops']]
133+
ifnames_v6 = [nh[1] for nh in rtinfo_v6['nexthops']]
122134

123-
ifnames_common = [ifname for ifname in ifnames_v4 if ifname in ifnames_v6]
124-
if len(ifnames_common) == 0:
125-
pytest.skip("No common ifnames between ifnames_v4 and ifname_v6: %s and %s" % (ifnames_v4, ifnames_v6))
126-
test_interface = ifnames_common[0]
135+
ifnames_common = [ifname for ifname in ifnames_v4 if ifname in ifnames_v6]
136+
if len(ifnames_common) == 0:
137+
pytest.skip("No common ifnames between ifnames_v4 and ifname_v6: %s and %s" % (ifnames_v4, ifnames_v6))
138+
test_interface = ifnames_common[0]
127139
else:
128140
# if default route is not present, randomly select a neighbor to test
129141
test_interface = random.sample(

tests/common/plugins/conditional_mark/tests_mark_conditions.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,8 @@ bgp/test_bgp_gr_helper.py:
342342

343343
bgp/test_bgp_gr_helper.py::test_bgp_gr_helper_routes_perserved:
344344
xfail:
345-
reason: "xfail for IPv6-only topologies. Or test case has issue on the t0-isolated-d256u256s2 topo."
346-
conditions_logical_operator: or
345+
reason: "Test case has issue on the t0-isolated-d256u256s2 topo."
347346
conditions:
348-
- "'-v6-' in topo_name"
349347
- "'t0-isolated-d256u256s2' in topo_name and platform in ['x86_64-nvidia_sn5640-r0']"
350348

351349
bgp/test_bgp_max_route.py::test_bgp_max_prefix_behavior:

0 commit comments

Comments
 (0)