Esempio n. 1
0
    def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname,
                            localhost, platform_api_conn):

        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        fan_drawers_skipped = 0

        for j in range(self.num_fan_drawers):
            target_speed = random.randint(1, 100)
            num_fans = fan_drawer.get_num_fans(platform_api_conn, j)
            fans_skipped = 0

            for i in range(num_fans):
                speed_controllable = self.get_fan_facts(
                    duthost, j, i, True, "speed", "controllable")
                if not speed_controllable:
                    logger.info(
                        "test_set_fans_speed: Skipping fandrawer {} fan {} (speed not controllable)"
                        .format(j, i))
                    fans_skipped += 1
                    continue

                speed_minimum = self.get_fan_facts(duthost, j, i, 1, "speed",
                                                   "minimum")
                speed_maximum = self.get_fan_facts(duthost, j, i, 100, "speed",
                                                   "maximum")
                if speed_minimum > target_speed or speed_maximum < target_speed:
                    target_speed = random.randint(speed_minimum, speed_maximum)

                speed = fan_drawer_fan.get_speed(platform_api_conn, j, i)
                speed_tol = fan_drawer_fan.get_speed_tolerance(
                    platform_api_conn, j, i)

                speed_set = fan_drawer_fan.set_speed(platform_api_conn, j, i,
                                                     target_speed)
                time.sleep(5)

                act_speed = fan_drawer_fan.get_speed(platform_api_conn, j, i)
                self.expect(
                    abs(act_speed - target_speed) <= speed_tol,
                    "Fan drawer {} fan {} speed change from {} to {} is not within tolerance, actual speed {}"
                    .format(j, i, speed, target_speed, act_speed))

            if fans_skipped == num_fans:
                fan_drawers_skipped += 1

        if fan_drawers_skipped == self.num_fan_drawers:
            pytest.skip(
                "skipped as all fandrawer fans' speed is not controllable")

        self.assert_expectations()
Esempio n. 2
0
    def test_set_fans_speed(self, duthost, localhost, platform_api_conn):

        for j in range(self.num_fan_drawers):
            num_fans = fan_drawer.get_num_fans(platform_api_conn, j)

            target_speed = random.randint(1, 100)

            for i in range(num_fans):
                speed = fan_drawer_fan.get_speed(platform_api_conn, j, i)
                speed_tol = fan_drawer_fan.get_speed_tolerance(platform_api_conn, j, i)

                speed_set = fan_drawer_fan.set_speed(platform_api_conn, j, i, target_speed)
                time.sleep(5)

                act_speed = fan_drawer_fan.get_speed(platform_api_conn, j, i)
                self.expect(abs(act_speed - target_speed) <= speed_tol,
                            "Fan drawer {} fan {} speed change from {} to {} is not within tolerance, actual speed {}".format(j, i, speed, target_speed, act_speed))

        self.assert_expectations()
    def test_get_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):

        for j in range(self.num_fan_drawers):
            num_fans = fan_drawer.get_num_fans(platform_api_conn, j)

            for i in range(num_fans):
            # Ensure the fan speed is sane
                speed = fan_drawer_fan.get_speed(platform_api_conn, j, i)
                if self.expect(speed is not None, "Unable to retrieve Fan drawer {} fan {} speed".format(j, i)):
                    if self.expect(isinstance(speed, int), "Fan drawer {} fan {} speed appears incorrect".format(j, i)):
                        self.expect(speed > 0 and speed <= 100,
                                    "Fan drawer {} fan {} speed {} reading is not within range".format(j , i, speed))

        self.assert_expectations()