|
10 | 10 | from tests.common.utilities import wait_until |
11 | 11 | from tests.common.fixtures.conn_graph_facts import conn_graph_facts # noqa F401 |
12 | 12 | from tests.common.fixtures.duthost_utils import shutdown_ebgp # noqa F401 |
| 13 | +from tests.common.platform.transceiver_utils import is_sw_control_enabled,\ |
| 14 | + get_port_expected_error_state_for_mellanox_device_on_sw_control_enabled |
| 15 | +from tests.common.mellanox_data import is_mellanox_device |
| 16 | +from collections import defaultdict |
13 | 17 |
|
14 | 18 | from .platform_api_test_base import PlatformApiTestBase |
15 | 19 |
|
@@ -47,6 +51,10 @@ def setup(request, duthosts, enum_rand_one_per_hwsku_hostname, |
47 | 51 | physical_port_index_map = get_physical_port_indices(duthost, physical_intfs) |
48 | 52 | sfp_setup["physical_port_index_map"] = physical_port_index_map |
49 | 53 |
|
| 54 | + sfp_setup["index_physical_port_map"] = defaultdict(list) |
| 55 | + for port, index in physical_port_index_map.items(): |
| 56 | + sfp_setup["index_physical_port_map"][index].append(port) |
| 57 | + |
50 | 58 | sfp_port_indices = set([physical_port_index_map[intf] for intf in list(physical_port_index_map.keys())]) |
51 | 59 | sfp_setup["sfp_port_indices"] = sorted(sfp_port_indices) |
52 | 60 |
|
@@ -846,23 +854,33 @@ def test_power_override(self, duthosts, enum_rand_one_per_hwsku_hostname, localh |
846 | 854 | "Transceiver {} power override data is incorrect".format(i)) |
847 | 855 | self.assert_expectations() |
848 | 856 |
|
849 | | - def test_get_error_description(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): |
| 857 | + @pytest.mark.device_type('physical') |
| 858 | + def test_get_error_description(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, |
| 859 | + platform_api_conn, passive_cable_ports, cmis_cable_ports_and_ver): # noqa F811 |
850 | 860 | """This function tests get_error_description() API (supported on 202106 and above)""" |
851 | | - skip_release(duthosts[enum_rand_one_per_hwsku_hostname], ["201811", "201911", "202012"]) |
| 861 | + duthost = duthosts[enum_rand_one_per_hwsku_hostname] |
| 862 | + skip_release(duthost, ["201811", "201911", "202012"]) |
852 | 863 |
|
853 | 864 | for i in self.sfp_setup["sfp_test_port_indices"]: |
854 | 865 | error_description = sfp.get_error_description(platform_api_conn, i) |
855 | 866 | if self.expect(error_description is not None, |
856 | 867 | "Unable to retrieve transceiver {} error description".format(i)): |
857 | 868 | if "Not implemented" in error_description: |
858 | 869 | pytest.skip("get_error_description isn't implemented. Skip the test") |
859 | | - if "Not supported" in error_description: |
| 870 | + |
| 871 | + expected_state = 'OK' |
| 872 | + if is_mellanox_device(duthost) and is_sw_control_enabled(duthost, i): |
| 873 | + intf = self.sfp_setup["index_physical_port_map"][i][0] |
| 874 | + expected_state = get_port_expected_error_state_for_mellanox_device_on_sw_control_enabled( |
| 875 | + intf, passive_cable_ports[duthost.hostname], cmis_cable_ports_and_ver[duthost.hostname]) |
| 876 | + elif "Not supported" in error_description: |
860 | 877 | logger.warning("test_get_error_description: Skipping transceiver {} as error description not " |
861 | 878 | "supported on this port)".format(i)) |
862 | 879 | continue |
863 | 880 | if self.expect(isinstance(error_description, str) or isinstance(error_description, str), |
864 | 881 | "Transceiver {} error description appears incorrect".format(i)): |
865 | | - self.expect(error_description == "OK", "Transceiver {} is not present".format(i)) |
| 882 | + self.expect(error_description == expected_state, |
| 883 | + f"Transceiver {i} is not {expected_state}, actual state is:{error_description}.") |
866 | 884 | self.assert_expectations() |
867 | 885 |
|
868 | 886 | def test_thermals(self, platform_api_conn): |
|
0 commit comments