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

[platform/sfp] Add test cases for SFP error status #3648

Merged
merged 4 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions tests/common/helpers/platform_api/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def get_presence(conn, index):
return sfp_api(conn, index, 'get_presence')


def get_error_description(conn, index):
return sfp_api(conn, index, 'get_error_description')


def get_model(conn, index):
return sfp_api(conn, index, 'get_model')

Expand Down
8 changes: 8 additions & 0 deletions tests/platform_tests/api/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ def test_power_override(self, duthosts, enum_rand_one_per_hwsku_hostname, localh
self.expect(power_override is False, "Transceiver {} power override data is incorrect".format(i))
self.assert_expectations()

def test_get_error_description(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
for i in self.candidate_sfp:
stephenxs marked this conversation as resolved.
Show resolved Hide resolved
error_description = sfp.get_error_description(platform_api_conn, i)
if self.expect(error_description is not None, "Unable to retrieve transceiver {} error description".format(i)):
if self.expect(isinstance(error_description, str) or isinstance(error_description, unicode), "Transceiver {} error description appears incorrect".format(i)):
self.expect(error_description == "OK", "Transceiver {} is not present".format(i))
self.assert_expectations()

def test_thermals(self, platform_api_conn):
for sfp_id in self.candidate_sfp:
try:
Expand Down
16 changes: 16 additions & 0 deletions tests/platform_tests/sfp/test_sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ def test_check_sfputil_presence(duthosts, enum_rand_one_per_hwsku_frontend_hostn
assert intf in parsed_presence, "Interface is not in output of '{}'".format(cmd_sfp_presence)
assert parsed_presence[intf] == "Present", "Interface presence is not 'Present'"

@pytest.mark.parametrize("cmd_sfp_error_status", ["sudo sfputil show error-status", "sudo sfputil show error-status --fetch-from-hardware"])
def test_check_sfputil_error_status(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_frontend_asic_index, conn_graph_facts, cmd_sfp_error_status):
"""
@summary: Check SFP error status using 'sfputil show error-status'
stephenxs marked this conversation as resolved.
Show resolved Hide resolved
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
portmap, dev_conn = get_dev_conn(duthost, conn_graph_facts, enum_frontend_asic_index)

logging.info("Check output of '{}'".format(cmd_sfp_error_status))
sfp_error_status = duthost.command(cmd_sfp_error_status)
parsed_presence = parse_output(sfp_error_status["stdout_lines"][2:])
for intf in dev_conn:
assert intf in parsed_presence, "Interface is not in output of '{}'".format(cmd_sfp_presence)
assert parsed_presence[intf] == "OK", "Interface error status is not 'OK'"
stephenxs marked this conversation as resolved.
Show resolved Hide resolved


def test_check_sfputil_eeprom(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_frontend_asic_index, conn_graph_facts):
"""
@summary: Check SFP presence using 'sfputil show presence'
Expand Down