Skip to content

Commit

Permalink
Modify the logic that cable can be reset or not (sonic-net#6085)
Browse files Browse the repository at this point in the history
For some plaform, the SFP cable can not reset, and for some platform the cable maybe RJ45
Add the option --unresettable_xcvr_types to let customer specify the type which type can not reset

- What is the motivation for this PR?
Modify the logic for check if the cable can be reset or not

- How did you do it?
Add option --unresettable_xcvr_types to let customer specify which types are not support to reset

- How did you verify/test it?
Run the test_sfp.py::test_reset on with the SFP port, the test can pass
py.test platform_tests/api/test_sfp.py::TestSfpApi::test_reset --unresettable_xcvr_types "SFP"
py.test platform_tests/api/test_sfp.py::TestSfpApi::test_reset --unresettable_xcvr_types "SFP" --unresettable_xcvr_types "RJ45"

- Any platform specific information?
No

- Supported testbed topology if it's a new test case?
No
  • Loading branch information
nhe-NV authored and ms-junyi committed Oct 28, 2022
1 parent 30c5ce8 commit 5052eec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions tests/platform_tests/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ def check_not_implemented_warnings(duthosts, enum_rand_one_per_hwsku_hostname):
loganalyzer.match_regex.extend(['WARNING pmon#platform_api_server.py: API.+not implemented'])
loganalyzer.analyze(marker)


def pytest_addoption(parser):
parser.addoption("--unresettable_xcvr_types", action="append", default=[], help="unsupported resettable xcvr types")
11 changes: 5 additions & 6 deletions tests/platform_tests/api/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,10 @@ def is_xcvr_optical(self, xcvr_info_dict):
return False
return True

def is_xcvr_resettable(self, xcvr_info_dict):
def is_xcvr_resettable(self, request, xcvr_info_dict):
not_resettable_xcvr_type = request.config.getoption("--unresettable_xcvr_types")
xcvr_type = xcvr_info_dict.get("type_abbrv_name")
if xcvr_type == "SFP":
return False
return True
return xcvr_type not in not_resettable_xcvr_type

def is_xcvr_support_lpmode(self, xcvr_info_dict):
"""Returns True if transceiver is support low power mode, False if not supported"""
Expand Down Expand Up @@ -487,7 +486,7 @@ def test_get_tx_power(self, duthosts, enum_rand_one_per_hwsku_hostname, localhos
"Transceiver {} TX power data appears incorrect".format(i))
self.assert_expectations()

def test_reset(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
def test_reset(self, request, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
# TODO: Verify that the transceiver was actually reset
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
skip_release_for_platform(duthost, ["202012"], ["arista", "mlnx"])
Expand All @@ -498,7 +497,7 @@ def test_reset(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, plat
continue

ret = sfp.reset(platform_api_conn, i)
if self.is_xcvr_resettable(info_dict):
if self.is_xcvr_resettable(request, info_dict):
self.expect(ret is True, "Failed to reset transceiver {}".format(i))
else:
self.expect(ret is False, "Resetting transceiver {} succeeded but should have failed".format(i))
Expand Down

0 comments on commit 5052eec

Please sign in to comment.