-
Notifications
You must be signed in to change notification settings - Fork 1k
Convert tests test_cpu_memory_usage, test_port_toggle to support T2 c… #3117
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,96 @@ | ||
|
|
||
| import json | ||
| import pytest | ||
| from tests.common.helpers.assertions import pytest_assert | ||
|
|
||
| pytestmark = [ | ||
| pytest.mark.topology('t2') | ||
| ] | ||
|
|
||
|
|
||
| def get_chassis_db_ip(duthost): | ||
| out = duthost.command("cat /etc/sonic/chassisdb.conf")['stdout_lines'] | ||
| for line in out: | ||
| if "chassis_db_address" in line.split("="): | ||
| chassis_db_ip = line.split("=")[1] | ||
| break | ||
| return chassis_db_ip | ||
|
|
||
|
|
||
| def get_expected_num_thermals(duts, dutname=None): | ||
| num_of_therms = 0 | ||
| cmd = "show platform temperature" | ||
| if dutname: | ||
| dut = duts[dutname] | ||
| therm_out = dut.show_and_parse(cmd) | ||
| num_of_therms = len(therm_out) | ||
| else: | ||
| for dut in duts: | ||
| therm_out = dut.show_and_parse(cmd) | ||
| num_of_therms += len(therm_out) | ||
|
|
||
| return num_of_therms | ||
|
|
||
|
|
||
| def check_therm_data(thermal_dict): | ||
| failed_check_msg = [] | ||
| for therm_sensor in thermal_dict.keys(): | ||
| max_threshold = float(thermal_dict[therm_sensor]['value']['high_threshold']) | ||
| low_threshold = float(thermal_dict[therm_sensor]['value']['low_threshold']) | ||
| min_temp = float(thermal_dict[therm_sensor]['value']['maximum_temperature']) | ||
| high_temp = float(thermal_dict[therm_sensor]['value']['minimum_temperature']) | ||
| warning_status = thermal_dict[therm_sensor]['value']['warning_status'] | ||
| if high_temp > max_threshold: | ||
| if warning_status == 'False': | ||
| failed_check_msg.append( | ||
| "high temperature {} exceeded max threshold {} warning status expected true but is {} for {}" | ||
| .format(high_temp, max_threshold, warning_status, therm_sensor)) | ||
| elif min_temp < low_threshold: | ||
| if warning_status == 'False': | ||
| failed_check_msg.append( | ||
| "Minimum temperature {} lower than min threshold {} warning status expected true but is {} for {}" | ||
| .format(high_temp, max_threshold, warning_status, therm_sensor)) | ||
| else: | ||
| if warning_status == 'True': | ||
| failed_check_msg.append( | ||
| "warning status expected False but is {} for {}" | ||
| .format(warning_status, therm_sensor)) | ||
|
|
||
| return failed_check_msg | ||
|
|
||
|
|
||
| def test_thermal_state_db(duthosts, enum_rand_one_per_hwsku_hostname, tbinfo): | ||
| """ | ||
| This test case will verify thermal local state db data on each hwsku type in chassis | ||
| """ | ||
| duthost = duthosts[enum_rand_one_per_hwsku_hostname] | ||
| if duthost.facts['modular_chassis'] == "False": | ||
| pytest.skip("Test skipped applicable to modular chassis only") | ||
| num_thermals = get_expected_num_thermals(duthosts, enum_rand_one_per_hwsku_hostname) | ||
| thermal_out = duthost.command("redis-dump -d 6 -y -k \"*TEMP*\"") | ||
| out_dict = json.loads(thermal_out['stdout']) | ||
| pytest_assert(len(out_dict.keys()) == num_thermals, "number of thermal sensors incorrect expected {} but got {}".format(num_thermals, len(out_dict.keys()))) | ||
| result = check_therm_data(out_dict) | ||
| pytest_assert(not result, | ||
| "Warning status incorrect for following thermal sensors:\n{}".format("\n".join(result))) | ||
|
|
||
|
|
||
| def test_thermal_global_state_db(duthosts, enum_supervisor_dut_hostname, tbinfo): | ||
| """ | ||
| This test case will verify global state db data on supervisor | ||
| Verify data for all sensors from line cards and fabric cards present in global state db | ||
| """ | ||
| duthost = duthosts[enum_supervisor_dut_hostname] | ||
| if duthost.facts['modular_chassis'] == "False": | ||
| pytest.skip("Test skipped applicable to modular chassis only") | ||
| chassis_db_ip = get_chassis_db_ip(duthost) | ||
| expected_num_thermals = get_expected_num_thermals(duthosts) | ||
| thermal_out = duthost.command("redis-dump -H {} -p 6380 -d 13 -y -k \"*TEMP*\"".format(chassis_db_ip)) | ||
| out_dict = json.loads(thermal_out['stdout']) | ||
| actual_num_thermal_sensors = len(out_dict.keys()) | ||
| pytest_assert(actual_num_thermal_sensors == expected_num_thermals, | ||
| "got {} thermal sensors expected {}".format(actual_num_thermal_sensors, expected_num_thermals)) | ||
| result = check_therm_data(out_dict) | ||
| pytest_assert(not result, | ||
| "Warning status incorrect in global db for following thermal sensors:\n{}".format( | ||
| "\n".join(result))) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.