-
Notifications
You must be signed in to change notification settings - Fork 727
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
Retry test_psu.py::TestPsuApi::test_power if power not within tolerance #14788
Retry test_psu.py::TestPsuApi::test_power if power not within tolerance #14788
Conversation
If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. Test is repeated for a maximum of three times until it passes, else it is failed. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences reading each of the parameters.
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. The test is repeated for a maximum of three times until it passes. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences in reading each of the parameters.
/azpw run Azure.sonic-mgmt |
/AzurePipelines run Azure.sonic-mgmt |
Azure Pipelines successfully started running 1 pipeline(s). |
.format(voltage, psu_id, low_threshold, high_threshold)) | ||
|
||
break | ||
|
||
self.assert_expectations() |
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.
How does the self.assert_expectations() evaluate the 3 test run values? What happens for different combinations of the expected values? For example:
Test1: True
Test2: False
Test3: True
In this combination, does the test raise assert or passes?
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.
The test would fail in this scenario. I have an update to address it, will commit the changes. Thanks.
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.
@smagarwal-arista With new changes, does the test pass in above scenario? Also, does the test exit on first Passed case?
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.
Yes, the test would exit the retry loop if all expects pass. Retry is only targeted for expect failing on abs(power - (voltage*current)) < power*0.1
condition. Any other expect failures would exit the retry loop for that PSU and eventually result in a failed test.
The pre-commit check detected issues in the files touched by this pull request. Detailed pre-commit check results: To run the pre-commit checks locally, you can follow below steps:
|
/azpw run Azure.sonic-mgmt |
/AzurePipelines run Azure.sonic-mgmt |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Looks good to me.
@smagarwal-arista As we are modifying this function already, can you modularize the function for better readability?
Sure, will update the function |
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.
Thank you. Looks good to me.
@prgeor could you review the PR? |
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.
@roy-sror @keboliu @Junchao-Mellanox can you review
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.
@Junchao-Mellanox @keboliu @roy-sror can you review?
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.
In the case, you want to retry the same test logic for 3 times. I think you don't need to desgin the retry mechanisam by yourself, you can use the exsiting function:
wait_until(timeout, interval, delay, condition, *args, **kwargs).
Using the function of wait_until will make the test more concise
tests/platform_tests/api/test_psu.py
Outdated
power = self.get_psu_parameter(psu_info, "power", psu.get_power, "power") | ||
|
||
failure_occured = self.get_len_failed_expectations() > failure_count | ||
if current is not None and voltage is not None and power is not None: |
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.
'if current is not None and voltage is not None and power is not None: ' is changed to if current and voltage and power :
Maybe It is more concise?
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.
Resolved in the latest commit.
tests/platform_tests/api/test_psu.py
Outdated
low_threshold = self.get_psu_parameter(psu_info, "voltage_low_threshold", | ||
psu.get_voltage_low_threshold, "low voltage threshold") | ||
|
||
if high_threshold is not None and low_threshold is not None: |
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.
Same as line 236. if high_threshold and low_threshold:
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.
Resolved in the latest commit.
Thanks, I'll take a look |
hi @smagarwal-arista could you address the comments? |
Resolved in the latest commit. Now using wait_until function. |
…ce (sonic-net#14788) * Retry test_power calculated power above 10% If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. Test is repeated for a maximum of three times until it passes, else it is failed. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences reading each of the parameters. * Retry test_power.py::TestPsuApi::test_power if power above tolerance If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. The test is repeated for a maximum of three times until it passes. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences in reading each of the parameters. * Add check to detect occurrence of a failure before power calculation * Resolve pre-commit check issue * Refactor test_power function to improve readability * Use wait_until function for retry
Cherry-pick PR to 202405: #15451 |
MSADO: 28386639 |
…ce (#14788) * Retry test_power calculated power above 10% If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. Test is repeated for a maximum of three times until it passes, else it is failed. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences reading each of the parameters. * Retry test_power.py::TestPsuApi::test_power if power above tolerance If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. The test is repeated for a maximum of three times until it passes. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences in reading each of the parameters. * Add check to detect occurrence of a failure before power calculation * Resolve pre-commit check issue * Refactor test_power function to improve readability * Use wait_until function for retry
…ce (sonic-net#14788) * Retry test_power calculated power above 10% If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. Test is repeated for a maximum of three times until it passes, else it is failed. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences reading each of the parameters. * Retry test_power.py::TestPsuApi::test_power if power above tolerance If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. The test is repeated for a maximum of three times until it passes. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences in reading each of the parameters. * Add check to detect occurrence of a failure before power calculation * Resolve pre-commit check issue * Refactor test_power function to improve readability * Use wait_until function for retry
…ce (sonic-net#14788) * Retry test_power calculated power above 10% If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. Test is repeated for a maximum of three times until it passes, else it is failed. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences reading each of the parameters. * Retry test_power.py::TestPsuApi::test_power if power above tolerance If the test fails on `abs(power - (voltage*current)) < power*0.1` then retry the test. The test is repeated for a maximum of three times until it passes. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences in reading each of the parameters. * Add check to detect occurrence of a failure before power calculation * Resolve pre-commit check issue * Refactor test_power function to improve readability * Use wait_until function for retry
Cherry-pick PR to 202311: #15587 |
Description of PR
Summary:
If
test_psu.py::TestPsuApi::test_power
fails onabs(power - (voltage*current)) < power*0.1
then retry the test. The test is repeated for a maximum of three times until it passes, else it is failed. This change is introduced to account for the stringent tolerance level of 10% and the errors that might be caused due to time differences in reading each of the parameters (current, voltage and power).Fixes # (issue)
Addresses issue: https://github.com/aristanetworks/sonic-qual.msft/issues/209
Type of change
Back port request
Approach
What is the motivation for this PR?
Improve the test to account for stringent tolerance level and asymmetric reading of parameters for power calculation.
How did you do it?
If the test fails for the condition
abs(power - (voltage*current)) < power*0.1
, the test will collect fresh parameters (voltage, current and power) from the PSU telemetry and recheck the condition. It is limited to a maximum of 3 attempts.How did you verify/test it?
Tested internally by varying the tolerance level and verifying the number of api calls.
Any platform specific information?
N/A
Supported testbed topology if it's a new test case?
N/A
Documentation
N/A