fix: generalize JUnit XML injection for all early-exit failures#5646
fix: generalize JUnit XML injection for all early-exit failures#5646rnetser wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
📜 Recent review details⏰ Context from checks skipped due to timeout. (29)
|
| Layer / File(s) | Summary |
|---|---|
Failure state and JUnit injection utilities/pytest_utils.py |
Stores early-exit details, sanitizes testcase names and error text, appends a synthetic <error> testcase, updates suite counters, and atomically rewrites the configured JUnit XML. |
Pytest teardown wiring and validation conftest.py, utilities/unittests/test_pytest_utils.py |
Runs failure injection from teardown regardless of earlier cleanup outcomes and tests missing configuration, XML updates, sanitization, teardown ordering, and write-failure preservation. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Possibly related PRs
- RedHatQE/openshift-virtualization-tests#5639 — Implements closely related synthetic JUnit error injection and failure-state tests.
Suggested labels: new-tests
Suggested reviewers: geetikakay, dshchedr, vsibirsk, ronikishner
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Branch Management
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
Security Checks
💡 Tips
📌 Additional InformationCustom Commands:
For more information, please refer to the project documentation or contact the maintainers. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #4571. Overlapping filesconftest.py |
7b1945c to
31cd531
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5646 +/- ##
==========================================
+ Coverage 98.67% 98.89% +0.21%
==========================================
Files 25 42 +17
Lines 2487 2617 +130
==========================================
+ Hits 2454 2588 +134
+ Misses 33 29 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
D/S test |
|
@coderabbitai review |
✅ Action performedReview finished.
|
When exit_pytest_execution aborts the session, the exit reason may not appear in the JUnit XML report. Add _inject_failure_junit to create a synthetic error testcase in the XML, ensuring CI systems always see the failure. - Record failure details in _failure_info before pytest.exit() - Inject synthetic testcase into JUnit XML during pytest_sessionfinish - Use atomic write (tempfile + os.replace) to preserve XML on failure - Wrap in try/finally to guarantee injection despite teardown errors Signed-off-by: Ruth Netser <rnetser@redhat.com> Co-authored-by: PI (claude-opus-4-6-1m) <noreply@pi.dev> Signed-off-by: rnetser <rnetser@redhat.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-5646 published |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Verification failed for PR #5646. Execution details |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
What this PR does / why we need it:
Adds JUnit XML injection for early pytest exit failures from
exit_pytest_execution.When sanity checks or other pre-test verifications fail and
exit_pytest_executionaborts the session, the JUnit XML report may contain zero testcases. CI systems (Jenkins, Prow) ignore empty reports, making these failures invisible. This PR adds a synthetic error testcase to the JUnit XML so failures are always reported.Key changes:
inject_failure_junit()inutilities/pytest_utils.py— re-opens the XML file after LogXML writes it and appends a synthetic error testcasemessage,log_message,return_code) fromexit_pytest_executionin a module-levelTypedDict-annotated dictcluster_sanity_failed,storage_class_failure)inject_failure_junitfrompytest_sessionfinishin root conftestRemoved private API dependency: replaced
_pytest.junitxml.bin_xml_escapewith inline control character sanitization using stdlibre.Co-authored-by: Claude noreply@anthropic.com
Which issue(s) this PR fixes:
Special notes for reviewer:
TypedDictunderTYPE_CHECKINGfor type safety without runtime overheadpytest.exit()call verificationjira-ticket:
Summary by CodeRabbit