Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert log4j test to test suites #7942

Merged
merged 1 commit into from
Mar 1, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("otel.javaagent-instrumentation")
id("org.unbroken-dome.test-sets")
}

muzzle {
Expand All @@ -12,14 +11,6 @@ muzzle {
}
}

testSets {
// Very different codepaths when threadlocals are enabled or not so we check both.
// Regression test for https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2403
create("testDisableThreadLocals") {
dirName = "test"
}
}

dependencies {
library("org.apache.logging.log4j:log4j-core:2.17.0")

Expand All @@ -30,12 +21,33 @@ dependencies {
testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
}

tasks {
val testDisableThreadLocals by existing(Test::class) {
jvmArgs("-Dlog4j2.is.webapp=false")
jvmArgs("-Dlog4j2.enable.threadlocals=false")
testing {
suites {
// Very different codepaths when threadlocals are enabled or not so we check both.
// Regression test for https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2403
val testDisableThreadLocals by registering(JvmTestSuite::class) {
sources {
groovy {
setSrcDirs(listOf("src/test/groovy"))
}
}
dependencies {
implementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))
}

targets {
all {
testTask.configure {
jvmArgs("-Dlog4j2.is.webapp=false")
jvmArgs("-Dlog4j2.enable.threadlocals=false")
}
}
}
}
}
}

tasks {
// Threadlocals are always false if is.webapp is true, so we make sure to override it because as of
// now testing-common includes jetty / servlet.
test {
Expand All @@ -44,6 +56,6 @@ tasks {
}

named("check") {
dependsOn(testDisableThreadLocals)
dependsOn(testing.suites)
}
}