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 API][SFP] Log warnings, don't fail test if newly-added xcvr info fields missing #3120

Merged
merged 1 commit into from
Mar 11, 2021
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
25 changes: 22 additions & 3 deletions tests/platform_tests/api/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class TestSfpApi(PlatformApiTestBase):

EXPECTED_XCVR_INFO_KEYS = [
'type',
'type_abbrv_name',
'manufacturer',
'model',
'hardware_rev',
Expand All @@ -61,7 +60,20 @@ class TestSfpApi(PlatformApiTestBase):
'cable_length',
'specification_compliance',
'nominal_bit_rate',
'application_advertisement'
]

# These are fields which have been added in the common parsers
# in sonic-platform-common/sonic_sfp, but since some vendors are
# using their own custom parsers, they do not yet provide these
# fields. So we treat them differently. Rather than failing the test
# if these fields are not present or 'N/A', we will simply log warnings
# until all vendors utilize the common parsers. At that point, we should
# add these into EXPECTED_XCVR_INFO_KEYS.
NEWLY_ADDED_XCVR_INFO_KEYS = [
'type_abbrv_name',
'application_advertisement',
'is_replaceable',
'dom_capability'
]

EXPECTED_XCVR_BULK_STATUS_KEYS = [
Expand Down Expand Up @@ -220,7 +232,14 @@ def test_get_transceiver_info(self, duthost, localhost, platform_api_conn):
for key in missing_keys:
self.expect(False, "Transceiver {} info does not contain field: '{}'".format(i, key))

unexpected_keys = set(actual_keys) - set(self.EXPECTED_XCVR_INFO_KEYS)
# TODO: Remove this once we can include these keys in EXPECTED_XCVR_INFO_KEYS
for key in self.NEWLY_ADDED_XCVR_INFO_KEYS:
if key not in actual_keys:
logger.warning("test_get_transceiver_info: Transceiver {} info missing field '{}'. Vendor needs to add support.".format(i, key))
elif info_dict[key] == "N/A":
logger.warning("test_get_transceiver_info: Transceiver {} info value for '{}' is 'N/A'. Vendor needs to add support.".format(i, key))

unexpected_keys = set(actual_keys) - set(self.EXPECTED_XCVR_INFO_KEYS + self.NEWLY_ADDED_XCVR_INFO_KEYS)
for key in unexpected_keys:
self.expect(False, "Transceiver {} info contains unexpected field '{}'".format(i, key))
self.assert_expectations()
Expand Down