Added detailed reason for assert failure for bgp,sonic,sfp#18777
Added detailed reason for assert failure for bgp,sonic,sfp#18777StormLiangMS merged 8 commits intosonic-net:masterfrom
Conversation
tests/bgp/test_bgp_azng_migration.py
Outdated
| "- Output: {}\n" | ||
| ).format( | ||
| bgp_nbr_recv_cmd if 'bgp_nbr_recv_cmd' in locals() else 'N/A', | ||
| routes_json |
There was a problem hiding this comment.
Not sure how many keys in routes_json, but for this assert, it's better to print out routes_json['totalPrefixCounter']
tests/bgp/test_bgp_azng_migration.py
Outdated
| "- Output: {}\n" | ||
| ).format( | ||
| bgp_nbr_recv_cmd if 'bgp_nbr_recv_cmd' in locals() else 'N/A', | ||
| routes_json |
There was a problem hiding this comment.
for this assert, it's better to print out routes_json['totalPrefixCounter']
tests/bgp/test_bgp_azng_migration.py
Outdated
| "- Output: {}\n" | ||
| ).format( | ||
| bgp_nbr_recv_cmd if 'bgp_nbr_recv_cmd' in locals() else 'N/A', | ||
| routes_json |
There was a problem hiding this comment.
for this assert, it's better to print out routes_json['totalPrefixCounter']
tests/bgp/test_bgp_azng_migration.py
Outdated
| ).format( | ||
| routes_json['totalPrefixCounter'], | ||
| bgp_nbr_recv_cmd if 'bgp_nbr_recv_cmd' in locals() else 'N/A', | ||
| routes_json |
There was a problem hiding this comment.
Don't print routes_json out, just printing out routes_json['totalPrefixCounter'] is enough
tests/bgp/test_bgp_azng_migration.py
Outdated
| "- Output: {}\n" | ||
| ).format( | ||
| bgp_nbr_recv_cmd if 'bgp_nbr_recv_cmd' in locals() else 'N/A', | ||
| routes_json |
There was a problem hiding this comment.
Please just print out routes_json['totalPrefixCounter']
tests/bgp/test_bgp_azng_migration.py
Outdated
| "Expected: {expected}, Actual: {actual}. " | ||
| "- Command: {cmd}\n" | ||
| ).format( | ||
| expected=original_ipv4_route_adv_filter_count, |
There was a problem hiding this comment.
why do you use another format to print the variables, please keep the format same consistently.
| ).format( | ||
| bgp_nbr_recv_cmd if 'bgp_nbr_recv_cmd' in locals() else 'N/A', | ||
| routes_json | ||
| ) |
There was a problem hiding this comment.
Pls print out routes_json['totalPrefixCounter']
tests/bgp/test_bgp_suppress_fib.py
Outdated
| r.status_code, | ||
| url, | ||
| data, | ||
| r.text |
There was a problem hiding this comment.
Does r have text? If you are not sure, please remove it, otherwise it will cause exception and fail the case
| "Check the process status with 'ps -ef | grep orchagent', review DUT logs, " | ||
| "and ensure no supervisor is restarting the process." | ||
| ).format(duthost.hostname) | ||
|
|
There was a problem hiding this comment.
For those ones have failed reason, I don't suggest to change it. That's the author intention.
| disable_dom_result = self.duthost.command(self.cmd_disable_dom) | ||
| assert disable_dom_result["rc"] == 0, \ | ||
| "Disable DOM polling failed for {}".format(self.logical_intf) | ||
| assert disable_dom_result["rc"] == 0, ( |
There was a problem hiding this comment.
For those ones have failed reason, I don't suggest to change it. That's the author intention.
| shutdown_result = self.duthost.command(self.cmd_down) | ||
| assert shutdown_result["rc"] == 0, "Shutdown {} failed".format(self.logical_intf) | ||
| assert check_interface_status(self.duthost, [self.logical_intf], expect_up=False) | ||
| assert shutdown_result["rc"] == 0, ( |
There was a problem hiding this comment.
For those ones have failed reason, I don't suggest to change it. That's the author intention.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| assert sfp_presence['rc'] == 0, "Run command '{}' failed".format(cmd_sfp_presence) | ||
| assert sfp_presence['rc'] == 0, ( | ||
| "Run command '{}' failed with return code {}. " | ||
| "This means the 'sfputil show presence' command did not execute successfully on the DUT. " |
There was a problem hiding this comment.
Please remove these 2 indication lines. Just print out the reason is enough, don't need to explain or tell the user how to do debug it. "This means.." is not necessary at all
| "This means the SFP module is not detected as present on this interface. " | ||
| "Please verify the SFP module is properly inserted and operational, check compatibility, " | ||
| "run 'sfputil show presence' manually, and review DUT logs for related errors." | ||
| ).format(intf) |
There was a problem hiding this comment.
Please remove these 3 indication lines. Just print out the reason is enough, don't need to explain or tell the user how to do debug it. "This means.." is not necessary at all
| assert sfp_eeprom['rc'] == 0, ( | ||
| "Run command '{}' failed with return code {}. " | ||
| "This means the 'sfputil show eeprom' command did not execute successfully on the DUT. " | ||
| "Please check the command output, DUT logs, and platform status for troubleshooting." |
There was a problem hiding this comment.
"This means.." is not necessary at all, please remove them.
| expect_up=True | ||
| ), ( | ||
| "Not all interfaces that are admin up transitioned to the 'up' state after SFP reset. " | ||
| "This means one or more interfaces expected to be operationally up are still down. " |
There was a problem hiding this comment.
"This means.." is not necessary at all. Just tell the failed reason, no need to tell user how to debug or fix it. Make the summary clean and clear.
| assert wait_until(300, 10, 0, check_docker_status, duthost) | ||
| assert wait_until(300, 10, 0, check_docker_status, duthost), ( | ||
| "Not all Docker containers reached the 'fully started' state within 300 seconds after config reload." | ||
| ).format() |
|
|
||
| assert wait_until(360, 20, 0, config_system_checks_passed, duthost, delayed_services), ( | ||
| "System checks did not pass within the allotted time after config reload." | ||
| ).format() |
There was a problem hiding this comment.
Please remove format if there is no variable, or add some variables in format.
|
|
||
| assert wait_until(360, 20, 0, config_system_checks_passed, duthost, delayed_services), ( | ||
| "System checks did not pass within the allotted time after config reload." | ||
| ).format() |
There was a problem hiding this comment.
Please remove format if there is no variable, or add some variables in format.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@StormLiangMS Please help review. Thanks. |
|
@bachalla Please add abstracted scripts name in the title. |
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally.
|
Cherry-pick PR to 202505: #19125 |
Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally.
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally.
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally. Signed-off-by: opcoder0 <110003254+opcoder0@users.noreply.github.com>
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally. Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally. Signed-off-by: Aharon Malkin <amalkin@nvidia.com>
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally. Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally.
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally. Signed-off-by: Guy Shemesh <gshemesh@nvidia.com>
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally. Signed-off-by: Yael Tzur <ytzur@nvidia.com>
…#18777) Summary: Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail. Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails. What is the motivation for this PR? The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance. How did you do it? I updated the assertion statements in the following test files to include descriptive error messages: tests/bgp/test_bgp_azng_migration.py tests/bgp/test_bgp_suppress_fib.py tests/common/devices/sonic.py tests/platform_tests/sfp/test_sfputil.py tests/platform_tests/sfp/test_show_intf_xcvr.py tests/platform_tests/test_reload_config.py How did you verify/test it? Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally.
Description of PR
Added detailed Reason for Assert failure
Type of change
Back port request
Summary:
Enhanced assertion messages in selected test cases to provide clearer failure context. This improves debuggability and speeds up issue resolution when tests fail.
Added detailed assertion failure messages in test scripts to make it easier to understand why tests fails.
What is the motivation for this PR?
The motivation is to improve test debuggability by adding detailed failure reasons in assertions for selected test cases. This enhancement makes it easier to identify the root cause of test failures in logs, thereby reducing triage time and simplifying test maintenance.
How did you do it?
I updated the assertion statements in the following test files to include descriptive error messages:
tests/bgp/test_bgp_azng_migration.py
tests/bgp/test_bgp_suppress_fib.py
tests/common/devices/sonic.py
tests/platform_tests/sfp/test_sfputil.py
tests/platform_tests/sfp/test_show_intf_xcvr.py
tests/platform_tests/test_reload_config.py
How did you verify/test it?
Verified that the updated assertion messages are correctly reflected in the test code by reviewing the changes locally.