Skip to content

Commit dbd2e51

Browse files
committed
Enhancement of test_sensors.py to address several issues
Details: 1. Updated PSU mapping of msn4600-r0 platform. 2. Updated test to support both Forward (PSF) and Reversed (PSR) versions of each PSU Model. 3. Added support to PSU Model MTEF-AC-G.
1 parent 5d30c62 commit dbd2e51

File tree

4 files changed

+134
-16
lines changed

4 files changed

+134
-16
lines changed

tests/platform_tests/sensors_utils/psu_data.yaml

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sensors_checks:
2-
MTEF-PSF-AC-A:
2+
MTEF-AC-A:
33
alarms:
44
fan:
55
- dps460-i2c-*-*/PSU-* Fan 1/fan1_alarm
@@ -29,7 +29,7 @@ sensors_checks:
2929
temp: [ ]
3030
psu_skips: { }
3131
sensor_skip_per_version: { }
32-
MTEF-PSF-AC-C:
32+
MTEF-AC-C:
3333
alarms:
3434
fan:
3535
- dps460-i2c-*-*/PSU-* Fan 1/fan1_alarm
@@ -80,7 +80,7 @@ sensors_checks:
8080
temp: [ ]
8181
psu_skips: { }
8282
sensor_skip_per_version: { }
83-
MTEF-PSF-AC-E:
83+
MTEF-AC-E:
8484
alarms:
8585
fan:
8686
- dps460-i2c-*-*/PSU-* Fan 1/fan1_alarm
@@ -110,7 +110,7 @@ sensors_checks:
110110
temp: [ ]
111111
psu_skips: { }
112112
sensor_skip_per_version: { }
113-
MTEF-PSF-AC-F:
113+
MTEF-AC-F:
114114
alarms:
115115
fan:
116116
- dps460-i2c-*-*/PSU-* Fan 1/fan1_alarm
@@ -153,7 +153,7 @@ sensors_checks:
153153
temp: [ ]
154154
psu_skips: { }
155155
sensor_skip_per_version: { }
156-
MTEF-PSF-AC-M:
156+
MTEF-AC-M:
157157
alarms:
158158
fan:
159159
- pmbus-i2c-*-*/PSU-* Fan1/fan1_alarm
@@ -239,3 +239,75 @@ sensors_checks:
239239
temp: [ ]
240240
psu_skips: { }
241241
sensor_skip_per_version: { }
242+
MTEF-AC-C-SS1:
243+
alarms:
244+
fan:
245+
- dps460-i2c-*-*/PSU-* Fan 1/fan1_alarm
246+
- dps460-i2c-*-*/PSU-* Fan 1/fan1_fault
247+
power:
248+
- dps460-i2c-*-*/PSU-* 220V Rail (in)/in1_min_alarm
249+
- dps460-i2c-*-*/PSU-* 220V Rail (in)/in1_max_alarm
250+
- dps460-i2c-*-*/PSU-* 220V Rail (in)/in1_lcrit_alarm
251+
- dps460-i2c-*-*/PSU-* 220V Rail (in)/in1_crit_alarm
252+
- dps460-i2c-*-*/PSU-* 12V Rail (out)/in3_min_alarm
253+
- dps460-i2c-*-*/PSU-* 12V Rail (out)/in3_max_alarm
254+
- dps460-i2c-*-*/PSU-* 12V Rail (out)/in3_lcrit_alarm
255+
- dps460-i2c-*-*/PSU-* 12V Rail (out)/in3_crit_alarm
256+
- dps460-i2c-*-*/PSU-* 220V Rail Pwr (in)/power1_alarm
257+
- dps460-i2c-*-*/PSU-* 12V Rail Pwr (out)/power2_max_alarm
258+
- dps460-i2c-*-*/PSU-* 12V Rail Pwr (out)/power2_crit_alarm
259+
- dps460-i2c-*-*/PSU-* 220V Rail Curr (in)/curr1_max_alarm
260+
- dps460-i2c-*-*/PSU-* 12V Rail Curr (out)/curr2_max_alarm
261+
- dps460-i2c-*-*/PSU-* 12V Rail Curr (out)/curr2_crit_alarm
262+
temp:
263+
- dps460-i2c-*-*/PSU-* Temp 1/temp1_max_alarm
264+
- dps460-i2c-*-*/PSU-* Temp 1/temp1_crit_alarm
265+
- dps460-i2c-*-*/PSU-* Temp 2/temp2_max_alarm
266+
- dps460-i2c-*-*/PSU-* Temp 2/temp2_crit_alarm
267+
- dps460-i2c-*-*/PSU-* Temp 3/temp3_max_alarm
268+
- dps460-i2c-*-*/PSU-* Temp 3/temp3_crit_alarm
269+
compares:
270+
power: [ ]
271+
temp:
272+
- - dps460-i2c-*-*/PSU-* Temp 1/temp1_input
273+
- dps460-i2c-*-*/PSU-* Temp 1/temp1_crit
274+
- - dps460-i2c-*-*/PSU-* Temp 2/temp2_input
275+
- dps460-i2c-*-*/PSU-* Temp 2/temp2_crit
276+
- - dps460-i2c-*-*/PSU-* Temp 3/temp3_input
277+
- dps460-i2c-*-*/PSU-* Temp 3/temp3_crit
278+
non_zero:
279+
fan: [ ]
280+
power: [ ]
281+
temp: [ ]
282+
psu_skips: { }
283+
sensor_skip_per_version: { }
284+
MTEF-AC-G:
285+
alarms:
286+
fan:
287+
- dps460-i2c-*-*/PSU-* Fan 1/fan1_alarm
288+
- dps460-i2c-*-*/PSU-* Fan 1/fan1_fault
289+
power:
290+
- dps460-i2c-*-*/PSU-* 220V Rail (in)/in1_alarm
291+
- dps460-i2c-*-*/PSU-* 12V Rail (out)/in2_lcrit_alarm
292+
- dps460-i2c-*-*/PSU-* 12V Rail (out)/in2_crit_alarm
293+
- dps460-i2c-*-*/PSU-* 220V Rail Pwr (in)/power1_alarm
294+
- dps460-i2c-*-*/PSU-* 12V Rail Pwr (out)/power2_max_alarm
295+
- dps460-i2c-*-*/PSU-* 220V Rail Curr (in)/curr1_max_alarm
296+
- dps460-i2c-*-*/PSU-* 12V Rail Curr (out)/curr2_max_alarm
297+
- dps460-i2c-*-*/PSU-* 12V Rail Curr (out)/curr2_lcrit_alarm
298+
temp:
299+
- dps460-i2c-*-*/PSU-* Temp 1/temp1_max_alarm
300+
- dps460-i2c-*-*/PSU-* Temp 2/temp2_max_alarm
301+
compares:
302+
power: [ ]
303+
temp:
304+
- - dps460-i2c-*-*/PSU-* Temp 1/temp1_input
305+
- dps460-i2c-*-*/PSU-* Temp 1/temp1_max
306+
- - dps460-i2c-*-*/PSU-* Temp 2/temp2_input
307+
- dps460-i2c-*-*/PSU-* Temp 2/temp2_max
308+
non_zero:
309+
fan: [ ]
310+
power: [ ]
311+
temp: [ ]
312+
psu_skips: { }
313+
sensor_skip_per_version: { }

