Remove unnecessary libs from javaagent test classpath (#2545)

* Remove unnecessary libs from javaagent test classpath

All `javaagent` & `library` modules are now filtered out: for instance, `hibernate-3.3:javaagent` tests no longer have `hibernate-common:javaagent` on classpath (previously they had).

Honestly this is kind of hacky, but I don't know gradle enough to solve that "properly" - maybe it is possible to filter out all `implementation` libraries from the classpath?

* spotless
This commit is contained in:
Mateusz Rzeszutek 2021-03-11 07:56:24 +01:00 committed by GitHub
parent 999a78c9ee
commit 97fa9932d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -130,9 +130,13 @@ tasks.withType(Test).configureEach {
if (file("$buildDir/resources/main").equals(it) || file("$buildDir/classes/java/main").equals(it)) {
return false
}
// If agent depends on library instrumentation, it will be packaged into the testing jar so we
// need to make sure to exclude from the test classpath.
if (it.absolutePath.startsWith(file("${projectDir.parent}/library/build/libs").absolutePath)) {
// If agent depends on some shared instrumentation module that is not a testing module, it will
// be packaged into the testing jar so we need to make sure to exclude from the test classpath.
String libPath = it.absolutePath
String instrumentationPath = file("${rootDir}/instrumentation/").absolutePath
if (libPath.startsWith(instrumentationPath) &&
libPath.endsWith(".jar") &&
!libPath.substring(instrumentationPath.size()).contains("testing")) {
return false
}
return true

View File

@ -6,7 +6,6 @@
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
import static io.opentelemetry.api.trace.SpanKind.SERVER
import io.opentelemetry.instrumentation.api.config.Config
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
@ -26,8 +25,6 @@ import server.TestController
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [SpringWebFluxTestApplication, ForceNettyAutoConfiguration])
class SpringWebfluxTest extends AgentInstrumentationSpecification {
static Config previousConfig
@TestConfiguration
static class ForceNettyAutoConfiguration {
@Bean