Пример #1
0
    def test_sfps(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
                  platform_api_conn):
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        try:
            num_sfps = int(chassis.get_num_sfps(platform_api_conn))
        except:
            pytest.fail("num_sfps is not an integer")

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

        sfp_list = chassis.get_all_sfps(platform_api_conn)
        pytest_assert(sfp_list is not None, "Failed to retrieve SFPs")
        pytest_assert(
            isinstance(sfp_list, list) and len(sfp_list) == num_sfps,
            "SFPs appear to be incorrect")

        for i in range(num_sfps):
            sfp = chassis.get_sfp(platform_api_conn, i)
            self.expect(sfp and sfp == sfp_list[i],
                        "SFP {} is incorrect".format(i))
        self.assert_expectations()
Пример #2
0
    def test_sfps(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
                  platform_api_conn, physical_port_indices):
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        if duthost.is_supervisor_node():
            pytest.skip("skipping for supervisor node")
        try:
            num_sfps = int(chassis.get_num_sfps(platform_api_conn))
        except:
            pytest.fail("num_sfps is not an integer")

        list_sfps = physical_port_indices

        logging.info("Physical port indices = {}".format(list_sfps))

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

        sfp_list = chassis.get_all_sfps(platform_api_conn)
        pytest_assert(sfp_list is not None, "Failed to retrieve SFPs")
        pytest_assert(
            isinstance(sfp_list, list) and len(sfp_list) == num_sfps,
            "SFPs appear to be incorrect")

        for i in range(len(list_sfps)):
            index = list_sfps[i]
            sfp = chassis.get_sfp(platform_api_conn, index)
            self.expect(sfp and sfp in sfp_list,
                        "SFP object for PORT{} NOT found".format(index))
        self.assert_expectations()
Пример #3
0
    def test_sfps(self, duthost, localhost, platform_api_conn):
        # TODO: Ensure the number of SFPs and that the returned list is correct for this platform
        try:
            num_sfps = int(chassis.get_num_sfps(platform_api_conn))
        except:
            pytest.fail("num_sfps is not an integer")

        sfp_list = chassis.get_all_sfps(platform_api_conn)
        pytest_assert(sfp_list is not None, "Failed to retrieve SFPs")
        pytest_assert(
            isinstance(sfp_list, list) and len(sfp_list) == num_sfps,
            "SFPs appear to be incorrect")

        for i in range(num_sfps):
            sfp = chassis.get_sfp(platform_api_conn, i)
            self.expect(sfp and sfp == sfp_list[i],
                        "SFP {} is incorrect".format(i))
        self.assert_expectations()
Пример #4
0
    def test_sfps(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
                  platform_api_conn):
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        if duthost.is_supervisor_node():
            pytest.skip("skipping for supervisor node")
        try:
            num_sfps = int(chassis.get_num_sfps(platform_api_conn))
        except:
            pytest.fail("num_sfps is not an integer")
        list_sfps = []
        if duthost.facts.get("interfaces"):
            intfs = duthost.facts.get("interfaces")
            for intf in intfs:
                index_list = [
                    int(x) for x in duthost.facts["interfaces"][intf]
                    ['index'].split(",")
                ]
                list_sfps.extend(set(index_list))
        else:
            int_list = get_port_map(duthost, 'all')
            for k, v in int_list.items():
                list_sfps.extend(v)
        list_sfps.sort()
        if duthost.facts.get("chassis"):
            expected_num_sfps = len(duthost.facts.get("chassis").get('sfps'))
            pytest_assert(
                num_sfps == expected_num_sfps,
                "Number of sfps ({}) does not match expected number ({})".
                format(num_sfps, expected_num_sfps))

        sfp_list = chassis.get_all_sfps(platform_api_conn)
        pytest_assert(sfp_list is not None, "Failed to retrieve SFPs")
        pytest_assert(
            isinstance(sfp_list, list) and len(sfp_list) == num_sfps,
            "SFPs appear to be incorrect")

        for i in list_sfps:
            sfp = chassis.get_sfp(platform_api_conn, i)
            self.expect(sfp and sfp == sfp_list[i],
                        "SFP {} is incorrect".format(i))
        self.assert_expectations()
Пример #5
0
    def test_sfps(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost,
                  platform_api_conn, physical_port_indices):
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        if duthost.is_supervisor_node():
            pytest.skip("skipping for supervisor node")
        try:
            num_sfps = int(chassis.get_num_sfps(platform_api_conn))
        except:
            pytest.fail("num_sfps is not an integer")
        else:
            if num_sfps == 0:
                pytest.skip("No sfps found on device")

        list_sfps = physical_port_indices

        logging.info("Physical port indices = {}".format(list_sfps))

        if duthost.facts.get("chassis"):
            expected_num_sfps = len(duthost.facts.get("chassis").get('sfps'))
            if duthost.facts.get("platform") == 'x86_64-nvidia_sn2201-r0':
                # On SN2201, there are 48 RJ45 ports which are also counted in SFP object lists
                # So we need to adjust test case accordingly
                expected_num_sfps += 48
            pytest_assert(
                num_sfps == expected_num_sfps,
                "Number of sfps ({}) does not match expected number ({})".
                format(num_sfps, expected_num_sfps))

        sfp_list = chassis.get_all_sfps(platform_api_conn)
        pytest_assert(sfp_list is not None, "Failed to retrieve SFPs")
        pytest_assert(
            isinstance(sfp_list, list) and len(sfp_list) == num_sfps,
            "SFPs appear to be incorrect")

        for i in range(len(list_sfps)):
            index = list_sfps[i]
            sfp = chassis.get_sfp(platform_api_conn, index)
            self.expect(sfp and sfp in sfp_list,
                        "SFP object for PORT{} NOT found".format(index))
        self.assert_expectations()