Skip to content

Commit

Permalink
Convert log4j test to test suites (#7942)
Browse files Browse the repository at this point in the history
Part of
#7911
  • Loading branch information
laurit authored Mar 1, 2023
1 parent 13c7617 commit f8927a4
Showing 1 changed file with 26 additions and 14 deletions.
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)
}
}

0 comments on commit f8927a4

Please sign in to comment.