|
7 | 7 | from tests.common.helpers.assertions import pytest_assert |
8 | 8 | from tests.common.utilities import wait_until |
9 | 9 | from tests.common.utilities import is_ipv4_address |
| 10 | +from tests.common.utilities import is_ipv6_only_topology |
10 | 11 |
|
11 | 12 |
|
12 | 13 | pytestmark = [ |
@@ -108,22 +109,33 @@ def _verify_prefix_counters_from_neighbor_after_graceful_restart(duthost, bgp_ne |
108 | 109 | portchannels = config_facts.get('PORTCHANNEL_MEMBER', {}) |
109 | 110 | dev_nbrs = config_facts.get('DEVICE_NEIGHBOR', {}) |
110 | 111 | 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'] |
113 | 119 |
|
114 | 120 | # select neighbor to test |
115 | | - if duthost.check_bgp_default_route(): |
| 121 | + if duthost.check_bgp_default_route(ipv4=not is_v6_topo): |
116 | 122 | # 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")) |
119 | 131 |
|
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']] |
122 | 134 |
|
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] |
127 | 139 | else: |
128 | 140 | # if default route is not present, randomly select a neighbor to test |
129 | 141 | test_interface = random.sample( |
|
0 commit comments