tests/platform_tests/sensors_utils/psu_sensor_utils.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
MISSING_PSU = "N/A"
1010
PSU_NUM_SENSOR_PATTERN = r'PSU-(\d+)(?:\([A-Z]\))?'
1111
SKIPPED_CHECK_TYPES = ["psu_skips", "sensor_skip_per_version"]
12+
PSU_FAN_DIR_PATTERN = r'-(PSF|PSR)-'
13+
# PSUs in this dictionary are only supported with the specified manufacturers
14+
PSU_MANUFACTURER_SUPPORT = {'MTEF-AC-G': ['ACBEL']}
15+
VPD_DATA_PATH_FORMAT = "/var/run/hw-management/eeprom/psu{PSU_INDEX}_vpd"
16+
PSU_VPD_MANUFACTURER_FIELD = 'MFR_NAME'
1217
logger = logging.getLogger()
1318

1419

@@ -106,6 +111,20 @@ def update_sensor_data(alarm_data, psu_platform_data, psu_numbers):
106111
return updated_alarm_data
107112

108113

114+
def parse_psu_manufacturer(duthost, psu_index):
115+
"""
116+
The function parses the psu manufacturer of the psu installed at the given index from the vpd_data
117+
:param duthost: duthost fixture
118+
:param psu_index: Index of the psu
119+
:return: The psu manufacturer name as it appears in the psu vpd_data
120+
"""
121+
vpd_data_path = VPD_DATA_PATH_FORMAT.format(PSU_INDEX=psu_index)
122+
manufacturer_cmd = f"cat {vpd_data_path} | grep {PSU_VPD_MANUFACTURER_FIELD}"
123+
psu_manufacturer_line = duthost.shell(manufacturer_cmd)["stdout"]
124+
manufacturer_name_ind = 1
125+
return psu_manufacturer_line.split(':')[manufacturer_name_ind].strip()
126+
127+
109128
class SensorHelper:
110129
"""
111130
Helper class to the test_sensors tests
@@ -159,16 +178,17 @@ def read_psus_from_dut(self):
159178
self.missing_psus = set()
160179
if self.supports_dynamic_psus:
161180
psu_data = json.loads(self.duthost.shell('show platform psu --json')['stdout'])
162-
covered_psus = set(self.psu_sensors_checks.keys())
163181
for psu in psu_data:
164182
psu_index, psu_model = psu["index"], psu["model"]
165-
if psu_model in covered_psus:
166-
self.psu_dict[psu_index] = psu_model
183+
# Ignore PSR/PSF part, as we don't care if the fan is reversed (PSR) or not (PSF)
184+
psu_model_no_fan_dir = re.sub(PSU_FAN_DIR_PATTERN, '-', psu_model)
185+
if self.is_supported_psu_model(psu_index, psu_model_no_fan_dir):
186+
self.psu_dict[psu_index] = psu_model_no_fan_dir
167187
elif psu["model"] == MISSING_PSU:
168188
self.missing_psus.add(psu_index)
169189
logger.warning(f"Slot {psu_index} is missing a PSU.")
170190
else:
171-
self.uncovered_psus.add(psu_model)
191+
self.uncovered_psus.add(psu_model_no_fan_dir)
172192

173193
def platform_supports_dynamic_psu(self):
174194
"""
@@ -277,3 +297,28 @@ def parse_psu_json_mapping(self, psu_nums_to_replace, hardware_version):
277297
bus_number = bus_data[0].split('-')[1]
278298
psu_json_data[psu_num] = (bus_number, bus_address, psu_side)
279299
return psu_json_data
300+
301+
def is_supported_psu_model(self, psu_index, psu_model):
302+
"""
303+
This function returns whether the given psu_model should be supported or not
304+
:param psu_index: The index the psu is installed in
305+
:param psu_model: A psu model (without fan direction)
306+
:returns: A boolean stating whether the psu dynamic feature is supported with this psu model
307+
"""
308+
covered_psus = set(self.psu_sensors_checks.keys())
309+
310+
return psu_model in covered_psus and self.is_psu_manufacturer_supported(psu_index, psu_model)
311+
312+
def is_psu_manufacturer_supported(self, psu_index, psu_model):
313+
"""
314+
This function returns whether the given psu_model is installed with supported manufacturers
315+
:param psu_index: The index the psu is installed in
316+
:param psu_model: A psu model (without fan direction)
317+
:returns: A boolean stating whether the psu dynamic feature is supported with this psu model its manufacturer
318+
"""
319+
manufacturer_supported = True
320+
if psu_model in PSU_MANUFACTURER_SUPPORT:
321+
supported_psu_manufacturers = PSU_MANUFACTURER_SUPPORT[psu_model]
322+
psu_manufacturer = parse_psu_manufacturer(self.duthost, psu_index)
323+
manufacturer_supported &= psu_manufacturer in supported_psu_manufacturers
324+
return manufacturer_supported

