Пример #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",
        ]
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        psus_skipped = 0

        for j in range(self.num_psus):
            num_fans = psu.get_num_fans(platform_api_conn, j)
            fans_skipped = 0

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

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

                    result = psu_fan.set_status_led(platform_api_conn, j, 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 psu {} fan {} to {}".
                            format(j, i, color))

                    color_actual = psu_fan.get_status_led(
                        platform_api_conn, j, 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 num_fans != 0 and fans_skipped == num_fans:
                psus_skipped += 1

        if psus_skipped == self.num_psus:
            pytest.skip("skipped as all PSU fans' LED is not controllable")

        self.assert_expectations()
Пример #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",
        ]

        for j in range(self.num_psus):
            num_fans = psu.get_num_fans(platform_api_conn, j)

            for i in range(num_fans):

                for color in LED_COLOR_LIST:

                    result = psu_fan.set_status_led(platform_api_conn, j, 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 psu {} fan {} to {}".
                            format(j, i, color))

                    color_actual = psu_fan.get_status_led(
                        platform_api_conn, j, 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()