Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use xcvr_skip_list to skip sfp tests #4157

Merged
merged 1 commit into from
Sep 4, 2021
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
28 changes: 16 additions & 12 deletions tests/common/platform/interface_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,31 @@ def get_port_map(dut, asic_index=None):

return port_mapping

def get_physical_port_indices(duthost):
"""Returns list of physical port numbers of the DUT"""
physical_port_indices = set()
def get_physical_port_indices(duthost, logical_intfs=None):
"""
@summary: Returns dictionary map of logical ports to corresponding physical port indices
@param logical_intfs: List of logical interfaces of the DUT
"""
physical_port_index_dict = {}

intf_facts = duthost.interface_facts()['ansible_facts']['ansible_interface_facts']
phy_port = re.compile(r'^Ethernet\d+$')
phy_intfs = [k for k in intf_facts.keys() if re.match(phy_port, k)]
phy_intfs = natsorted(phy_intfs)
logging.info("physical interfaces = {}".format(phy_intfs))
if logical_intfs is None:
intf_facts = duthost.interface_facts()['ansible_facts']['ansible_interface_facts']
phy_port = re.compile(r'^Ethernet\d+$')
logical_intfs = [k for k in intf_facts.keys() if re.match(phy_port, k)]
logical_intfs = natsorted(logical_intfs)
logging.info("physical interfaces = {}".format(logical_intfs))

for asic_index in duthost.get_frontend_asic_ids():
# Get interfaces of this asic
interface_list = get_port_map(duthost, asic_index)
interfaces_per_asic = {k:v for k, v in interface_list.items() if k in phy_intfs}
interfaces_per_asic = {k:v for k, v in interface_list.items() if k in logical_intfs}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a chat with Guohan about this. I think the main issue is that we are running SFP test against disabled (admin down) ports. If we could skip the admin down ports, that would be a much easier and generic solution.

can you update PR with that approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we are passing all interfaces which are in conn_graph_facts that are based on the connection graph and will not include 'admin' down' port. get_physical_port_indices() is a helper function which will give indices for the input list of logical interfaces. The list of interfaces is formed in setup() fixture in test_sfp.py

#logging.info("ASIC index={} interfaces = {}".format(asic_index, interfaces_per_asic))
for intf in interfaces_per_asic:
if asic_index is not None:
cmd = 'sonic-db-cli -n asic{} CONFIG_DB HGET "PORT|{}" index'.format(asic_index, intf)
else:
cmd = 'sonic-db-cli CONFIG_DB HGET "PORT|{}" index'.format(intf)
index = duthost.command(cmd)["stdout"]
physical_port_indices.add(int(index))
#logging.info("$$$ physical port indices = {}".format(physical_port_indices))
return list(physical_port_indices)
physical_port_index_dict[intf] = (int(index))

return physical_port_index_dict
Loading