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
22 changes: 16 additions & 6 deletions tests/platform_tests/mellanox/test_check_sfp_using_ethtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import json
import pytest
from tests.common.fixtures.conn_graph_facts import conn_graph_facts
from tests.common.mellanox_data import SPC3_HWSKUS
from check_hw_mgmt_service import check_hw_management_service

pytestmark = [
Expand All @@ -21,17 +22,26 @@ def test_check_sfp_using_ethtool(duthost, conn_graph_facts):
ports_config = json.loads(duthost.command("sudo sonic-cfggen -d --var-json PORT")["stdout"])

logging.info("Use the ethtool to check SFP information")
if duthost.facts["hwsku"] in SPC3_HWSKUS:
lanes_divider = 8
else:
lanes_divider = 4
for intf in conn_graph_facts["device_conn"]:
intf_lanes = ports_config[intf]["lanes"]
sfp_id = int(intf_lanes.split(",")[0])/4 + 1
sfp_id = int(intf_lanes.split(",")[0])/lanes_divider + 1

ethtool_sfp_output = duthost.command("sudo ethtool -m sfp%s" % str(sfp_id))
assert ethtool_sfp_output["rc"] == 0, "Failed to read eeprom of sfp%s using ethtool" % str(sfp_id)
assert len(ethtool_sfp_output["stdout_lines"]) >= 5, \
"Does the ethtool output look normal? " + str(ethtool_sfp_output["stdout_lines"])
for line in ethtool_sfp_output["stdout_lines"]:
assert len(line.split(":")) >= 2, \
"Unexpected line %s in %s" % (line, str(ethtool_sfp_output["stdout_lines"]))
# QSFP-DD cable case (currenly ethtool not supporting a full parser)
if len(ethtool_sfp_output["stdout_lines"]) == 1:
assert '0x18' in str(ethtool_sfp_output["stdout_lines"]), \
"Does the ethtool output look normal? " + str(ethtool_sfp_output["stdout_lines"])
else:
assert len(ethtool_sfp_output["stdout_lines"]) >= 5, \
"Does the ethtool output look normal? " + str(ethtool_sfp_output["stdout_lines"])
for line in ethtool_sfp_output["stdout_lines"]:
assert len(line.split(":")) >= 2, \
"Unexpected line %s in %s" % (line, str(ethtool_sfp_output["stdout_lines"]))

logging.info("Check interface status")
mg_facts = duthost.minigraph_facts(host=duthost.hostname)["ansible_facts"]
Expand Down