ansible-powerscale
ansible-powerscale copied to clipboard
Mock the actual behavior of fail_json
Ansible faile_json will call sys.exit, then abort the execution, but currently we use FailJsonException to mock fail_json, that it cannot abort the execution.
Now mock fail_json to throw SystemExit to align with Ansible behavior.
All UTs are updated to extend PowerScaleUnitBase.
Description
A few sentences describing the overall goals of the pull request's commits.
GitHub Issues
List the GitHub issues impacted by this PR:
| GitHub Issue # |
|---|
Checklist:
- [x] I have performed a self-review of my own code to ensure there are no formatting, pep8, linting, or security issues
- [x] I have performed Ansible Sanity test using --docker default
- [x] I have verified that new and existing unit tests pass locally with my changes
- [ ] I have not allowed coverage numbers to degenerate
- [x] I have maintained at least 90% code coverage
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] Backward compatibility is not broken
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration
- [x] UT
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 90.24%. Comparing base (
b7de8d3) to head (bfe8972).
Additional details and impacted files
@@ Coverage Diff @@
## main #173 +/- ##
==========================================
- Coverage 90.54% 90.24% -0.30%
==========================================
Files 145 143 -2
Lines 16695 16541 -154
Branches 2367 2365 -2
==========================================
- Hits 15116 14928 -188
- Misses 920 942 +22
- Partials 659 671 +12
| Flag | Coverage Δ | |
|---|---|---|
| units | 90.24% <100.00%> (-0.30%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
As per the Codecov report, it brings missing and partial..
As per the Codecov report, it brings missing and partial..
After adopting the same behavior as fail_json, some UTs coverage indeed went down, because the previous FailJsonException is caught and thrown to upper method caller. Before issuing the PR, I've struggled for some days to fix UT errors (logic and design, etc), add test cases and improve the coverage. For now we have 90+% coverage, that meets the criteria already, so I am not planning to make the code coverage look appealing.
It is not the module code coverage, but the test case code coverage which is weired.
For codecov app, the stats are weird indeed. Maybe we can adopt a more reasonable way to calculate the coverage in future.
Good catch. It is my fault. Used wrong indentation. Please recheck the result.