@@ -88,17 +88,29 @@ def check_transceiver_details(dut, asic_index, interfaces, xcvr_skip_list):
8888 else :
8989 expected_fields = ["type" , "vendor_rev" , "serial" , "manufacturer" , "model" ]
9090
91+ cmd_keys = 'sonic-db-cli STATE_DB KEYS "TRANSCEIVER_INFO|Ethernet*"'
92+ cmd_hgetall = 'sonic-db-cli STATE_DB HGETALL $key'
93+ docker_cmd_keys = asichost .get_docker_cmd (cmd_keys , "database" )
94+ docker_cmd_hgetall = asichost .get_docker_cmd (cmd_hgetall , "database" )
95+
96+ docker_cmd = f'for key in $({ docker_cmd_keys } ); do echo "$key : $({ docker_cmd_hgetall } )" ; done'
97+ port_xcvr_info = dut .command (docker_cmd , _uses_shell = True )
98+ port_xcvr_info_dict = {}
99+ for line in port_xcvr_info ["stdout_lines" ]:
100+ key , value = line .split (":" , 1 )
101+ intf_name = key .split ('|' )[1 ].strip ()
102+ port_xcvr_info_dict [intf_name ] = value .strip ()
103+
91104 for intf in interfaces :
92105 if intf not in xcvr_skip_list [dut .hostname ]:
93- cmd = 'redis-cli -n 6 hgetall "TRANSCEIVER_INFO|%s"' % intf
94- docker_cmd = asichost .get_docker_cmd (cmd , "database" )
95- port_xcvr_info = dut .command (docker_cmd )
106+ port_xcvr_info_value = port_xcvr_info_dict [intf ]
96107 for field in expected_fields :
97- assert port_xcvr_info [ "stdout" ] .find (field ) >= 0 , \
98- "Expected field %s is not found in %s while checking %s" % (field , port_xcvr_info [ "stdout" ] , intf )
108+ assert port_xcvr_info_value .find (field ) >= 0 , \
109+ "Expected field %s is not found in %s while checking %s" % (field , port_xcvr_info_value , intf )
99110
100111
101- def check_transceiver_dom_sensor_basic (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory ):
112+ def check_transceiver_dom_sensor_basic (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory ,
113+ lport_to_first_subport_mapping ):
102114 """
103115 @summary: Check whether all the specified interface are in TRANSCEIVER_DOM_SENSOR redis DB.
104116 @param dut: The AnsibleHost object of DUT. For interacting with DUT.
@@ -112,10 +124,13 @@ def check_transceiver_dom_sensor_basic(dut, asic_index, interfaces, xcvr_skip_li
112124 parsed_xcvr_dom_sensor = parse_transceiver_dom_sensor (xcvr_dom_sensor ["stdout_lines" ])
113125 for intf in interfaces :
114126 if intf not in xcvr_skip_list [dut .hostname ] + port_list_with_flat_memory [dut .hostname ]:
115- assert intf in parsed_xcvr_dom_sensor , "TRANSCEIVER_DOM_SENSOR of %s is not found in DB" % intf
127+ assert lport_to_first_subport_mapping [intf ] in parsed_xcvr_dom_sensor ,\
128+ "TRANSCEIVER_DOM_SENSOR of subport %s of %s port is not found in DB" \
129+ % (lport_to_first_subport_mapping [intf ], intf )
116130
117131
118- def check_transceiver_dom_sensor_details (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory ):
132+ def check_transceiver_dom_sensor_details (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory ,
133+ lport_to_first_subport_mapping ):
119134 """
120135 @summary: Check the detailed TRANSCEIVER_DOM_SENSOR content of all the specified interfaces.
121136 @param dut: The AnsibleHost object of DUT. For interacting with DUT.
@@ -125,27 +140,44 @@ def check_transceiver_dom_sensor_details(dut, asic_index, interfaces, xcvr_skip_
125140 asichost = dut .asic_instance (asic_index )
126141 expected_fields = ["temperature" , "voltage" , "rx1power" , "rx2power" , "rx3power" , "rx4power" , "tx1bias" ,
127142 "tx2bias" , "tx3bias" , "tx4bias" , "tx1power" , "tx2power" , "tx3power" , "tx4power" ]
143+
144+ cmd_keys = 'sonic-db-cli STATE_DB KEYS "TRANSCEIVER_DOM_SENSOR|Ethernet*"'
145+ cmd_hgetall = 'sonic-db-cli STATE_DB HGETALL $key'
146+ docker_cmd_keys = asichost .get_docker_cmd (cmd_keys , "database" )
147+ docker_cmd_hgetall = asichost .get_docker_cmd (cmd_hgetall , "database" )
148+
149+ docker_cmd = f'for key in $({ docker_cmd_keys } ); do echo "$key : $({ docker_cmd_hgetall } )" ; done'
150+ port_xcvr_dom_sensor = dut .command (docker_cmd , _uses_shell = True )
151+
152+ port_xcvr_dom_dict = {}
153+ for line in port_xcvr_dom_sensor ["stdout_lines" ]:
154+ key , value = line .split (":" , 1 )
155+ intf_name = key .split ('|' )[1 ].strip ()
156+ port_xcvr_dom_dict [intf_name ] = value .strip ()
157+
128158 for intf in interfaces :
129159 if intf not in xcvr_skip_list [dut .hostname ] + port_list_with_flat_memory [dut .hostname ]:
130- cmd = 'redis-cli -n 6 hgetall "TRANSCEIVER_DOM_SENSOR|%s"' % intf
131- docker_cmd = asichost .get_docker_cmd (cmd , "database" )
132- port_xcvr_dom_sensor = dut .command (docker_cmd )
160+ first_subport = lport_to_first_subport_mapping [intf ]
161+ port_xcvr_dom_value = port_xcvr_dom_dict [first_subport ]
133162 for field in expected_fields :
134- assert port_xcvr_dom_sensor [ "stdout" ] .find (field ) >= 0 , \
163+ assert port_xcvr_dom_value .find (field ) >= 0 , \
135164 "Expected field %s is not found in %s while checking %s" % (
136- field , port_xcvr_dom_sensor [ "stdout" ] , intf )
165+ field , port_xcvr_dom_value , intf )
137166
138167
139- def check_transceiver_status (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory ):
168+ def check_transceiver_status (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory ,
169+ lport_to_first_subport_mapping ):
140170 """
141171 @summary: Check transceiver information of all the specified interfaces in redis DB.
142172 @param dut: The AnsibleHost object of DUT. For interacting with DUT.
143173 @param interfaces: List of interfaces that need to be checked.
144174 """
145175 check_transceiver_basic (dut , asic_index , interfaces , xcvr_skip_list )
146176 check_transceiver_details (dut , asic_index , interfaces , xcvr_skip_list )
147- check_transceiver_dom_sensor_basic (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory )
148- check_transceiver_dom_sensor_details (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory )
177+ check_transceiver_dom_sensor_basic (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory ,
178+ lport_to_first_subport_mapping )
179+ check_transceiver_dom_sensor_details (dut , asic_index , interfaces , xcvr_skip_list , port_list_with_flat_memory ,
180+ lport_to_first_subport_mapping )
149181
150182
151183def get_sfp_eeprom_map_per_port (eeprom_infos ):
0 commit comments