Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/instructions/instrumentation-gradle.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ or test failure that CI will report.
of the same coordinate does not test both versions: Gradle resolves one dependency graph,
normally selecting the higher version. Exercise the newer runtime in a wired version-specific
test suite.
- Inspect test sources before requiring `testcontainersBuildService`: declare `usesService`
on tasks that really use containers, not every task with a transitive dependency. Use
`withType<Test>().configureEach` for configuration shared by multiple explicitly declared
test tasks; not for a module with only `tasks.test` (implicit `latestDepTest` does not count).
- Inspect test sources before requiring `testcontainersBuildService`; a transitive dependency
alone is not enough. In a project whose tests use Testcontainers, declare
`usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)` once
in `tasks.withType<Test>().configureEach`, or `withType<Test>().configureEach` inside `tasks`.
Apply it unconditionally to all `Test` tasks, even with only the default test task. Accept
Comment thread
trask marked this conversation as resolved.
Outdated
brief slot use by container-free variants rather than adding task-name filters, source-set
inspection, automatic detection, or helpers to optimize slots. Narrower registration requires
an evidenced meaningful scheduling problem.
- Use `withType<Test>().configureEach` for configuration shared by multiple explicitly declared
test tasks; not for a module with only `tasks.test` (implicit `latestDepTest` does not count),
except for the project-wide Testcontainers service registration above. This exception does
not broaden unrelated JVM settings or system properties.
- Check metadata collection when its wiring or collected telemetry changes, not as unrelated
cleanup. Collect default telemetry and supported non-default telemetry modes. Register
representative tasks in `.github/scripts/instrumentations.sh` covering each profile's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ testing {
implementation(project(":instrumentation:aws-sdk:aws-sdk-2.2:library"))
implementation("org.testcontainers:testcontainers-localstack")
}

targets {
all {
testTask.configure {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
}
}

register<JvmTestSuite>("testBedrockRuntime") {
Expand Down Expand Up @@ -193,6 +185,7 @@ tasks {
}

withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)
}

Expand Down
6 changes: 4 additions & 2 deletions instrumentation/jms/jms-1.1/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ testing {
}

tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val testReceiveSpansDisabled = register<Test>("testReceiveSpansDisabled") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)

filter {
includeTestsMatching("Jms1SuppressReceiveSpansTest")
Expand All @@ -79,7 +82,6 @@ tasks {
}

test {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
filter {
excludeTestsMatching("Jms1SuppressReceiveSpansTest")
}
Expand Down
3 changes: 2 additions & 1 deletion instrumentation/jmx-metrics/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ tasks {
filter {
includeTestsMatching(testClass)
}
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}

Expand All @@ -81,6 +80,8 @@ tasks {
}

withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)

// the base agent only contains the agent machinery and the internal instrumentations that it
// requires, the JMX instrumentation is added on top of it. Using the full agent would capture
// telemetry from the target systems that is unrelated to JMX metrics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ testing {

tasks {
withType<Test>().configureEach {
if (name != "unitTests") {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)

if (name != "unitTests") {
Comment thread
trask marked this conversation as resolved.
Outdated
systemProperty("testLatestDeps", otelProps.testLatestDeps)
}
}
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/mongo/mongo-3.1/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
2 changes: 1 addition & 1 deletion instrumentation/nats/nats-2.17/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
2 changes: 1 addition & 1 deletion instrumentation/nats/nats-2.17/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
2 changes: 1 addition & 1 deletion instrumentation/oracle-ucp-11.2/testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ testing {

tasks {
withType<Test>().configureEach {
if (!name.endsWith("unitTests", ignoreCase = true)) {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val agentTestSuites = testing.suites.withType(JvmTestSuite::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ tasks {
}

withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)
if (name != "version41Test") {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ testing {
}

tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

test {
systemProperty("testLatestDeps", otelProps.testLatestDeps)
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
check {
dependsOn(testing.suites)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ tasks {
val testJmsDisabled = register<Test>("testJmsDisabled") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
filter {
includeTestsMatching("*.testSpringJmsListenerWithJmsDisabled")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ dependencies {
}
}

tasks.test {
tasks.withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

tasks.test {
systemProperty("testLatestDeps", otelProps.testLatestDeps)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ testing {

tasks {
withType<Test>().configureEach {
if (!name.endsWith("unitTests", ignoreCase = true)) {
if (name != "testSpringDisabled") {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)

// add byte buddy agent for mockito
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ testing {
}

tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

withType<Test>()
.matching { it.name != "unitTests" }
.configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)
}

Expand Down
2 changes: 1 addition & 1 deletion smoke-tests-otel-starter/spring-boot-4/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ tasks {
bootJar {
enabled = false
}
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
Expand Down
Loading