Remove glassfish-testing module
DELETE
instrumentation/servlet/glassfish-testing/glassfish-testing.gradle
-ext {
- maxJavaVersionForTests = JavaVersion.VERSION_1_8
- skipPublish = true
-}
-
-apply from: "$rootDir/gradle/instrumentation.gradle"
-
-dependencies {
- testInstrumentation project(':instrumentation:servlet:servlet-3.0:javaagent')
- testInstrumentation project(':instrumentation:servlet:servlet-javax-common:javaagent')
- testInstrumentation project(':instrumentation:grizzly-2.0:javaagent')
-
- testCompileOnly "org.glassfish.main.common:scattered-archive-api:4.1"
- testCompileOnly "org.glassfish.main.common:simple-glassfish-api:4.1"
- testCompileOnly "javax.servlet:javax.servlet-api:3.0.1"
- if (!testLatestDeps) {
- testRuntimeOnly "org.glassfish.main.extras:glassfish-embedded-all:4.1"
- } else {
- testRuntimeOnly "org.glassfish.main.extras:glassfish-embedded-all:5.1.0"
- }
-}
-
-tasks.withType(Test).configureEach {
- jvmArgs "-Djava.awt.headless=true"
-}

DELETE
instrumentation/servlet/glassfish-testing/src/test/groovy/GlassFishServerTest.groovy
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
-import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
-import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
-
-import io.opentelemetry.instrumentation.test.AgentTestTrait
-import io.opentelemetry.instrumentation.test.asserts.TraceAssert
-import io.opentelemetry.instrumentation.test.base.HttpServerTest
-import org.glassfish.embeddable.BootstrapProperties
-import org.glassfish.embeddable.Deployer
-import org.glassfish.embeddable.GlassFish
-import org.glassfish.embeddable.GlassFishProperties
-import org.glassfish.embeddable.GlassFishRuntime
-import org.glassfish.embeddable.archive.ScatteredArchive
-
-/**
- * Unfortunately because we're using an embedded GlassFish instance, we aren't exercising the standard
- * OSGi setup that requires {@link io.opentelemetry.javaagent.instrumentation.javaclassloader.ClassloadingInstrumentation}.
- */
-// TODO: Figure out a better way to test with OSGi included.
-class GlassFishServerTest extends HttpServerTest<GlassFish> implements AgentTestTrait {
-
- @Override
- String getContextPath() {
- "/test-gf"
- }
-
- @Override
- GlassFish startServer(int port) {
- // Setup the deployment archive
- def testDir = new File(TestServlets.protectionDomain.codeSource.location.path)
- assert testDir.exists() && testDir.directory
- def testResourcesDir = new File(TestServlets.getResource("error.jsp").path).parentFile
- assert testResourcesDir.exists() && testResourcesDir.directory
- ScatteredArchive archive = new ScatteredArchive(contextPath, ScatteredArchive.Type.WAR, testResourcesDir)
- archive.addClassPath(testDir)
-
- // Initialize the server
- BootstrapProperties bootstrapProperties = new BootstrapProperties()
- GlassFishRuntime glassfishRuntime = GlassFishRuntime.bootstrap(bootstrapProperties)
- GlassFishProperties glassfishProperties = new GlassFishProperties()
- glassfishProperties.setPort('http-listener', port)
- def server = glassfishRuntime.newGlassFish(glassfishProperties)
- server.start()
-
- // Deploy war to server
- Deployer deployer = server.getDeployer()
- println "Deploying $testDir.absolutePath with $testResourcesDir.absolutePath"
- deployer.deploy(archive.toURI())
-
- return server
- }
-
- @Override
- void stopServer(GlassFish server) {
- server.stop()
- }
-
- @Override
- boolean hasResponseSpan(ServerEndpoint endpoint) {
- endpoint == REDIRECT || endpoint == ERROR || endpoint == NOT_FOUND
- }
-
- @Override
- void responseSpan(TraceAssert trace, int index, Object parent, String method, ServerEndpoint endpoint) {
- switch (endpoint) {
- case REDIRECT:
- redirectSpan(trace, index, parent)
- break
- case ERROR:
- case NOT_FOUND:
- sendErrorSpan(trace, index, parent)
- break
- }
- }
-}

