Skip to content

Commit 03b002e

Browse files
authored
[action] [PR:19403] Fix SRv6 config_setup fixture (sonic-net#543)
<!-- Please make sure you've read and understood our contributing guidelines; https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md Please provide following information to help code review process a bit easier: --> ### Description of PR <!-- - Please include a summary of the change and which issue is fixed. - Please also include relevant motivation and context. Where should reviewer start? background context? - List any dependencies that are required for this change. --> Summary: Previously, the config_setup fixture assumes that the egress RIF of static route is always a single ethernet interface. However, in some setups, it can be a portchannel. We need to adapt the fixture to work even if portchannel exists. Fixes # (issue) ### Type of change <!-- - Fill x for your type of change. - e.g. - [x] Bug fix --> - [x] Bug fix - [ ] Testbed and Framework(new/improvement) - [ ] New Test case - [ ] Skipped for non-supported platforms - [ ] Test case improvement ### Back port request - [ ] 202205 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [x] 202412 - [ ] 202505 ### Approach #### What is the motivation for this PR? #### How did you do it? #### How did you verify/test it? #### Any platform specific information? #### Supported testbed topology if it's a new test case? ### Documentation <!-- (If it's a new feature, new test case) Did you update documentation/Wiki relevant to your implementation? Link to the wiki page? -->
1 parent 07e821e commit 03b002e

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

tests/srv6/conftest.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,21 @@ def srv6_crm_total_sids(rand_selected_dut):
5757
rand_selected_dut.command(f"crm config polling interval {original_crm_polling_interval}")
5858

5959

60-
def get_random_uplink_port(upstream_links, intf_infos): # noqa F811
60+
def get_random_uplink_port(duthost, upstream_links, intf_infos): # noqa F811
6161
'''
6262
Get a random uplink port that is used by the ipv6 interface info
6363
'''
6464
upstream_ports = set(upstream_links.keys())
65+
random_port = random.choice(list(upstream_ports))
66+
portchannels = duthost.show_and_parse('show int portchannel', start_line_index=2)
67+
for pc in portchannels:
68+
if random_port in pc['ports']:
69+
random_port = pc['team dev']
70+
break
71+
72+
logger.info(f"Selected uplink port: {random_port}")
6573
intf_neighbor_map = {intf_info['interface']: intf_info['neighbor ip'] for intf_info in intf_infos}
66-
common_ports = upstream_ports.intersection(intf_neighbor_map.keys())
67-
if common_ports:
68-
random_port = random.choice(list(common_ports))
69-
return random_port, intf_neighbor_map[random_port]
74+
return random_port, intf_neighbor_map[random_port]
7075

7176

7277
@pytest.fixture(scope="class", params=MySIDs.TUNNEL_MODE)
@@ -76,7 +81,8 @@ def config_setup(request, rand_selected_dut, srv6_crm_total_sids, upstream_links
7681
'''
7782
with allure.step('Create static route for SRv6'):
7883
ipv6_intf_info = rand_selected_dut.show_and_parse('show ipv6 interface')
79-
ifname, nexthop = get_random_uplink_port(upstream_links, ipv6_intf_info)
84+
ifname, nexthop = get_random_uplink_port(rand_selected_dut, upstream_links, ipv6_intf_info)
85+
logger.info(f"Selected uplink interface and nexthop: {ifname}, nexthop: {nexthop}")
8086
rand_selected_dut.command(f"sonic-db-cli CONFIG_DB HSET STATIC_ROUTE\\|default\\|{ROUTE_BASE}::/16 "
8187
f"nexthop {nexthop} ifname {ifname}")
8288

0 commit comments

Comments
 (0)