Add more testable servlets to some test app, update tomcat 10 and jetty 10 versions
MODIFY
smoke-tests/matrix/build.gradle
smoke-tests/matrix/build.gradle
@@ -33,13 +33,13 @@ tasks.create("pushMatrix", DockerPushImage) {
def targets = [
"jetty" : [
"9.4.35": ["8", "11", "15"],
- "10.0.0.beta3": ["11", "15"],
+ "10.0.0": ["11", "15"],
],
"tomcat" : [
"7.0.107": ["8"],
"8.5.60" : ["8", "11"],
"9.0.40" : ["8", "11"],
- "10.0.0-M10": ["8", "11"]
+ "10.0.0" : ["8", "11"]
],
"payara" : [
"5.2020.6" : ["8"],

ADD
smoke-tests/matrix/src/main/java/io/opentelemetry/smoketest/matrix/AsyncGreetingServlet.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.smoketest.matrix;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class AsyncGreetingServlet extends GreetingServlet {
+ private static final BlockingQueue<AsyncContext> jobQueue = new LinkedBlockingQueue<>();
+ private static final ExecutorService executor = Executors.newFixedThreadPool(2);
+
+ @Override
+ public void init() throws ServletException {
+ executor.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ while (true) {
+ AsyncContext ac = jobQueue.take();
+ executor.submit(() -> handleRequest(ac));
+ }
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void destroy() {
+ executor.shutdownNow();
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
+ AsyncContext ac = req.startAsync(req, resp);
+ jobQueue.add(ac);
+ }
+
+ private void handleRequest(AsyncContext ac) {
+ ac.dispatch("/greeting");
+ }
+
+}

ADD
smoke-tests/matrix/src/main/java/io/opentelemetry/smoketest/matrix/ExceptionRequestListener.java
+package io.opentelemetry.smoketest.matrix;
+
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+
+public class ExceptionRequestListener implements ServletRequestListener {
+
+ @Override
+ public void requestDestroyed(ServletRequestEvent sre) {
+ if ("true".equals(sre.getServletRequest().getParameter("throwOnRequestDestroyed"))) {
+ throw new RuntimeException("This is expected");
+ }
+ }
+
+ @Override
+ public void requestInitialized(ServletRequestEvent sre) {
+ if ("true".equals(sre.getServletRequest().getParameter("throwOnRequestInitialized"))) {
+ throw new RuntimeException("This is expected");
+ }
+ }
+}

ADD
smoke-tests/matrix/src/main/java/io/opentelemetry/smoketest/matrix/ExceptionServlet.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.smoketest.matrix;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ExceptionServlet extends HttpServlet {
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+ throw new RuntimeException("This is expected");
+ }
+}

ADD
smoke-tests/matrix/src/main/java/io/opentelemetry/smoketest/matrix/ForwardServlet.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.smoketest.matrix;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ForwardServlet extends HttpServlet {
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.getRequestDispatcher("/hello.txt").forward(req, resp);
+ }
+}

ADD
smoke-tests/matrix/src/main/java/io/opentelemetry/smoketest/matrix/IncludeServlet.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.smoketest.matrix;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class IncludeServlet extends HttpServlet {
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ req.getRequestDispatcher("/hello.txt").include(req, resp);
+ }
+}

MODIFY
smoke-tests/matrix/src/main/webapp/WEB-INF/web.xml
smoke-tests/matrix/src/main/webapp/WEB-INF/web.xml
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
+ <listener>
+ <listener-class>io.opentelemetry.smoketest.matrix.ExceptionRequestListener</listener-class>
+ </listener>
<servlet>
<servlet-name>Headers</servlet-name>
<servlet-class>io.opentelemetry.smoketest.matrix.HeaderDumpingServlet</servlet-class>
<servlet-name>Greeting</servlet-name>
<servlet-class>io.opentelemetry.smoketest.matrix.GreetingServlet</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>AsyncGreeting</servlet-name>
+ <servlet-class>io.opentelemetry.smoketest.matrix.AsyncGreetingServlet</servlet-class>
+ <async-supported>true</async-supported>
+ </servlet>
+ <servlet>
+ <servlet-name>Exception</servlet-name>
+ <servlet-class>io.opentelemetry.smoketest.matrix.ExceptionServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Forward</servlet-name>
+ <servlet-class>io.opentelemetry.smoketest.matrix.ForwardServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>Include</servlet-name>
+ <servlet-class>io.opentelemetry.smoketest.matrix.IncludeServlet</servlet-class>
+ </servlet>
<servlet>
<servlet-name>Jsp</servlet-name>
<servlet-class>io.opentelemetry.smoketest.matrix.JspServlet</servlet-class>
<servlet-name>Greeting</servlet-name>
<url-pattern>/greeting</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>AsyncGreeting</servlet-name>
+ <url-pattern>/asyncgreeting</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Exception</servlet-name>
+ <url-pattern>/exception</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Forward</servlet-name>
+ <url-pattern>/forward</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Include</servlet-name>
+ <url-pattern>/include</url-pattern>
+ </servlet-mapping>
<servlet-mapping>
<servlet-name>Jsp</servlet-name>
<url-pattern>/jsp</url-pattern>

ADD
smoke-tests/matrix/src/main/webapp/hello.txt
+Hello
\ No newline at end of file

Add more testable servlets to some test app, update tomcat 10 and jetty 10 versions (#1899)