|
15 | 15 | from tests.common.fixtures.conn_graph_facts import conn_graph_facts # noqa F401 |
16 | 16 | from tests.common.fixtures.duthost_utils import shutdown_ebgp # noqa F401 |
17 | 17 | from tests.common.platform.device_utils import platform_api_conn # noqa F401 |
| 18 | +from tests.common.platform.transceiver_utils import is_sw_control_enabled,\ |
| 19 | + get_port_expected_error_state_for_mellanox_device_on_sw_control_enabled |
| 20 | +from tests.common.mellanox_data import is_mellanox_device |
| 21 | +from collections import defaultdict |
| 22 | + |
18 | 23 |
|
19 | 24 | from .platform_api_test_base import PlatformApiTestBase |
20 | 25 |
|
@@ -52,6 +57,10 @@ def setup(request, duthosts, enum_rand_one_per_hwsku_hostname, |
52 | 57 | physical_port_index_map = get_physical_port_indices(duthost, physical_intfs) |
53 | 58 | sfp_setup["physical_port_index_map"] = physical_port_index_map |
54 | 59 |
|
| 60 | + sfp_setup["index_physical_port_map"] = defaultdict(list) |
| 61 | + for port, index in physical_port_index_map.items(): |
| 62 | + sfp_setup["index_physical_port_map"][index].append(port) |
| 63 | + |
55 | 64 | sfp_port_indices = set([physical_port_index_map[intf] for intf in list(physical_port_index_map.keys())]) |
56 | 65 | sfp_setup["sfp_port_indices"] = sorted(sfp_port_indices) |
57 | 66 |
|
@@ -906,24 +915,33 @@ def test_power_override(self, duthosts, enum_rand_one_per_hwsku_hostname, localh |
906 | 915 | "Transceiver {} power override data is incorrect".format(i)) |
907 | 916 | self.assert_expectations() |
908 | 917 |
|
| 918 | + @pytest.mark.device_type('physical') |
909 | 919 | def test_get_error_description(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, |
910 | | - platform_api_conn): # noqa F811 |
| 920 | + platform_api_conn, passive_cable_ports, cmis_cable_ports_and_ver): # noqa F811 |
911 | 921 | """This function tests get_error_description() API (supported on 202106 and above)""" |
912 | | - skip_release(duthosts[enum_rand_one_per_hwsku_hostname], ["201811", "201911", "202012"]) |
| 922 | + duthost = duthosts[enum_rand_one_per_hwsku_hostname] |
| 923 | + skip_release(duthost, ["201811", "201911", "202012"]) |
913 | 924 |
|
914 | 925 | for i in self.sfp_setup["sfp_test_port_indices"]: |
915 | 926 | error_description = sfp.get_error_description(platform_api_conn, i) |
916 | 927 | if self.expect(error_description is not None, |
917 | 928 | "Unable to retrieve transceiver {} error description".format(i)): |
918 | 929 | if "Not implemented" in error_description: |
919 | 930 | pytest.skip("get_error_description isn't implemented. Skip the test") |
920 | | - if "Not supported" in error_description: |
| 931 | + |
| 932 | + expected_state = 'OK' |
| 933 | + if is_mellanox_device(duthost) and is_sw_control_enabled(duthost, i): |
| 934 | + intf = self.sfp_setup["index_physical_port_map"][i][0] |
| 935 | + expected_state = get_port_expected_error_state_for_mellanox_device_on_sw_control_enabled( |
| 936 | + intf, passive_cable_ports[duthost.hostname], cmis_cable_ports_and_ver[duthost.hostname]) |
| 937 | + elif "Not supported" in error_description: |
921 | 938 | logger.warning("test_get_error_description: Skipping transceiver {} as error description not " |
922 | 939 | "supported on this port)".format(i)) |
923 | 940 | continue |
924 | 941 | if self.expect(isinstance(error_description, str) or isinstance(error_description, str), |
925 | 942 | "Transceiver {} error description appears incorrect".format(i)): |
926 | | - self.expect(error_description == "OK", "Transceiver {} is not present".format(i)) |
| 943 | + self.expect(error_description == expected_state, |
| 944 | + f"Transceiver {i} is not {expected_state}, actual state is:{error_description}.") |
927 | 945 | self.assert_expectations() |
928 | 946 |
|
929 | 947 | def test_thermals(self, platform_api_conn): # noqa F811 |
|
0 commit comments