예제 #1
0
    def test_lpmode(self, duthosts, enum_rand_one_per_hwsku_hostname,
                    localhost, platform_api_conn):
        """This function tests both the get_lpmode() and set_lpmode() APIs"""
        for i in self.sfp_setup["sfp_test_port_indices"]:
            # First ensure that the transceiver type supports low-power mode
            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_lpmode(info_dict):
                logger.warning(
                    "test_lpmode: Skipping transceiver {} (not applicable for this transceiver type)"
                    .format(i))
                continue

            # Enable and disable low-power mode on each transceiver
            for state in [True, False]:
                ret = sfp.set_lpmode(platform_api_conn, i, state)
                if ret is None:
                    logger.warning(
                        "test_lpmode: Skipping transceiver {} (not supported on this platform)"
                        .format(i))
                    break
                self.expect(
                    ret is True,
                    "Failed to {} low-power mode for transceiver {}".format(
                        "enable" if state is True else "disable", i))
                self.expect(
                    wait_until(5, 1, 0, self._check_lpmode_status, sfp,
                               platform_api_conn, i, state),
                    "Transceiver {} expected low-power state {} is not aligned with the real state"
                    .format(i, "enable" if state is True else "disable"))
        self.assert_expectations()
예제 #2
0
    def test_lpmode(self, duthosts, enum_rand_one_per_hwsku_hostname,
                    localhost, platform_api_conn):
        """This function tests both the get_lpmode() and set_lpmode() APIs"""
        for i in self.candidate_sfp:
            # First ensure that the transceiver type supports low-power mode
            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_lpmode: Skipping transceiver {} (not applicable for this transceiver type)"
                    .format(i))
                continue

            # Enable and disable low-power mode on each transceiver
            for state in [True, False]:
                ret = sfp.set_lpmode(platform_api_conn, i, state)
                self.expect(
                    ret is True,
                    "Failed to {} low-power mode for transceiver {}".format(
                        "enable" if state is True else "disable", i))
                lpmode = sfp.get_lpmode(platform_api_conn, i)
                if self.expect(
                        lpmode is not None,
                        "Unable to retrieve transceiver {} low-power mode".
                        format(i)):
                    self.expect(
                        lpmode == state,
                        "Transceiver {} low-power is incorrect".format(i))
        self.assert_expectations()