Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tests/bgp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from tests.common.helpers.parallel import reset_ansible_local_tmp
from tests.common.utilities import wait_until, get_plt_reboot_ctrl
from tests.common.utilities import wait_tcp_connection
from tests.common.utilities import is_ipv6_only_topology
from tests.common import config_reload
from bgp_helpers import define_config, apply_default_bgp_config, DUT_TMP_DIR, TEMPLATE_DIR, BGP_PLAIN_TEMPLATE,\
BGP_NO_EXPORT_TEMPLATE, DUMP_FILE, CUSTOM_DUMP_SCRIPT, CUSTOM_DUMP_SCRIPT_DEST,\
Expand Down Expand Up @@ -185,9 +186,13 @@ def restore_nbr_gr(node=None, results=None):
err_msg = "not all bgp sessions are up after enable graceful restart"

is_backend_topo = "backend" in tbinfo["topo"]["name"]
if not is_backend_topo and res and not wait_until(100, 5, 0, duthost.check_bgp_default_route):
is_v6_topo = is_ipv6_only_topology(tbinfo)
if not is_backend_topo and res and not wait_until(100, 5, 0, duthost.check_bgp_default_route, ipv4=not is_v6_topo):
res = False
err_msg = "ipv4 or ipv6 bgp default route not available"
if is_v6_topo:
err_msg = "ipv6 bgp default route not available for v6 topology"
else:
err_msg = "ipv4 or ipv6 bgp default route not available"

if not res:
# Disable graceful restart in case of failure
Expand Down
34 changes: 23 additions & 11 deletions tests/bgp/test_bgp_gr_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from tests.common.helpers.assertions import pytest_assert
from tests.common.utilities import wait_until
from tests.common.utilities import is_ipv4_address
from tests.common.utilities import is_ipv6_only_topology


pytestmark = [
Expand Down Expand Up @@ -108,22 +109,33 @@ def _verify_prefix_counters_from_neighbor_after_graceful_restart(duthost, bgp_ne
portchannels = config_facts.get('PORTCHANNEL_MEMBER', {})
dev_nbrs = config_facts.get('DEVICE_NEIGHBOR', {})
configurations = tbinfo['topo']['properties']['configuration_properties']
exabgp_ips = [configurations['common']['nhipv4'], configurations['common']['nhipv6']]
exabgp_sessions = ['exabgp_v4', 'exabgp_v6']
is_v6_topo = is_ipv6_only_topology(tbinfo)
if is_v6_topo:
exabgp_ips = [configurations['common']['nhipv6']]
exabgp_sessions = ['exabgp_v6']
else:
exabgp_ips = [configurations['common']['nhipv4'], configurations['common']['nhipv6']]
exabgp_sessions = ['exabgp_v4', 'exabgp_v6']

# select neighbor to test
if duthost.check_bgp_default_route():
if duthost.check_bgp_default_route(ipv4=not is_v6_topo):
# if default route is present, select from default route nexthops
rtinfo_v4 = duthost.get_ip_route_info(ipaddress.ip_network("0.0.0.0/0"))
rtinfo_v6 = duthost.get_ip_route_info(ipaddress.ip_network("::/0"))
if is_v6_topo:
rtinfo_v6 = duthost.get_ip_route_info(ipaddress.ip_network("::/0"))
ifnames_v6 = [nh[1] for nh in rtinfo_v6['nexthops']]

test_interface = ifnames_v6[0]
else:
rtinfo_v4 = duthost.get_ip_route_info(ipaddress.ip_network("0.0.0.0/0"))
rtinfo_v6 = duthost.get_ip_route_info(ipaddress.ip_network("::/0"))

ifnames_v4 = [nh[1] for nh in rtinfo_v4['nexthops']]
ifnames_v6 = [nh[1] for nh in rtinfo_v6['nexthops']]
ifnames_v4 = [nh[1] for nh in rtinfo_v4['nexthops']]
ifnames_v6 = [nh[1] for nh in rtinfo_v6['nexthops']]

ifnames_common = [ifname for ifname in ifnames_v4 if ifname in ifnames_v6]
if len(ifnames_common) == 0:
pytest.skip("No common ifnames between ifnames_v4 and ifname_v6: %s and %s" % (ifnames_v4, ifnames_v6))
test_interface = ifnames_common[0]
ifnames_common = [ifname for ifname in ifnames_v4 if ifname in ifnames_v6]
if len(ifnames_common) == 0:
pytest.skip("No common ifnames between ifnames_v4 and ifname_v6: %s and %s" % (ifnames_v4, ifnames_v6))
test_interface = ifnames_common[0]
else:
# if default route is not present, randomly select a neighbor to test
test_interface = random.sample(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,8 @@ bgp/test_bgp_gr_helper.py:

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

bgp/test_bgp_multipath_relax.py:
Expand Down
Loading