Skip to content

Commit

Permalink
[Platform API] : modified test_sfp for 400G ports (#3888)
Browse files Browse the repository at this point in the history
- For QSFD-DD, transceiver type is mapped as active or passive under specification compliance.
Modified script for this change.
- for Tx-bias , included check to verify whether the transceiver is optical .
  • Loading branch information
chitra-raghavan authored Jul 31, 2021
1 parent 28da508 commit 4e1bba1
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tests/platform_tests/api/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,20 @@ def compare_value_with_platform_facts(self, key, value, sfp_idx, duthost):

def is_xcvr_optical(self, xcvr_info_dict):
"""Returns True if transceiver is optical, False if copper (DAC)"""
spec_compliance_dict = ast.literal_eval(xcvr_info_dict["specification_compliance"])
compliance_code = spec_compliance_dict.get("10/40G Ethernet Compliance Code")
if compliance_code == "40GBASE-CR4":
return False
#For QSFP-DD specification compliance will return type as passive or active
if xcvr_info_dict["type_abbrv_name"] == "QSFP-DD":
if xcvr_info_dict["specification_compliance"] == "passive_copper_media_interface":
return False
else:
spec_compliance_dict = ast.literal_eval(xcvr_info_dict["specification_compliance"])
if xcvr_info_dict["type_abbrv_name"] == "SFP":
compliance_code = spec_compliance_dict.get("SFP+CableTechnology")
if compliance_code == "Passive Cable":
return False
else:
compliance_code = spec_compliance_dict.get("10/40G Ethernet Compliance Code")
if compliance_code == "40GBASE-CR4":
return False
return True

def is_xcvr_resettable(self, xcvr_info_dict):
Expand Down Expand Up @@ -335,6 +345,11 @@ def test_get_voltage(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost
def test_get_tx_bias(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
# TODO: Do more sanity checking on the data we retrieve
for i in self.candidate_sfp:
info_dict = sfp.get_transceiver_info(platform_api_conn, i)
# Determine whether the transceiver type supports TX Bias
if not self.is_xcvr_optical(info_dict):
logger.warning("test_get_tx_bias: Skipping transceiver {} (not applicable for this transceiver type)".format(i))
continue
tx_bias = sfp.get_tx_bias(platform_api_conn, i)
if self.expect(tx_bias is not None, "Unable to retrieve transceiver {} TX bias data".format(i)):
self.expect(isinstance(tx_bias, list) and (all(isinstance(item, float) for item in tx_bias)),
Expand Down

0 comments on commit 4e1bba1

Please sign in to comment.