junit upload: pass CI when every failing test is quarantined #2650
All Vouch review confidence checks passed
Residual risk 0.36 = Change Risk (0.64) × (1 − Review Confidence (0.44)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.64 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
No Reviewer Assigned
no_reviewer_assigned
0.120
Real PR Conversation Timeline
1 comments
"Review active on #2650"
general
weight: 0.35
afontan
Flaky Test Management docs
Why the change
Repositories that only upload JUnit XML can quarantine or disable tests in Flaky Test Management, but their CI jobs still fail on those tests, so this adds an opt-in
--test-exit-codetodatadog-ci junit uploadthat passes a job whose only failures are quarantined or disabled tests.Special things to note
--test-exit-codenothing changes. Only the runner's "tests failed" exit code can be excused (--test-failure-exit-code, default1; Bazel3, nextest100, ctest8). Anything the reports can't explain keeps the job red: an unreadable or dropped report, no failing testcase, an unknown commit, Flaky Test Management turned off in the settings the test libraries read (test_management.enabled), a failed lookup, a Go panic or timeout.dd_tags[test.test_management.is_quarantined]ordd_tags[test.test_management.is_test_disabled]property, so Datadog shows them like the test libraries' runs. A testcase is found by its position and checked by itsname; if anything doesn't line up, the report is uploaded as it is. The files on disk don't change.--tags/DD_TAGSoverrides ofgit.applied. When testcases with differentclassnames share a suite and name (pytest's default suite, for example), Datadog merges them into one test, so none of them is excused. Go reports are judged at the leaves, and the last rerun within a report wins; another report is another execution. A quarantined Go parent does not cover its subtests: in JUnit reports a parent fails whenever a subtest does, so failure-rate policies quarantine parents of flaky subtests, and covering the subtests would hide their real failures. Known limitation: a parent that fails on its own assertion while a quarantined subtest fails is excused.Change outline
The new flags, and how a pipeline uses them:
The order of the command with the flag:
The two lookups use the API-key endpoints the test libraries use:
The verdict,
judge()inquarantine.ts:What a tagged testcase looks like in the uploaded report:
Where it hooks into the upload command:
Validation
quarantine.test.tsand 1 inapi.test.ts, covering every rule and exit path. Removing any one rule makes at least one test fail: Go leaves, last rerun, JUnit-only modules, panic and timeout, invalid reports, the exit-code check, entities, value trimming, unnamed suites, attribute case, the.xmlmodules,--test-failure-exit-code, the quarantine setting, the--tagsoverride order, "disabled wins", tagging every run, the name check, document order, skipping comments and the DOCTYPE, the testcase name boundary, the settings branch fallback, no parent coverage, reruns and parents per report, panicking parents, shared suite + name, the exit-code range, and sending the tagged copy.yarn tsc:build, eslint, prettier andlint:readme-usagepass.3f01cf92: sandbox pipelines build this branch, run a Go package (gotestsum) and a pytest suite where one test fails on demand, and upload to a Datadog test environment. Each job asserts the exit code and the verdict's own line. The "real failure" is named after the run, so no policy can quarantine it.| Provider | Job | Tests exit | datadog-ci exit |
|---|---|---|---|
| GitHub Actions (the test and its Go parent quarantined) |
quarantined-only| 1 | 0 || |
real-failure| 1 | 1, only the real failure listed || |
flaky-passes| 0 | 0 || GitLab CI (the test and its Go parent disabled) |
quarantined-only| 1 | 0 || |
real-failure| 1 | 1 || |
all-pass| 0 | 0 || |
customer-setup, no assertion: the job's result is datadog-ci's exit | 1 | 0, job green || | upload in
after_script| 1 | 0, but the job stays red: GitLab ignoresafter_script, as the README says || GitLab CI, pytest, default
<testsuite name="pytest">(the test quarantined) |quarantined-only| 1 | 0 || |
real-failure| 1 | 1, only the real failure listed || |
all-pass| 0 | 0 || |
same-name: a test of another module with the same name fails too | 1 | 1: "another testcase has the same suite and name" || GitLab CI, pytest with
--xpath-tag test.suite=/testcase/@classname(the test quarantined) |quarantined-only, the other module's same-name test passing | 1 | 0 || |
all-pass| 0 | 0 |@test.test_management.is_quarantined:true(GitHub, and pytest on GitLab), and of the disabled ones@test.test_management.is_test_disabled:true(Go on GitLab). The real failures carry neither, and neither do thesame-nameruns. With--xpath-tag test.suite=/testcase/@classname, Datadog stored the classname as the suite, as the CLI matched it. Runs in jobs whose tests passed carry no tag, as the README says. A separate probe confirmed the property is stored as a boolean and that two<properties>blocks in one testcase are fine.- failure-rate policies quarantined and disabled the Go parents between runs; with "a quarantined parent covers its subtests", a real-failure job turned green;
- the tests lookup failed with a 500 when a branch was sent for a repository without Flaky Test Management settings, so it now sends only the repository and commit, which is all quarantine and disable need.
- with several reports in one upload, a Go test that failed in one report and passed in another counted as passing, and a Go parent's own failure in one report could be skipped because of a subtest in another;
- a Go parent whose failure shows a panic was skipped when a quarantined subtest also failed;
- testcases of different classnames sharing a suite and name (pytest's default suite) could excuse each other;
- an exit code above 255 could wrap to 0;
- elements named like
<testcase.step>and a DOCTYPE could misplace a tag; the settings call needs a branch.--tags git.repository_urloverride: without it the lookup used the CI's repository and kept exit 1; with it, exit 0.test_management.enabledfalse. It's on for every repository today, so that path is covered by unit tests only; the CLI reads the same setting as the test libraries, so it applies quarantine exactly when they do.- no change without the flag;
- at most two extra API calls per command (10 s timeout, 2 retries), only when the code is the "tests failed" code and a testcase failed;
- the report is uploaded unchanged if tagging can't line up, and any lookup error keeps the exit code;
- upload or auth errors exit 1 as today, and the API key is never logged.