Skip to content

Add JUnit support for @Flaky conditions - #12620

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 15 commits into
masterfrom
sarahchen6/junit-flaky-conditions
Oct 2, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 15 commits into
masterfrom
sarahchen6/junit-flaky-conditions

Conversation

@sarahchen6

@sarahchen6 sarahchen6 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Adds JUnit support for @/Flaky conditions and suite restrictions such that -PskipFlakyTests and -PrunFlakyTests work. Now conditions can be added via a String of a method that returns true for the cases where we want to mark the test as flaky.

Motivation

We want to preserve conditional flaky test behavior when migrating Spock tests to JUnit (and when existing JUnit tests become conditionally flaky). Tests should still run normally when the flaky condition does not apply.

Additional Notes

This PR also migrates SampleTraceSmokeTest and CustomSystemLoaderSmokeTest as POCs. See CI results from this PR:

which match CI runs from master:

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@sarahchen6
sarahchen6 force-pushed the sarahchen6/junit-flaky-conditions branch from b191f72 to f2f7b4d Compare September 23, 2026 18:45
@datadog-prod-us1-6

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.99 s 14.02 s [-1.0%; +0.5%] (no difference)
startup:insecure-bank:tracing:Agent 12.89 s 13.04 s [-1.9%; -0.5%] (maybe better)
startup:petclinic:appsec:Agent 17.05 s 17.02 s [-0.8%; +1.1%] (no difference)
startup:petclinic:iast:Agent 17.15 s 17.13 s [-0.7%; +1.0%] (no difference)
startup:petclinic:profiling:Agent 16.84 s 16.98 s [-2.0%; +0.3%] (no difference)
startup:petclinic:sca:Agent 17.13 s 16.73 s [+1.4%; +3.4%] (significantly worse)
startup:petclinic:tracing:Agent 16.14 s 16.30 s [-1.9%; -0.1%] (maybe better)

Commit: b7432145 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@PerfectSlayer
PerfectSlayer self-requested a review September 24, 2026 08:26
Comment thread buildSrc/src/main/kotlin/dd-trace-java.configure-tests.gradle.kts Outdated
@sarahchen6 sarahchen6 added type: feature Enhancements and improvements comp: tooling Build & Tooling tag: ai generated Largely based on code generated by an AI or LLM labels Sep 24, 2026
@sarahchen6
sarahchen6 marked this pull request as ready for review September 24, 2026 16:14
@sarahchen6
sarahchen6 requested review from a team as code owners September 24, 2026 16:14
@sarahchen6
sarahchen6 requested review from mhlidd and removed request for a team September 24, 2026 16:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T16:22:09.751106Z e59ec12 Draft marked ready
🔒 Security Review ✅ Completed 2026-09-24T16:18:44.289774Z e59ec12 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e59ec123a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

The most critical issue is that method-level @/Flaky tests are not filtered out before JUnit runs class-level setup and teardown, so smoke-test extensions can still start processes and fail the job even when skipping flaky tests. A separate bug causes the flaky-only run (-PrunFlakyTests) to miss nested tests whose enclosing class carries @/Flaky, because the filter does not walk up the class hierarchy to find the annotation.

Open Bits AI session

🤖 Bits Code Review · Commit e59ec12 · @DataDog review to ask questions

Comment thread buildSrc/src/main/kotlin/dd-trace-java.configure-tests.gradle.kts Outdated
Comment thread utils/test-utils/src/main/java/datadog/trace/test/util/Flaky.java
Comment thread utils/test-utils/src/main/groovy/datadog/trace/test/util/FlakyJUnitExtension.java Outdated
Comment thread buildSrc/src/main/kotlin/dd-trace-java.configure-tests.gradle.kts

@PerfectSlayer PerfectSlayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a bunch of comments to answer / review.
Additionally, anything to Flaky (the annotation, JUnit extension and filter) should move to the Java set.

Glad to see progress on the feature! 💪

Comment thread docs/how_to_test.md Outdated
Comment thread utils/test-utils/src/main/groovy/datadog/trace/test/util/Flaky.java Outdated
Comment thread utils/test-utils/src/main/java/datadog/trace/test/util/FlakyJUnitExtension.java Outdated

@PerfectSlayer PerfectSlayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional feedback on the changes:

🔨 issue: ‏It seems it always look for class annotation, skipping possible method annotation with different condition.

@sarahchen6

Copy link
Copy Markdown
Contributor Author

🔨 issue: ‏It seems it always look for class annotation, skipping possible method annotation with different condition.

The FlakyJUnitExtension should now check method-level -> the test class and its superclasses -> enclosing classes and its superclasses for the Flaky annotation (ref).

@amarziali amarziali left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok to me

bric3
bric3 previously requested changes Sep 30, 2026

@bric3 bric3 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not introduce Stringy condition methods in the Flaky annotation. I believe that relying on existing predicates would already serve the intended purpose. We can eventually bootstrap handy pre-made conditions.

Moreover allowing this stringy condition weakens refactoring awareness like Groovy is. They're harder to navigate to.

As far as I understand this PR was first based on Predicates only, which looks more appropriate to me.

Comment thread utils/test-utils/src/main/java/datadog/trace/test/util/FlakyJUnitExtension.java Outdated
Comment thread buildSrc/src/main/kotlin/dd-trace-java.configure-tests.gradle.kts
Comment thread docs/how_to_test.md
Comment thread utils/test-utils/src/main/java/datadog/trace/test/util/Flaky.java
@bric3
bric3 dismissed their stale review September 30, 2026 16:21

Dismissing myself, I made my statements in the relevant discussions.

@bric3

bric3 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

I still don't like the JUnit API choice (having a String to link to a method symbol) in this matter. But it's not a blocker either.

@sarahchen6

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-02 15:06:02 UTC ℹ️ Start processing command /merge


2026-10-02 15:06:07 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-02 15:16:21 UTC 🚨 MergeQueue: This merge request is in error because of DDCI

DDCI didn't respond in time.
If this continues, please let us know in #ci-infra-support with the following details:

  • Head SHA of the MQ branch: e7835db
  • Name of the MQ branch: mq-working-branch-master-78dadd8
  • The DDCI Workflow from GenerateDDCIRequestFromDevflow: atlas

@sarahchen6

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-10-02 15:17:44 UTC ℹ️ Start processing command /merge


2026-10-02 15:17:49 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-10-02 16:39:45 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 9660160 into master Oct 2, 2026
799 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the sarahchen6/junit-flaky-conditions branch October 2, 2026 16:39
@github-actions github-actions Bot added this to the 1.67.0 milestone Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: tooling Build & Tooling tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants