diff --git a/tests/platform_tests/api/test_sfp.py b/tests/platform_tests/api/test_sfp.py index e4111b1c4cf..73cbba8ddcf 100644 --- a/tests/platform_tests/api/test_sfp.py +++ b/tests/platform_tests/api/test_sfp.py @@ -46,7 +46,6 @@ class TestSfpApi(PlatformApiTestBase): EXPECTED_XCVR_INFO_KEYS = [ 'type', - 'type_abbrv_name', 'manufacturer', 'model', 'hardware_rev', @@ -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 = [ @@ -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()