def test_set_fans_speed(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):

        fans_skipped = 0
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        if duthost.facts["asic_type"] in ["cisco-8000"]:
            target_speed = random.randint(40, 60)
        else:
            target_speed = random.randint(1, 100)

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

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

            speed = fan.get_speed(platform_api_conn, i)
            speed_tol = fan.get_speed_tolerance(platform_api_conn, i)

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

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

        if fans_skipped == self.num_fans:
            pytest.skip("skipped as all chassis fans' speed is not controllable")

        self.assert_expectations()
    def test_set_fans_speed(self, duthost, localhost, platform_api_conn):

        target_speed = random.randint(1, 100)

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

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

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

        self.assert_expectations()
Beispiel #3
0
 def test_get_speed(self, duthost, localhost, platform_api_conn):
     # Ensure the fan speed is sane
     for i in range(self.num_fans):
         speed = fan.get_speed(platform_api_conn, i)
         if self.expect(speed is not None, "Unable to retrieve Fan {} speed".format(i)):
             if self.expect(isinstance(speed, int), "Fan {} speed appears incorrect".format(i)):
                 self.expect(speed > 0 and speed <= 100,
                             "Fan {} speed {} reading is not within range".format(i, speed))
     self.assert_expectations()
Beispiel #4
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]
        if duthost.facts["asic_type"] in ["cisco-8000"]:
            target_speed = random.randint(40, 60)
        else:
            target_speed = random.randint(1, 100)

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

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

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

        self.assert_expectations()