def test_psus(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
                  platform_api_conn):
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        try:
            num_psus = int(chassis.get_num_psus(platform_api_conn))
        except:
            pytest.fail("num_psus is not an integer")
        else:
            if num_psus == 0:
                pytest.skip("No psus found on device")

        if duthost.facts.get("chassis"):
            expected_num_psus = len(duthost.facts.get("chassis").get('psus'))
            pytest_assert(
                num_psus == expected_num_psus,
                "Number of psus ({}) does not match expected number ({})".
                format(num_psus, expected_num_psus))

        psu_list = chassis.get_all_psus(platform_api_conn)
        pytest_assert(psu_list is not None, "Failed to retrieve PSUs")
        pytest_assert(
            isinstance(psu_list, list) and len(psu_list) == num_psus,
            "PSUs appear to be incorrect")

        for i in range(num_psus):
            psu = chassis.get_psu(platform_api_conn, i)
            self.expect(psu and psu == psu_list[i],
                        "PSU {} is incorrect".format(i))
        self.assert_expectations()
Beispiel #2
0
    def test_psus(self, duthost, localhost, platform_api_conn):
        # TODO: Ensure the number of PSUs and that the returned list is correct for this platform
        try:
            num_psus = int(chassis.get_num_psus(platform_api_conn))
        except:
            pytest.fail("num_psus is not an integer")

        psu_list = chassis.get_all_psus(platform_api_conn)
        pytest_assert(psu_list is not None, "Failed to retrieve PSUs")
        pytest_assert(
            isinstance(psu_list, list) and len(psu_list) == num_psus,
            "PSUs appear to be incorrect")

        for i in range(num_psus):
            psu = chassis.get_psu(platform_api_conn, i)
            self.expect(psu and psu == psu_list[i],
                        "PSU {} is incorrect".format(i))
        self.assert_expectations()
Beispiel #3
0
    def test_psus(self, duthost, localhost, platform_api_conn):
        try:
            num_psus = int(chassis.get_num_psus(platform_api_conn))
        except:
            pytest.fail("num_psus is not an integer")

        if self.chassis_facts:
            expected_num_psus = len(self.chassis_facts.get('psus'))
            pytest_assert(num_psus == expected_num_psus,
                          "Number of psus ({}) does not match expected number ({})"
                          .format(num_psus, expected_num_psus))

        psu_list = chassis.get_all_psus(platform_api_conn)
        pytest_assert(psu_list is not None, "Failed to retrieve PSUs")
        pytest_assert(isinstance(psu_list, list) and len(psu_list) == num_psus, "PSUs appear to be incorrect")

        for i in range(num_psus):
            psu = chassis.get_psu(platform_api_conn, i)
            self.expect(psu and psu == psu_list[i], "PSU {} is incorrect".format(i))
        self.assert_expectations()