Enable strict context check on grizzly (#3921)

* Enable strict context check on grizzly

* add comment

* move wait to base class
This commit is contained in:
Lauri Tulmin 2021-08-24 21:46:30 +03:00 committed by GitHub
parent a2928663f4
commit ec585c7717
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View File

@ -26,11 +26,5 @@ tasks.withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.grizzly.enabled=true")
}
tasks.withType<Test>().configureEach {
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/2640
jvmArgs("-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false")
}
// Requires old Guava. Can't use enforcedPlatform since predates BOM
configurations.testRuntimeClasspath.resolutionStrategy.force("com.google.guava:guava:19.0")

View File

@ -8,9 +8,11 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
import static org.awaitility.Awaitility.await
import io.opentelemetry.instrumentation.test.AgentTestTrait
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import java.util.concurrent.TimeUnit
import javax.ws.rs.GET
import javax.ws.rs.NotFoundException
import javax.ws.rs.Path
@ -45,6 +47,23 @@ class GrizzlyTest extends HttpServerTest<HttpServer> implements AgentTestTrait {
server.stop()
}
def cleanup() {
// wait for async request threads to complete
await()
.atMost(15, TimeUnit.SECONDS)
.until({ !isRequestRunning() })
}
static boolean isRequestRunning() {
def result = Thread.getAllStackTraces().values().find {stackTrace ->
def element = stackTrace.find {
return ((it.className == "org.glassfish.grizzly.http.server.HttpHandler\$1" && it.methodName == "run"))
}
element != null
}
return result != null
}
static class SimpleExceptionMapper implements ExceptionMapper<Throwable> {
@Override