Skip to content
Merged
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
64 changes: 61 additions & 3 deletions tests/fib/test_fib.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,54 @@ def filter_ports(all_port_indices, tbinfo):
return host_ptf_ports_all


def get_port_and_portchannel_members(port_name, all_port_indices, duts_minigraph_facts,
upstream_lc, tbinfo):
"""
Get PTF port indices for a port and all its port channel members (if applicable).

Args:
port_name: The DUT port name to check
all_port_indices: Dictionary mapping PTF port indices to (asic_id, port_name)
duts_minigraph_facts: Minigraph facts containing port channel information
upstream_lc: The upstream line card hostname

Returns:
List of PTF port indices for the port and all its port channel members
"""

# for T2(except UT2) topologies, no need to append, as we are already filtering out the whole upstream lc ports
if tbinfo['topo']['type'] == 't2' and 't2_single_node' not in tbinfo['topo']['name']:
return []

# Search all ASICs for port channel information
portchannel_members = [port_name] # Default is just the single port
found_portchannel = False

for asic_id, asic_data in duts_minigraph_facts[upstream_lc]:
mg_facts = asic_data
if mg_facts and 'minigraph_portchannels' in mg_facts:
for pc_name, pc_info in mg_facts['minigraph_portchannels'].items():
if port_name in pc_info.get('members', []):
portchannel_members = pc_info['members']
logging.info("Port {} is a member of port channel {} with {} member(s): {}".format(
port_name, pc_name, len(portchannel_members), portchannel_members))
found_portchannel = True
break
if found_portchannel:
break

# Find PTF port indices for all port channel members
ptf_ports_to_filter = []
for member_port in portchannel_members:
for ptf_port, (asic_id, dut_port) in all_port_indices.items():
if dut_port == member_port:
ptf_ports_to_filter.append(ptf_port)
logging.info("Found PTF port {} for port channel member {}".format(ptf_port, member_port))
break

return ptf_ports_to_filter


def fib_info_files_per_function(duthosts, ptfhost, duts_running_config_facts, duts_minigraph_facts, tbinfo, request):
"""Get FIB info from database and store to text files on PTF host.

Expand Down Expand Up @@ -840,8 +888,14 @@ def test_ecmp_group_member_flap(
logging.info("Shutting down port {}".format(nh_dut_ports[port_index_to_shut][1]))
duthosts[0].shell("sudo config interface {} shutdown {}".format(asic_ns, nh_dut_ports[port_index_to_shut][1]))

time.sleep(10) # Allow time for the state to stabilize
filtered_ports.append(nh_ptf_ports[port_index_to_shut])
time.sleep(60) # Allow time for the state to stabilize

# Get all PTF ports for the port and its port channel members (if applicable)
ptf_ports_to_filter = get_port_and_portchannel_members(
nh_dut_ports[port_index_to_shut][1], all_port_indices, duts_minigraph_facts, upstream_lc, tbinfo)

# Add them to filtered_ports
filtered_ports.extend(ptf_ports_to_filter)

# --- Re-run the PTF test after member down ---
logging.info("Verifying ECMP behavior after member down.")
Expand Down Expand Up @@ -885,7 +939,11 @@ def test_ecmp_group_member_flap(

logging.info("Enabling port {}".format(nh_dut_ports[port_index_to_shut][1]))
duthosts[0].shell("sudo config interface {} startup {}".format(asic_ns, nh_dut_ports[port_index_to_shut][1]))
filtered_ports.pop()

# Remove the PTF ports that were added earlier
for ptf_port in ptf_ports_to_filter:
if ptf_port in filtered_ports:
filtered_ports.remove(ptf_port)

time.sleep(60) # Allow time for the state to stabilize

Expand Down
Loading