tests/platform_tests/sensors_utils/psu_sensors.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@
232232
"i2c-1-mux (chan_id 3)"
233233
],
234234
"chip": {
235-
"dps460-i2c-*-58": [
235+
"dps460-i2c-*-59": [
236236
"1",
237237
"L"
238238
],
239-
"dps460-i2c-*-59": [
239+
"dps460-i2c-*-58": [
240240
"2",
241241
"R"
242242
]
@@ -282,11 +282,11 @@
282282
"i2c-1-mux (chan_id 3)"
283283
],
284284
"chip": {
285-
"dps460-i2c-*-58": [
285+
"dps460-i2c-*-59": [
286286
"1",
287287
"L"
288288
],
289-
"dps460-i2c-*-59": [
289+
"dps460-i2c-*-58": [
290290
"2",
291291
"R"
292292
]

tests/platform_tests/test_sensors.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ def update_sensors_checks(duthost, sensors_checks, hardware_version):
5353
if psu_models_to_replace:
5454
logging.info(f"Fetching PSU sensors for PSUS: {psu_models_to_replace}\n")
5555
if sensor_helper.get_uncovered_psus():
56-
logging.warning(f"Unsupported PSUs in psu-sensors-data.yml: {sensor_helper.get_uncovered_psus()}\n")
56+
logging.warning(f"Unsupported PSUs (regardless of fan direction) in psu_data.yml: "
57+
f"{sensor_helper.get_uncovered_psus()}\n")
5758

5859
sensor_helper.remove_psu_checks(sensors_checks, set(psu_models_to_replace.keys()))
5960

6061
sensor_helper.update_psu_sensors(sensors_checks, psu_models_to_replace, hardware_version)
6162
else:
62-
logging.warning(f"PSU sensors not covered by psu-sensors-data.yml. "
63-
f"Unsupported PSUs: {sensor_helper.get_uncovered_psus()}\n")
63+
logging.warning(f"PSU sensors not covered by psu_data.yml. Unsupported PSUs"
64+
f" (regardless of fan direction): {sensor_helper.get_uncovered_psus()}\n")
6465

6566

6667
def test_sensors(duthosts, rand_one_dut_hostname, sensors_data):

0 commit comments

Comments
 (0)