DELETE
instrumentation/servlet/glassfish-testing/src/test/java/TestServlets.java
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import io.opentelemetry.instrumentation.test.base.HttpServerTest;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public class TestServlets {
-
- @WebServlet("/success")
- public static class Success extends HttpServlet {
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse resp) {
- HttpServerTest.ServerEndpoint endpoint =
- HttpServerTest.ServerEndpoint.forPath(req.getServletPath());
- HttpServerTest.controller(
- endpoint,
- () -> {
- resp.setContentType("text/plain");
- resp.setStatus(endpoint.getStatus());
- resp.getWriter().print(endpoint.getBody());
- return null;
- });
- }
- }
-
- @WebServlet("/query")
- public static class Query extends HttpServlet {
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse resp) {
- HttpServerTest.ServerEndpoint endpoint =
- HttpServerTest.ServerEndpoint.forPath(req.getServletPath());
- HttpServerTest.controller(
- endpoint,
- () -> {
- resp.setContentType("text/plain");
- resp.setStatus(endpoint.getStatus());
- resp.getWriter().print(req.getQueryString());
- return null;
- });
- }
- }
-
- @WebServlet("/redirect")
- public static class Redirect extends HttpServlet {
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse resp) {
- HttpServerTest.ServerEndpoint endpoint =
- HttpServerTest.ServerEndpoint.forPath(req.getServletPath());
- HttpServerTest.controller(
- endpoint,
- () -> {
- resp.sendRedirect(endpoint.getBody());
- return null;
- });
- }
- }
-
- @WebServlet("/error-status")
- public static class ErrorServlet extends HttpServlet {
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse resp) {
- HttpServerTest.ServerEndpoint endpoint =
- HttpServerTest.ServerEndpoint.forPath(req.getServletPath());
- HttpServerTest.controller(
- endpoint,
- () -> {
- resp.setContentType("text/plain");
- resp.sendError(endpoint.getStatus(), endpoint.getBody());
- return null;
- });
- }
- }
-
- @WebServlet("/exception")
- public static class ExceptionServlet extends HttpServlet {
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse resp) {
- HttpServerTest.ServerEndpoint endpoint =
- HttpServerTest.ServerEndpoint.forPath(req.getServletPath());
- HttpServerTest.controller(
- endpoint,
- () -> {
- throw new Exception(endpoint.getBody());
- });
- }
- }
-}

DELETE
instrumentation/servlet/glassfish-testing/src/test/resources/WEB-INF/web.xml
-<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
- http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
- version="3.1">
-
- <error-page>
- <location>/error.jsp</location>
- </error-page>
-</web-app>

DELETE
instrumentation/servlet/glassfish-testing/src/test/resources/error.jsp
-<%@ page contentType="text/plain;charset=UTF-8" isErrorPage="true" trimDirectiveWhitespaces="true" %>
-
-<% if (exception != null) {%>
- <%= exception.getMessage() %>
-<% } else { %>
- <%= request.getAttribute("javax.servlet.error.message") %>
-<% } %>

MODIFY
settings.gradle
settings.gradle
@@ -266,7 +266,6 @@ include ':instrumentation:rxjava:rxjava-3.0:library'
include ':instrumentation:rxjava:rxjava-3.0:testing'
include ':instrumentation:rxjava:rxjava-3.0:javaagent'
include ':instrumentation:scala-executors:javaagent'
-include ':instrumentation:servlet:glassfish-testing'
include ':instrumentation:servlet:servlet-common:library'
include ':instrumentation:servlet:servlet-common:javaagent'
include ':instrumentation:servlet:servlet-javax-common:library'

Remove glassfish-testing module (#3301)