-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mellanox] add test cases for dynamic minimum fan speed and psu fan speed policy #1552
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
201647d
[Mellanox] add test cases for dynamic minimum fan speed and psu fan s…
Junchao-Mellanox 29cc6cb
Register chassis information to avoid log analyzer error
Junchao-Mellanox 4cd5e7a
Set timeout to wait thermal control daemon restart from 5s to 30s
Junchao-Mellanox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,9 @@ | |
}, | ||
{ | ||
"type": "psu_info" | ||
}, | ||
{ | ||
"type": "chassis_info" | ||
} | ||
], | ||
"policies": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
MINIMUM_TABLE= { | ||
'ACS-MSN2700': { | ||
"p2c_trust": {"-127:40":13, "41:120":15}, | ||
"p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16}, | ||
"c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16} | ||
}, | ||
'LS-SN2700': { | ||
"p2c_trust": {"-127:40":13, "41:120":15}, | ||
"p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16}, | ||
"c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16} | ||
}, | ||
'ACS-MSN2740': { | ||
"p2c_trust": {"-127:120":13}, | ||
"p2c_untrust": {"-127:35":13, "36:40":14 , "41:120":15}, | ||
"c2p_trust": {"-127:120":13}, | ||
"c2p_untrust": {"-127:15":13, "16:30":14 , "31:35":15, "36:120":17}, | ||
"unk_trust": {"-127:120":13}, | ||
"unk_untrust": {"-127:15":13, "16:30":14 , "31:35":15, "36:120":17}, | ||
}, | ||
'ACS-MSN2410': { | ||
"p2c_trust": {"-127:40":13, "41:120":15}, | ||
"p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16}, | ||
"c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16} | ||
}, | ||
'Mellanox-SN2700': { | ||
"p2c_trust": {"-127:40":13, "41:120":15}, | ||
"p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16}, | ||
"c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16} | ||
}, | ||
'Mellanox-SN2700-D48C8': { | ||
"p2c_trust": {"-127:40":13, "41:120":15}, | ||
"p2c_untrust": {"-127:25":13, "26:30":14 , "31:35":15, "36:120":16}, | ||
"c2p_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"c2p_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_trust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16}, | ||
"unk_untrust": {"-127:20":13, "21:25":14 , "26:30":15, "31:120":16} | ||
}, | ||
'ACS-MSN2100': { | ||
"p2c_trust": {"-127:120":12}, | ||
"p2c_untrust": {"-127:15":12, "16:25":13, "26:30":14, "31:35":15, "36:120":16}, | ||
"c2p_trust": {"-127:40":12, "41:120":13}, | ||
"c2p_untrust": {"-127:40":12, "41:120":13}, | ||
"unk_trust": {"-127:40":12, "41:120":13}, | ||
"unk_untrust": {"-127:15":12, "16:25":13, "26:30":14, "31:35":15, "36:120":16} | ||
}, | ||
'ACS-MSN2010': { | ||
"p2c_trust": {"-127:120":12}, | ||
"p2c_untrust": {"-127:15":12, "16:20":13, "21:30":14, "31:35":15, "36:120":16}, | ||
"c2p_trust": {"-127:120":12}, | ||
"c2p_untrust": {"-127:20":12, "21:25":13 , "26:30":14, "31:35":15, "36:120":16}, | ||
"unk_trust": {"-127:120":12}, | ||
"unk_untrust": {"-127:15":12, "16:20":13 , "21:30":14, "31:35":15, "36:120":16} | ||
}, | ||
'ACS-MSN3700': { | ||
"p2c_trust": {"-127:25":12, "26:40":13 , "41:120":14}, | ||
"p2c_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16}, | ||
"c2p_trust": {"-127:25":12, "26:40":13 , "41:120":14}, | ||
"c2p_untrust": {"-127:25":12, "26:40":13 , "41:120":14}, | ||
"unk_trust": {"-127:25":12, "26:40":13 , "41:120":14}, | ||
"unk_untrust": {"-127:15":12, "16:30":13 , "31:35":14, "36:40":15, "41:120":16}, | ||
}, | ||
'ACS-MSN3800': { | ||
"p2c_trust": {"-127:35":12, "36:120":13}, | ||
"p2c_untrust": {"-127:0":12, "1:10":13 , "11:15":14, "16:20":15, "21:35":16, "36:120":17}, | ||
"c2p_trust": {"-127:30":12, "31:40":13 , "41:120":14}, | ||
"c2p_untrust": {"-127:20":12, "21:30":13 , "31:35":14, "36:40":15, "41:120":16}, | ||
"unk_trust": {"-127:30":12, "31:40":13 , "41:120":14}, | ||
"unk_untrust": {"-127:0":12, "1:10":13 , "11:15":14, "16:20":15, "21:35":16, "36:120":17}, | ||
}, | ||
'Mellanox-SN3800-D112C8': { | ||
"p2c_trust": {"-127:35":12, "36:120":13}, | ||
"p2c_untrust": {"-127:0":12, "1:10":13 , "11:15":14, "16:20":15, "21:35":16, "36:120":17}, | ||
"c2p_trust": {"-127:30":12, "31:40":13 , "41:120":14}, | ||
"c2p_untrust": {"-127:20":12, "21:30":13 , "31:35":14, "36:40":15, "41:120":16}, | ||
"unk_trust": {"-127:30":12, "31:40":13 , "41:120":14}, | ||
"unk_untrust": {"-127:0":12, "1:10":13 , "11:15":14, "16:20":15, "21:35":16, "36:120":17}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import logging | ||
import operator | ||
import pytest | ||
import random | ||
import time | ||
from common.mellanox_data import SWITCH_MODELS | ||
from common.plugins.loganalyzer.loganalyzer import LogAnalyzer | ||
from common.utilities import wait_until | ||
from thermal_control_test_helper import * | ||
from mellanox_thermal_control_test_helper import MockerHelper, AbnormalFanMocker | ||
|
||
THERMAL_CONTROL_TEST_WAIT_TIME = 65 | ||
THERMAL_CONTROL_TEST_CHECK_INTERVAL = 5 | ||
|
||
COOLING_CUR_STATE_PATH = '/run/hw-management/thermal/cooling_cur_state' | ||
COOLING_CUR_STATE_THRESHOLD = 7 | ||
PSU_PRESENCE_PATH = '/run/hw-management/thermal/psu{}_status' | ||
PSU_SPEED_PATH = '/run/hw-management/thermal/psu{}_fan1_speed_get' | ||
PSU_SPEED_TOLERANCE = 0.25 | ||
|
||
LOG_EXPECT_CHANGE_MIN_COOLING_LEVEL_RE = '.*Changed minimum cooling level to {}.*' | ||
|
||
|
||
@pytest.mark.disable_loganalyzer | ||
def test_dynamic_minimum_table(testbed_devices, mocker_factory): | ||
air_flow_dirs = ['p2c', 'c2p', 'unk'] | ||
max_temperature = 45000 # 45 C | ||
dut = testbed_devices['dut'] | ||
cooling_cur_state = get_cooling_cur_state(dut) | ||
if cooling_cur_state >= COOLING_CUR_STATE_THRESHOLD: | ||
pytest.skip('The cooling level {} is higher than threshold {}.'.format(cooling_cur_state, COOLING_CUR_STATE_THRESHOLD)) | ||
|
||
mocker = mocker_factory(dut, 'MinTableMocker') | ||
loganalyzer = LogAnalyzer(ansible_host=dut, marker_prefix='thermal_control') | ||
loganalyzer.load_common_config() | ||
|
||
for index in range(len(air_flow_dirs)): | ||
air_flow_index = random.randint(0, len(air_flow_dirs) - 1) | ||
air_flow_dir = air_flow_dirs[air_flow_index] | ||
air_flow_dirs.remove(air_flow_dir) | ||
temperature = random.randint(0, max_temperature) | ||
trust_state = True if random.randint(0, 1) else False | ||
logging.info('Testing with air_flow_dir={}, temperature={}, trust_state={}'.format(air_flow_dir, temperature, trust_state)) | ||
expect_minimum_cooling_level = mocker.get_expect_cooling_level(air_flow_dir, temperature, trust_state) | ||
loganalyzer.expect_regex = [LOG_EXPECT_CHANGE_MIN_COOLING_LEVEL_RE.format(expect_minimum_cooling_level)] | ||
with loganalyzer: | ||
mocker.mock_min_table(air_flow_dir, temperature, trust_state) | ||
time.sleep(THERMAL_CONTROL_TEST_WAIT_TIME) | ||
|
||
temperature = random.randint(0, max_temperature) | ||
logging.info('Testing with air_flow_dir={}, temperature={}, trust_state={}'.format(air_flow_dir, temperature, not trust_state)) | ||
expect_minimum_cooling_level = mocker.get_expect_cooling_level(air_flow_dir, temperature, not trust_state) | ||
loganalyzer.expect_regex = [LOG_EXPECT_CHANGE_MIN_COOLING_LEVEL_RE.format(expect_minimum_cooling_level)] | ||
with loganalyzer: | ||
mocker.mock_min_table(air_flow_dir, temperature, not trust_state) | ||
time.sleep(THERMAL_CONTROL_TEST_WAIT_TIME) | ||
|
||
|
||
@pytest.mark.disable_loganalyzer | ||
def test_set_psu_fan_speed(testbed_devices, mocker_factory): | ||
dut = testbed_devices['dut'] | ||
hwsku = dut.facts["hwsku"] | ||
psu_num = SWITCH_MODELS[hwsku]['psus']['number'] | ||
hot_swappable = SWITCH_MODELS[hwsku]['psus']['hot_swappable'] | ||
if not hot_swappable: | ||
pytest.skip('The SKU {} does not support this test case.'.format(hwsku)) | ||
|
||
logging.info('Create mocker, it may take a few seconds...') | ||
single_fan_mocker = mocker_factory(dut, 'SingleFanMocker') | ||
logging.info('Mock FAN absence...') | ||
single_fan_mocker.mock_absence() | ||
assert wait_until(THERMAL_CONTROL_TEST_WAIT_TIME, THERMAL_CONTROL_TEST_CHECK_INTERVAL, check_cooling_cur_state, dut, 10, operator.eq), \ | ||
'Current cooling state is {}'.format(get_cooling_cur_state(dut)) | ||
|
||
logging.info('Wait {} seconds for the policy to take effect...'.format(THERMAL_CONTROL_TEST_CHECK_INTERVAL)) | ||
time.sleep(THERMAL_CONTROL_TEST_CHECK_INTERVAL) | ||
full_speeds = [] | ||
for index in range(psu_num): | ||
speed = get_psu_speed(dut, index) | ||
full_speeds.append(speed) | ||
|
||
logging.info('Full speed={}'.format(full_speeds)) | ||
logging.info('Mock FAN presence...') | ||
single_fan_mocker.mock_presence() | ||
assert wait_until(THERMAL_CONTROL_TEST_WAIT_TIME, THERMAL_CONTROL_TEST_CHECK_INTERVAL, check_cooling_cur_state, dut, 10, operator.ne), \ | ||
'Current cooling state is {}'.format(get_cooling_cur_state(dut)) | ||
logging.info('Wait {} seconds for the policy to take effect...'.format(THERMAL_CONTROL_TEST_CHECK_INTERVAL)) | ||
time.sleep(THERMAL_CONTROL_TEST_CHECK_INTERVAL) | ||
cooling_cur_state = get_cooling_cur_state(dut) | ||
logging.info('Cooling level changed to {}'.format(cooling_cur_state)) | ||
current_speeds = [] | ||
for index in range(psu_num): | ||
speed = get_psu_speed(dut, index) | ||
current_speeds.append(speed) | ||
|
||
logging.info('Current speed={}'.format(current_speeds)) | ||
index = 0 | ||
if cooling_cur_state < 6: | ||
cooling_cur_state = 6 | ||
expect_multiple = float(10) / cooling_cur_state | ||
while index < psu_num: | ||
full_speed = full_speeds[index] | ||
current_speed = current_speeds[index] | ||
index += 1 | ||
if not full_speed or not current_speed: | ||
continue | ||
|
||
actual_multiple = float(full_speed) / current_speed | ||
if expect_multiple > actual_multiple: | ||
assert actual_multiple > expect_multiple * (1 - PSU_SPEED_TOLERANCE) | ||
elif expect_multiple < actual_multiple: | ||
assert actual_multiple < expect_multiple * (1 + PSU_SPEED_TOLERANCE) | ||
|
||
|
||
def get_psu_speed(dut, index): | ||
index = index + 1 | ||
psu_speed_path = PSU_SPEED_PATH.format(index) | ||
file_exists = dut.stat(path=psu_speed_path) | ||
if not file_exists: | ||
return None | ||
|
||
cmd_output = dut.command('cat {}'.format(psu_speed_path)) | ||
try: | ||
return int(cmd_output['stdout']) | ||
except Exception as e: | ||
assert False, 'Bad content in {} - {}'.format(psu_speed_path, e) | ||
|
||
|
||
def get_cooling_cur_state(dut): | ||
cmd_output = dut.command('cat {}'.format(COOLING_CUR_STATE_PATH)) | ||
try: | ||
return int(cmd_output['stdout']) | ||
except Exception as e: | ||
assert False, 'Bad content in {} - {}'.format(COOLING_CUR_STATE_PATH, e) | ||
|
||
|
||
def check_cooling_cur_state(dut, expect_value, op): | ||
actual_value = get_cooling_cur_state(dut) | ||
return op(actual_value, expect_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this LS-SN2700 come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's one SKU of 2700, I just copy the SKU name from existing code.