Skip to content

Commit d6d8d9c

Browse files
authored
Modify the logic that cable can be reset or not (#6085)
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
1 parent a02fdcc commit d6d8d9c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tests/platform_tests/api/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,6 @@ def check_not_implemented_warnings(duthosts, enum_rand_one_per_hwsku_hostname):
111111
loganalyzer.match_regex.extend(['WARNING pmon#platform_api_server.py: API.+not implemented'])
112112
loganalyzer.analyze(marker)
113113

114+
115+
def pytest_addoption(parser):
116+
parser.addoption("--unresettable_xcvr_types", action="append", default=[], help="unsupported resettable xcvr types")

tests/platform_tests/api/test_sfp.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,10 @@ def is_xcvr_optical(self, xcvr_info_dict):
181181
return False
182182
return True
183183

184-
def is_xcvr_resettable(self, xcvr_info_dict):
184+
def is_xcvr_resettable(self, request, xcvr_info_dict):
185+
not_resettable_xcvr_type = request.config.getoption("--unresettable_xcvr_types")
185186
xcvr_type = xcvr_info_dict.get("type_abbrv_name")
186-
if xcvr_type == "SFP":
187-
return False
188-
return True
187+
return xcvr_type not in not_resettable_xcvr_type
189188

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

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

500499
ret = sfp.reset(platform_api_conn, i)
501-
if self.is_xcvr_resettable(info_dict):
500+
if self.is_xcvr_resettable(request, info_dict):
502501
self.expect(ret is True, "Failed to reset transceiver {}".format(i))
503502
else:
504503
self.expect(ret is False, "Resetting transceiver {} succeeded but should have failed".format(i))

0 commit comments

Comments
 (0)