def test_power_override(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): """This function tests both the get_power_override() and set_power_override() APIs""" duthost = duthosts[enum_rand_one_per_hwsku_hostname] skip_release_for_platform(duthost, ["202012"], ["arista", "mlnx", "nokia"]) for i in self.sfp_setup["sfp_test_port_indices"]: info_dict = sfp.get_transceiver_info(platform_api_conn, i) if not self.expect(info_dict is not None, "Unable to retrieve transceiver {} info".format(i)): continue if not self.is_xcvr_support_power_override(info_dict): logger.warning("test_power_override: Skipping transceiver {} (not applicable for this transceiver type)".format(i)) continue # Enable power override in both low-power and high-power modes for state in [True, False]: ret = sfp.set_power_override(platform_api_conn, i, True, state) self.expect(ret is True, "Failed to {} power override for transceiver {}".format("enable" if state is True else "disable", i)) power_override = sfp.get_power_override(platform_api_conn, i) if self.expect(power_override is not None, "Unable to retrieve transceiver {} power override data".format(i)): self.expect(power_override is True, "Transceiver {} power override data is incorrect".format(i)) # Disable power override ret = sfp.set_power_override(platform_api_conn, i, False, None) self.expect(ret is True, "Failed to disable power override for transceiver {}".format(i)) power_override = sfp.get_power_override(platform_api_conn, i) if self.expect(power_override is not None, "Unable to retrieve transceiver {} power override data".format(i)): self.expect(power_override is False, "Transceiver {} power override data is incorrect".format(i)) self.assert_expectations()
def test_power_override(self, duthost, localhost, platform_api_conn): """This function tests both the get_power_override() and set_power_override() APIs""" for i in range(self.num_sfps): info_dict = sfp.get_transceiver_info(platform_api_conn, i) if not self.expect(info_dict is not None, "Unable to retrieve transceiver {} info".format(i)): continue if not self.is_xcvr_optical(info_dict): logger.warning("test_power_override: Skipping transceiver {} (not applicable for this transceiver type)".format(i)) continue # Enable power override in both low-power and high-power modes for state in [True, False]: ret = sfp.set_power_override(platform_api_conn, i, True, state) self.expect(ret is True, "Failed to {} power override for transceiver {}".format("enable" if state is True else "disable", i)) power_override = sfp.get_power_override(platform_api_conn, i) if self.expect(power_override is not None, "Unable to retrieve transceiver {} power override data".format(i)): self.expect(power_override is True, "Transceiver {} power override data is incorrect".format(i)) # Disable power override ret = sfp.set_power_override(platform_api_conn, i, False, None) self.expect(ret is True, "Failed to disable power override for transceiver {}".format(i)) power_override = sfp.get_power_override(platform_api_conn, i) if self.expect(power_override is not None, "Unable to retrieve transceiver {} power override data".format(i)): self.expect(power_override is False, "Transceiver {} power override data is incorrect".format(i)) self.assert_expectations()