def test_get_fans_speed_tolerance(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): speed_tolerance = fan_drawer_fan.get_speed_tolerance(platform_api_conn, j, i) if self.expect(speed_tolerance is not None, "Unable to retrieve fan drawer {} fan {} speed tolerance".format(j, i)): if self.expect(isinstance(speed_tolerance, int), "Fan drawer {} fan {} speed tolerance appears incorrect".format(j, i)): self.expect(speed_tolerance > 0 and speed_tolerance <= 100, "Fan drawer {} fan {} speed tolerance {} reading does not make sense".format(j, i, speed_tolerance)) self.assert_expectations()
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()
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()