Skip to content

Allow forked test tasks for source sets other than test - #12147

Open
AlexeyKuznetsov-DD wants to merge 1 commit into
masterfrom
alexeyk/forked-test-source-set
Open

Allow forked test tasks for source sets other than test#12147
AlexeyKuznetsov-DD wants to merge 1 commit into
masterfrom
alexeyk/forked-test-source-set

Conversation

@AlexeyKuznetsov-DD

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Lets a module register a forked-test task for a source set other than test.

gradle/java_no_deps.gradle registered a single hardcoded forkedTest task bound to sourceSets.test. This turns that registration into a reusable helper next to its siblings in gradle/test-suites.gradle, and calls it with 'test' from the same place as before:

ext.addForkedTestTask = { String sourceSetName ->
  def taskName = sourceSetName == 'test' ? 'forkedTest' : "${sourceSetName}ForkedTest"
  return tasks.register(taskName, Test) {
    group = LifecycleBasePlugin.VERIFICATION_GROUP
    useJUnitPlatform()
    testClassesDirs = sourceSets[sourceSetName].output.classesDirs
    classpath = sourceSets[sourceSetName].runtimeClasspath
  }
}

A module with its own suites now opts in with one line:

addTestSuite('baseTest')
addForkedTestTask('baseTest')  // registers 'baseTestForkedTest'

No behaviour changes for any existing module: forkedTest is still registered for every project, with the same name and the same configuration.

Motivation

Modules that do not use the default test source set silently do not run their forked tests.

The convention plugin excludes **/*ForkedTest* from every non-forked Test task, and the only task that runs them was bound to sourceSets.test. A module that keeps its tests in its own suites — for example to compile the same tests against several Scala versions — therefore has no task that runs its *ForkedTest classes at all.

Two modules are in exactly that state today, with forked tests that have never executed:

  • dd-java-agent/instrumentation/pekko/pekko-http-1.0 — 6 classes in src/baseTest
  • dd-java-agent/instrumentation/netty/netty-3.8 — 2 classes in src/latestDepTest

This PR only provides the mechanism. Switching those modules on is deliberately left out, because their dormant tests do not currently pass — running pekko's surfaces a real NPE in PekkoHttpClientHelpers$PekkoHttpHeaders during Data Streams injection — and each needs its own investigation.

Additional Notes

This PR only adds the helper; enabling it in existing modules will be handled separately.

Validation:

  • :internal-api:forkedTest passed 6 tests, confirming the default test source-set behavior is unchanged.
  • A temporary Pekko opt-in registered the custom-source-set forked tasks and ran 146 test cases with no failures (86 conditionally skipped). The opt-in was reverted after validation.
  • spotlessGroovyGradleCheck passed.

Contributor Checklist

Jira ticket: [PROJ-IDENT]

🤖 Generated with Claude Code

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD added tag: no release notes Changes to exclude from release notes type: refactoring comp: tooling Build & Tooling tag: ai generated Largely based on code generated by an AI or LLM labels Aug 5, 2026
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 58.79% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1fb9331 | Docs | View more details | Give us feedback!

@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD force-pushed the alexeyk/forked-test-source-set branch from b5e02c8 to 36f6dd2 Compare August 5, 2026 15:13
@dd-octo-sts

dd-octo-sts Bot commented Aug 5, 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 14.74 s 14.73 s [-0.8%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 13.69 s 13.66 s [-0.6%; +1.0%] (no difference)
startup:petclinic:appsec:Agent 17.56 s 17.25 s [+0.9%; +2.7%] (maybe worse)
startup:petclinic:iast:Agent 17.41 s 17.58 s [-1.9%; -0.1%] (maybe better)
startup:petclinic:profiling:Agent 16.79 s 17.35 s [-7.5%; +1.0%] (no difference)
startup:petclinic:sca:Agent 17.35 s 17.19 s [-0.2%; +2.0%] (no difference)
startup:petclinic:tracing:Agent 16.49 s 16.76 s [-2.5%; -0.7%] (maybe better)

Commit: 1fb9331f · 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.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD force-pushed the alexeyk/forked-test-source-set branch from 36f6dd2 to 1fb9331 Compare August 26, 2026 18:46
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD marked this pull request as ready for review August 26, 2026 19:10
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD requested a review from a team as a code owner August 26, 2026 19:10

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot 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.

Datadog Autotest: PASS

More details

The existing task keeps its default source set. Custom tasks use the selected source set and the same fork controls.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 1fb9331 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

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 tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant