Skip to content

fix(ci): count JUnit errors in Slack failure report#4912

Merged
openshift-merge-bot[bot] merged 1 commit into
redhat-developer:mainfrom
gustavolira:fix/report-count-junit-errors
Jun 3, 2026
Merged

fix(ci): count JUnit errors in Slack failure report#4912
openshift-merge-bot[bot] merged 1 commit into
redhat-developer:mainfrom
gustavolira:fix/report-count-junit-errors

Conversation

@gustavolira
Copy link
Copy Markdown
Member

Summary

The Slack CI alert was reporting 0 tests failed with a :circleci-fail: failure emoji, which is contradictory and misleading.

Root cause: The JUnit XML spec distinguishes failures (assertion failures) from errors (exceptions/timeouts). Playwright reports TimeoutError and similar issues as errors, not failures. The old code in testing.sh only parsed the failures attribute:

failed_tests=$(grep -oP 'failures="\K[0-9]+' "${e2e_tests_dir}/${JUNIT_RESULTS}" | head -n 1)

So any test that failed due to a timeout or exception was silently uncounted, producing 0 tests failed on Slack even though tests actually failed.

Evidence from build 2061711989599637504:

  • showcase JUnit: failures="0" errors="4" → Slack showed "0 tests failed" (should be 4)
  • showcase-runtime JUnit: failures="0" errors="8" → Slack showed "0 tests failed" (should be 8)

Fix: Sum both failures and errors from the root <testsuites> element. Also adds a safety net: if Playwright exits non-zero but JUnit reports 0 of both, report "some" instead of the misleading "0".

Test plan

  • Verified fix logic against actual JUnit XML from the failing build
  • Next nightly run should show correct failure counts on Slack

🤖 Generated with Claude Code

The Slack alert was reporting "0 tests failed" even when tests actually
failed. The root cause is that the JUnit XML spec distinguishes
"failures" (assertion failures) from "errors" (exceptions/timeouts).
Playwright reports TimeoutError and similar issues as `errors`, not
`failures`. The old code only parsed the `failures` attribute, so any
test that failed due to a timeout or exception was silently uncounted.

Fix by summing both `failures` and `errors` from the root <testsuites>
element. Also add a safety net: if Playwright exits non-zero but the
JUnit XML somehow reports 0 failures and 0 errors, report "some" instead
of the misleading "0".

Verified against build 2061711989599637504 where showcase had
failures="0" errors="4" and showcase-runtime had failures="0" errors="8"
— both incorrectly reported as "0 tests failed" on Slack.

Requested-By: <@U05QPKB8VB3> (gliraesi)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

@rhdh-qodo-merge
Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again

Grey Divider

Qodo Logo

@rhdh-qodo-merge
Copy link
Copy Markdown

Review Summary by Qodo

Fix Slack CI alert to count JUnit errors in failure report

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Fix Slack CI alert reporting incorrect test failure counts
• Sum both JUnit failures and errors attributes
• Handle Playwright crashes/timeouts with safety fallback
• Playwright reports timeouts as errors, not failures
Diagram
flowchart LR
  A["Playwright Test Exit Code"] --> B{"Exit Code = 0?"}
  B -->|Yes| C["Report 0 failures"]
  B -->|No| D["Parse JUnit XML"]
  D --> E["Extract failures attribute"]
  D --> F["Extract errors attribute"]
  E --> G["Sum failures + errors"]
  F --> G
  G --> H{"Sum = 0?"}
  H -->|Yes| I["Report 'some'"]
  H -->|No| J["Report actual count"]
  I --> K["Slack Notification"]
  J --> K

Loading

Grey Divider

File Changes

1. .ci/pipelines/lib/testing.sh 🐞 Bug fix +16/-2

Count both JUnit failures and errors in test report

• Extract both failures and errors from JUnit XML root element
• Sum both values to get accurate failed test count
• Add fallback to "some" when Playwright exits non-zero but JUnit reports 0 failures and 0 errors
• Add detailed comments explaining JUnit XML distinction between failures and errors

.ci/pipelines/lib/testing.sh


Grey Divider

Qodo Logo

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.25%. Comparing base (c64c1dd) to head (e043cc6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4912      +/-   ##
==========================================
- Coverage   55.82%   55.25%   -0.58%     
==========================================
  Files         121      109      -12     
  Lines        2350     2132     -218     
  Branches      562      513      -49     
==========================================
- Hits         1312     1178     -134     
+ Misses       1032      954      -78     
+ Partials        6        0       -6     
Flag Coverage Δ
rhdh 55.25% <ø> (-0.58%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c64c1dd...e043cc6. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Image was built and published successfully. It is available at:

@sanketpathak
Copy link
Copy Markdown
Contributor

Thanks @gustavolira
/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Jun 3, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit e8d7187 into redhat-developer:main Jun 3, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants