def test_get_fans_target_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): speed_target_val = 25 speed_set = fan_drawer_fan.set_speed(platform_api_conn, j, i, speed_target_val) target_speed = fan_drawer_fan.get_target_speed( platform_api_conn, j, i) if self.expect( target_speed is not None, "Unable to retrieve Fan drawer {} fan {} target speed". format(j, i)): if self.expect( isinstance(target_speed, int), "Fan drawer {} fan {} target speed appears incorrect" .format(j, i)): self.expect( target_speed == speed_target_val, "Fan drawer {} fan {} target speed setting is not correct, speed_target_val {} target_speed = {}" .format(j, i, speed_target_val, target_speed)) self.assert_expectations()
def test_get_fans_target_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): num_fans = fan_drawer.get_num_fans(platform_api_conn, j) fans_skipped = 0 for i in range(num_fans): speed_target_val = 25 speed_controllable = self.get_fan_facts( duthost, j, i, True, "speed", "controllable") if not speed_controllable: logger.info( "test_get_fans_target_speed: Skipping fandrawer {} fan {} (speed not controllable)" .format(j, i)) fans_skipped += 1 continue speed_minimum = self.get_fan_facts(duthost, j, i, 25, "speed", "minimum") speed_maximum = self.get_fan_facts(duthost, j, i, 100, "speed", "maximum") if speed_minimum > speed_target_val or speed_maximum < speed_target_val: speed_target_val = random.randint(speed_minimum, speed_maximum) speed_set = fan_drawer_fan.set_speed(platform_api_conn, j, i, speed_target_val) target_speed = fan_drawer_fan.get_target_speed( platform_api_conn, j, i) if self.expect( target_speed is not None, "Unable to retrieve Fan drawer {} fan {} target speed". format(j, i)): if self.expect( isinstance(target_speed, int), "Fan drawer {} fan {} target speed appears incorrect" .format(j, i)): self.expect( target_speed == speed_target_val, "Fan drawer {} fan {} target speed setting is not correct, speed_target_val {} target_speed = {}" .format(j, i, speed_target_val, target_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()