Skip to content

Commit 57a0eaf

Browse files
Junchao-Mellanoxmssonicbld
authored andcommitted
[Mellanox] Ignore checking ASIC/module temperature if thermal updater is there (#11165)
- Why I did it thermal updater is a thread which will update ASIC/module thermal sysfs nodes periodically. Currently, there is no way to stop thermal updater. So, there is no easy way to mock thermal sysfs value if thermal updater is there (thermal updater will always override mocked values). - How I did it Ignore ASIC/module thermal mock test if thermal updater is present - How to verify it Manual test sonic-mgmt regression test
1 parent 8983081 commit 57a0eaf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/platform_tests/mellanox/mellanox_thermal_control_test_helper.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import json
3+
import re
34
import random
45
import logging
56
import time
@@ -404,6 +405,11 @@ def is_201911(self):
404405
else:
405406
return True
406407

408+
def has_thermal_updater(self):
409+
cmd = 'python3 -c "from sonic_platform import thermal_updater"'
410+
out = self.dut.shell(cmd, module_ignore_errors=True)
411+
return not out['failed']
412+
407413

408414
class FanDrawerData:
409415
"""
@@ -807,6 +813,8 @@ def check_result(self, actual_data):
807813
"""
808814
expected = {}
809815
for name, fields in list(self.expected_data.items()):
816+
if self.excluded_entry_pattern and re.search(self.excluded_entry_pattern, name):
817+
continue
810818
data = {}
811819
for idx, header in enumerate(self.expected_data_headers):
812820
data[header] = fields[idx]
@@ -819,6 +827,8 @@ def check_result(self, actual_data):
819827
mismatch_in_actual_data = []
820828
for actual_data_item in actual_data:
821829
primary = actual_data_item[self.primary_field]
830+
if self.excluded_entry_pattern and re.search(self.excluded_entry_pattern, primary):
831+
continue
822832
if primary not in expected:
823833
extra_in_actual_data.append(actual_data_item)
824834
else:
@@ -869,6 +879,7 @@ def __init__(self, dut):
869879
'drawer', 'led', 'fan', 'speed', 'direction', 'presence', 'status']
870880
self.primary_field = 'fan'
871881
self.excluded_fields = ['timestamp', ]
882+
self.excluded_entry_pattern = None
872883

873884
def deinit(self):
874885
"""
@@ -1023,6 +1034,13 @@ def __init__(self, dut):
10231034
'warning']
10241035
self.primary_field = 'sensor'
10251036
self.excluded_fields = ['timestamp', ]
1037+
if self.mock_helper.has_thermal_updater():
1038+
# if thermal updater is there, ASIC and module temperature are read from SDK sysfs.
1039+
# There is no way to mock SDK sysfs because it is created by kernel (user space has
1040+
# no permission to change it). So, we just ignore it for checking.
1041+
self.excluded_entry_pattern = re.compile(r"ASIC|(xSFP module \d+ Temp)")
1042+
else:
1043+
self.excluded_entry_pattern = None
10261044

10271045
def deinit(self):
10281046
"""

0 commit comments

Comments
 (0)