Exemplo n.º 1
0
    def test_set_fans_led(self, duthosts, enum_rand_one_per_hwsku_hostname,
                          localhost, platform_api_conn):
        LED_COLOR_LIST = [
            "off",
            "red",
            "amber",
            "green",
        ]

        for i in range(self.num_fans):
            for color in LED_COLOR_LIST:

                result = fan.set_status_led(platform_api_conn, i, color)
                if self.expect(result is not None,
                               "Failed to perform set_status_led"):
                    self.expect(
                        result is True,
                        "Failed to set status_led for fan {} to {}".format(
                            i, color))

                color_actual = fan.get_status_led(platform_api_conn, i)

                if self.expect(color_actual is not None,
                               "Failed to retrieve status_led"):
                    if self.expect(isinstance(color_actual, STRING_TYPE),
                                   "Status LED color appears incorrect"):
                        self.expect(
                            color == color_actual,
                            "Status LED color incorrect (expected: {}, actual: {} for fan {})"
                            .format(color, color_actual, i))

        self.assert_expectations()
Exemplo n.º 2
0
    def test_set_fans_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
        LED_COLOR_LIST = [
            "off",
            "red",
            "amber",
            "green",
        ]
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        fans_skipped = 0

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

            LED_COLOR_LIST = self.get_fan_facts(duthost, i, LED_COLOR_LIST, "status_led", "colors")
            for color in LED_COLOR_LIST:

                result = fan.set_status_led(platform_api_conn, i, color)
                if self.expect(result is not None, "Failed to perform set_status_led"):
                    self.expect(result is True, "Failed to set status_led for fan {} to {}".format(i, color))

                color_actual = fan.get_status_led(platform_api_conn, i)

                if self.expect(color_actual is not None, "Failed to retrieve status_led"):
                    if self.expect(isinstance(color_actual, STRING_TYPE), "Status LED color appears incorrect"):
                        self.expect(color == color_actual, "Status LED color incorrect (expected: {}, actual: {} for fan {})".format(
                            color, color_actual, i))

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

        self.assert_expectations()
Exemplo n.º 3
0
    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)

            led_status = fan.get_status_led(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()