Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
38 changes: 38 additions & 0 deletions build-logic/src/main/kotlin/io.sentry.systemtest.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import io.sentry.gradle.SystemTestExtension
import org.gradle.api.tasks.ClasspathNormalizer

val systemTest = extensions.create<SystemTestExtension>("sentrySystemTest")

// The sample system tests launch the packaged app (war/shadowJar/bootJar) from build/libs as a
// separate process, so the archive is a real input even though it is not on the test classpath.
// Agent-based samples are additionally launched with -javaagent:<otel agent>, another runtime
// input not on the classpath. See test/system-test-runner.py.
tasks.matching { it.name == "systemTest" }.configureEach {
val archiveTask =
listOf("war", "shadowJar", "bootJar").firstOrNull { it in tasks.names }
?: throw GradleException(
"io.sentry.systemtest is applied to $path but none of war/shadowJar/bootJar " +
"exist to provide the launched app archive for the systemTest task"
)
// Declaring the archive as an input also wires the dependency on its producing task.
inputs
.files(tasks.named(archiveTask))
.withPropertyName("appArchive")
.withNormalizer(ClasspathNormalizer::class.java)
Comment thread
cursor[bot] marked this conversation as resolved.

if (systemTest.usesOpenTelemetryAgent.get()) {
// The runner builds the agent and launches the app with -javaagent before invoking this task,
// so the agent jar is tracked for content only (by path, no cross-project task dependency): a
// change to it makes systemTest out of date even though it runs outside the test JVM.
val version = providers.gradleProperty("versionName").get()
inputs
.files(
rootProject.layout.projectDirectory.file(
"sentry-opentelemetry/sentry-opentelemetry-agent/build/libs/" +
"sentry-opentelemetry-agent-$version.jar"
)
)
.withPropertyName("openTelemetryAgent")
.withNormalizer(ClasspathNormalizer::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.sentry.gradle

import org.gradle.api.provider.Property

/** Configuration for the `io.sentry.systemtest` convention plugin. */
abstract class SystemTestExtension {
/**
* Set to `true` for samples that the system-test runner launches with the Sentry OpenTelemetry
* Java agent (`-javaagent`). The agent jar is then tracked as a `systemTest` input so the task
* re-runs when the agent changes, even though it is started outside the test JVM.
*/
abstract val usesOpenTelemetryAgent: Property<Boolean>

init {
usesOpenTelemetryAgent.convention(false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.shadow)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.console.Main") }
Expand Down Expand Up @@ -71,8 +72,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.shadow)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.console.Main") }
Expand Down Expand Up @@ -74,8 +75,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
3 changes: 1 addition & 2 deletions sentry-samples/sentry-samples-console/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.shadow)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.console.Main") }
Expand Down Expand Up @@ -75,8 +76,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

Comment thread
cursor[bot] marked this conversation as resolved.
maxParallelForks = 1

// Cap JVM args per test
Expand Down
3 changes: 1 addition & 2 deletions sentry-samples/sentry-samples-jul/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.shadow)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.jul.Main") }
Expand Down Expand Up @@ -66,8 +67,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
3 changes: 1 addition & 2 deletions sentry-samples/sentry-samples-log4j2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.shadow)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.log4j2.Main") }
Expand Down Expand Up @@ -72,8 +73,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
3 changes: 1 addition & 2 deletions sentry-samples/sentry-samples-logback/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.shadow)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.logback.Main") }
Expand Down Expand Up @@ -66,8 +67,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
3 changes: 1 addition & 2 deletions sentry-samples/sentry-samples-spring-7/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
alias(libs.plugins.kotlin.spring)
id("war")
alias(libs.plugins.gretty)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.spring7.Main") }
Expand Down Expand Up @@ -77,8 +78,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-4"
Expand Down Expand Up @@ -90,8 +91,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-4"
Expand Down Expand Up @@ -110,6 +111,9 @@ tasks.register<BootRun>("bootRunWithAgent").configure {
jvmArgs = listOf("-Dotel.javaagent.debug=true", "-javaagent:$agentJarPath")
}

// The runner launches this sample with -javaagent, so track the agent jar as a systemTest input.
sentrySystemTest { usesOpenTelemetryAgent = true }

tasks.register<Test>("systemTest").configure {
group = "verification"
description = "Runs the System tests"
Expand All @@ -118,8 +122,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-4-otlp"
Expand Down Expand Up @@ -91,8 +92,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-4-webflux"
Expand Down Expand Up @@ -70,8 +71,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-4"
Expand Down Expand Up @@ -92,8 +93,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-jakarta"
Expand Down Expand Up @@ -95,8 +96,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-jakarta"
Expand Down Expand Up @@ -120,6 +121,9 @@ tasks.register<BootRun>("bootRunWithAgent").configure {
jvmArgs = listOf("-Dotel.javaagent.debug=true", "-javaagent:$agentJarPath")
}

// The runner launches this sample with -javaagent, so track the agent jar as a systemTest input.
sentrySystemTest { usesOpenTelemetryAgent = true }

tasks.register<Test>("systemTest").configure {
group = "verification"
description = "Runs the System tests"
Expand All @@ -128,8 +132,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-jakarta"
Expand Down Expand Up @@ -98,8 +99,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.shadow)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.spring.boot.SentryDemoApplication") }
Expand Down Expand Up @@ -140,8 +141,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.shadow)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.spring.boot.SentryDemoApplication") }
Expand Down Expand Up @@ -154,6 +155,9 @@ tasks.register<JavaExec>("bootRunWithAgent").configure {
jvmArgs = listOf("-Dotel.javaagent.debug=true", "-javaagent:$agentJarPath")
}

// The runner launches this sample with -javaagent, so track the agent jar as a systemTest input.
sentrySystemTest { usesOpenTelemetryAgent = true }

tasks.register<Test>("systemTest").configure {
group = "verification"
description = "Runs the System tests"
Expand All @@ -162,8 +166,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.spring)
id("io.sentry.systemtest")
}

group = "io.sentry.sample.spring-boot-webflux-jakarta"
Expand Down Expand Up @@ -72,8 +73,6 @@ tasks.register<Test>("systemTest").configure {
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

outputs.upToDateWhen { false }

maxParallelForks = 1

// Cap JVM args per test
Expand Down
Loading
Loading