You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2023/03/03 09:31:09 UTC

[skywalking-java] branch main updated: fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x (#466)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git


The following commit(s) were added to refs/heads/main by this push:
     new 122d0064f0 fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x (#466)
122d0064f0 is described below

commit 122d0064f0418dcad3aefe856a7168820bb4484b
Author: xzyJavaX <49...@users.noreply.github.com>
AuthorDate: Fri Mar 3 17:31:02 2023 +0800

    fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x (#466)
---
 .github/workflows/plugins-tomcat9-test.0.yaml      | 69 +++++++++++++++++
 CHANGES.md                                         |  1 +
 .../plugin/tomcat10x/TomcatInvokeInterceptor.java  | 11 +--
 .../spring-6.x-scenario/config/expectedData.yaml   |  4 +-
 .../tomcat-10x-scenario/config/expectedData.yaml   |  2 +
 .../config/expectedData.yaml                       | 20 ++---
 .../scenarios/tomcat-9x-scenario/configuration.yml | 19 +++++
 test/plugin/scenarios/tomcat-9x-scenario/pom.xml   | 86 ++++++++++++++++++++++
 .../apm/testcase/tomcat9x/CaseServlet.java         | 61 +++++++++++++++
 .../apm/testcase/tomcat9x/ErrorCatchServlet.java   | 40 ++++++++++
 .../apm/testcase/tomcat9x/HealthCheckServlet.java  | 40 ++++++++++
 .../src/main/resources/log4j2.xml                  | 30 ++++++++
 .../src/main/webapp/WEB-INF/web.xml                | 58 +++++++++++++++
 .../tomcat-9x-scenario/support-version.list        | 19 +++++
 14 files changed, 440 insertions(+), 20 deletions(-)

diff --git a/.github/workflows/plugins-tomcat9-test.0.yaml b/.github/workflows/plugins-tomcat9-test.0.yaml
new file mode 100644
index 0000000000..8f54080254
--- /dev/null
+++ b/.github/workflows/plugins-tomcat9-test.0.yaml
@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Test
+
+on:
+  pull_request:
+    paths:
+      - '.github/workflows/plugins-*.yaml'
+      - 'apm-application-toolkit/**'
+      - 'apm-commons/**'
+      - 'apm-protocol/**'
+      - 'apm-sniffer/**'
+      - 'test/plugin/**'
+      - '**/pom.xml'
+      - '!**.md'
+
+concurrency:
+  group: plugins-tomcat9-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  build:
+    name: Build
+    runs-on: ubuntu-latest
+    timeout-minutes: 30
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          submodules: true
+      - name: Build
+        uses: ./.github/actions/build
+        with:
+          base_image_tomcat: tomcat:9.0.71-jdk8
+
+  test:
+    needs: [ build ]
+    name: ${{ matrix.case }}
+    runs-on: ubuntu-latest
+    timeout-minutes: 90
+    strategy:
+      matrix:
+        case:
+          - tomcat-9x-scenario
+    steps:
+      - uses: actions/checkout@v2
+        with:
+          submodules: true
+      - uses: actions/setup-java@v2
+        with:
+          distribution: temurin
+          java-version: 8
+      - name: Run Plugin Test
+        uses: ./.github/actions/run
+        with:
+          test_case: ${{ matrix.case }}
diff --git a/CHANGES.md b/CHANGES.md
index 7898f75a83..3fbe3a8971 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -18,6 +18,7 @@ Release Notes.
 * Change gRPC instrumentation point to fix plugin not working for server side.
 * Fix servicecomb plugin trace break.
 * Adapt Armeria's plugins to the latest version 1.22.x
+* Fix tomcat-10x-plugin and add test case to support tomcat7.x-8.x-9.x.
 
 #### Documentation
 * Update docs of Tracing APIs, reorganize the API docs into six parts.
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java
index fde1fc2700..52bedf994d 100644
--- a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java
@@ -31,7 +31,6 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedI
 import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
 import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
 import org.apache.skywalking.apm.agent.core.util.CollectionUtil;
-import org.apache.skywalking.apm.agent.core.util.MethodUtil;
 import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
 import org.apache.skywalking.apm.util.StringUtil;
 import org.apache.tomcat.util.http.Parameters;
@@ -43,15 +42,9 @@ import java.util.Map;
 
 public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor {
 
-    private static boolean IS_SERVLET_GET_STATUS_METHOD_EXIST;
     private static final String SERVLET_RESPONSE_CLASS = "jakarta.servlet.http.HttpServletResponse";
     private static final String GET_STATUS_METHOD = "getStatus";
 
-    static {
-        IS_SERVLET_GET_STATUS_METHOD_EXIST = MethodUtil.isMethodExist(
-            TomcatInvokeInterceptor.class.getClassLoader(), SERVLET_RESPONSE_CLASS, GET_STATUS_METHOD);
-    }
-
     @Override
     public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
                              MethodInterceptResult result) throws Throwable {
@@ -82,9 +75,9 @@ public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor
         HttpServletResponse response = (HttpServletResponse) allArguments[1];
 
         AbstractSpan span = ContextManager.activeSpan();
-        if (IS_SERVLET_GET_STATUS_METHOD_EXIST && response.getStatus() >= 400) {
+        Tags.HTTP_RESPONSE_STATUS_CODE.set(span, response.getStatus());
+        if (response.getStatus() >= 400) {
             span.errorOccurred();
-            Tags.HTTP_RESPONSE_STATUS_CODE.set(span, response.getStatus());
         }
         // Active HTTP parameter collection automatically in the profiling context.
         if (!TomcatPluginConfig.Plugin.Tomcat.COLLECT_HTTP_PARAMS && span.isProfiling()) {
diff --git a/test/plugin/scenarios/spring-6.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-6.x-scenario/config/expectedData.yaml
index 15d6e7326f..926a3f2b4c 100644
--- a/test/plugin/scenarios/spring-6.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/spring-6.x-scenario/config/expectedData.yaml
@@ -104,7 +104,7 @@ segmentItems:
       tags:
       - {key: url, value: 'http://localhost:8080/spring-6.x-scenario/create/'}
       - {key: http.method, value: POST}
-      - {key: http.status_code, value: '200'}
+      - {key: http.status_code, value: '201'}
       refs:
       - {parentEndpoint: GET:/case/resttemplate, networkAddress: 'localhost:8080', refType: CrossProcess,
         parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not
@@ -167,7 +167,7 @@ segmentItems:
       tags:
       - {key: url, value: 'http://localhost:8080/spring-6.x-scenario/delete/1'}
       - {key: http.method, value: DELETE}
-      - {key: http.status_code, value: '200'}
+      - {key: http.status_code, value: '204'}
       refs:
       - {parentEndpoint:  GET:/case/resttemplate, networkAddress: 'localhost:8080', refType: CrossProcess,
         parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml b/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml
index b8fa2322f7..dc03590cdd 100644
--- a/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml
@@ -34,6 +34,7 @@ segmentItems:
       tags:
       - {key: url, value: 'http://localhost:8080/tomcat-10x-scenario/case/tomcat-10x-scenario'}
       - {key: http.method, value: POST}
+      - {key: http.status_code, value: "200"}
       refs:
       - {parentEndpoint: 'GET:/tomcat-10x-scenario/case/tomcat-10x-scenario', networkAddress: 'localhost:8080',
         refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null,
@@ -72,3 +73,4 @@ segmentItems:
       tags:
       - {key: url, value: 'http://localhost:8080/tomcat-10x-scenario/case/tomcat-10x-scenario'}
       - {key: http.method, value: GET}
+      - {key: http.status_code, value: "200"}
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml b/test/plugin/scenarios/tomcat-9x-scenario/config/expectedData.yaml
similarity index 70%
copy from test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml
copy to test/plugin/scenarios/tomcat-9x-scenario/config/expectedData.yaml
index b8fa2322f7..10bd8bee30 100644
--- a/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/tomcat-9x-scenario/config/expectedData.yaml
@@ -14,12 +14,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 segmentItems:
-- serviceName: tomcat-10x-scenario
+- serviceName: tomcat-9x-scenario
   segmentSize: ge 2
   segments:
   - segmentId: not null
     spans:
-    - operationName: POST:/tomcat-10x-scenario/case/tomcat-10x-scenario
+    - operationName: POST:/tomcat-9x-scenario/case/tomcat-9x-scenario
       operationId: 0
       parentSpanId: -1
       spanId: 0
@@ -32,16 +32,17 @@ segmentItems:
       peer: ''
       skipAnalysis: false
       tags:
-      - {key: url, value: 'http://localhost:8080/tomcat-10x-scenario/case/tomcat-10x-scenario'}
+      - {key: url, value: 'http://localhost:8080/tomcat-9x-scenario/case/tomcat-9x-scenario'}
       - {key: http.method, value: POST}
+      - {key: http.status_code, value: "200"}
       refs:
-      - {parentEndpoint: 'GET:/tomcat-10x-scenario/case/tomcat-10x-scenario', networkAddress: 'localhost:8080',
+      - {parentEndpoint: 'GET:/tomcat-9x-scenario/case/tomcat-9x-scenario', networkAddress: 'localhost:8080',
         refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null,
-        parentServiceInstance: not null, parentService: tomcat-10x-scenario,
+        parentServiceInstance: not null, parentService: tomcat-9x-scenario,
         traceId: not null}
   - segmentId: not null
     spans:
-    - operationName: /tomcat-10x-scenario/case/tomcat-10x-scenario
+    - operationName: /tomcat-9x-scenario/case/tomcat-9x-scenario
       operationId: 0
       parentSpanId: 0
       spanId: 1
@@ -54,10 +55,10 @@ segmentItems:
       peer: localhost:8080
       skipAnalysis: false
       tags:
-      - {key: url, value: 'http://localhost:8080/tomcat-10x-scenario/case/tomcat-10x-scenario'}
+      - {key: url, value: 'http://localhost:8080/tomcat-9x-scenario/case/tomcat-9x-scenario'}
       - {key: http.method, value: POST}
       - {key: http.status_code, value: "200"}
-    - operationName: GET:/tomcat-10x-scenario/case/tomcat-10x-scenario
+    - operationName: GET:/tomcat-9x-scenario/case/tomcat-9x-scenario
       operationId: 0
       parentSpanId: -1
       spanId: 0
@@ -70,5 +71,6 @@ segmentItems:
       peer: ''
       skipAnalysis: false
       tags:
-      - {key: url, value: 'http://localhost:8080/tomcat-10x-scenario/case/tomcat-10x-scenario'}
+      - {key: url, value: 'http://localhost:8080/tomcat-9x-scenario/case/tomcat-9x-scenario'}
       - {key: http.method, value: GET}
+      - {key: http.status_code, value: "200"}
diff --git a/test/plugin/scenarios/tomcat-9x-scenario/configuration.yml b/test/plugin/scenarios/tomcat-9x-scenario/configuration.yml
new file mode 100644
index 0000000000..523a817486
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-9x-scenario/configuration.yml
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+type: tomcat
+entryService: http://localhost:8080/tomcat-9x-scenario/case/tomcat-9x-scenario
+healthCheck: http://localhost:8080/tomcat-9x-scenario/case/healthCheck
diff --git a/test/plugin/scenarios/tomcat-9x-scenario/pom.xml b/test/plugin/scenarios/tomcat-9x-scenario/pom.xml
new file mode 100644
index 0000000000..308cb5cd10
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-9x-scenario/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <groupId>org.apache.skywalking.apm.testcase</groupId>
+    <artifactId>tomcat-9x-scenario</artifactId>
+    <version>1.0.0</version>
+    <packaging>war</packaging>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <name>skywalking-tomcat-9x-scenario</name>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <compiler.version>1.8</compiler.version>
+        <test.framework.version>1.0</test.framework.version>
+        <lombok.version>1.18.20</lombok.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>4.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>2.8.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>2.8.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>${lombok.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.3</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>tomcat-9x-scenario</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>3.3.1</version>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>${compiler.version}</source>
+                    <target>${compiler.version}</target>
+                    <encoding>${project.build.sourceEncoding}</encoding>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/CaseServlet.java b/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/CaseServlet.java
new file mode 100644
index 0000000000..9b47be8639
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/CaseServlet.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.testcase.tomcat9x;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class CaseServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+            HttpPost httpPost = new HttpPost("http://localhost:8080/tomcat-9x-scenario/case/tomcat-9x-scenario");
+            ResponseHandler<String> responseHandler = response -> {
+                HttpEntity entity = response.getEntity();
+                return entity != null ? EntityUtils.toString(entity) : null;
+            };
+            httpClient.execute(httpPost, responseHandler);
+        }
+        PrintWriter writer = resp.getWriter();
+        writer.write("Success1");
+        writer.flush();
+        writer.close();
+    }
+
+    @Override
+    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        PrintWriter writer = resp.getWriter();
+        writer.write("Success2");
+        writer.flush();
+        writer.close();
+    }
+
+}
diff --git a/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/ErrorCatchServlet.java b/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/ErrorCatchServlet.java
new file mode 100644
index 0000000000..94967b210f
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/ErrorCatchServlet.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.testcase.tomcat9x;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class ErrorCatchServlet extends HttpServlet {
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        PrintWriter writer = resp.getWriter();
+        writer.write("404");
+        writer.flush();
+    }
+
+    @Override
+    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        doGet(req, resp);
+    }
+}
diff --git a/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/HealthCheckServlet.java b/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/HealthCheckServlet.java
new file mode 100644
index 0000000000..c5de6f07dd
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-9x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat9x/HealthCheckServlet.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.skywalking.apm.testcase.tomcat9x;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class HealthCheckServlet extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        PrintWriter writer = resp.getWriter();
+        writer.write("Success");
+        writer.flush();
+    }
+
+    @Override
+    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        doGet(req, resp);
+    }
+}
diff --git a/test/plugin/scenarios/tomcat-9x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/tomcat-9x-scenario/src/main/resources/log4j2.xml
new file mode 100644
index 0000000000..9849ed5a8a
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-9x-scenario/src/main/resources/log4j2.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+<Configuration status="WARN">
+    <Appenders>
+        <Console name="Console" target="SYSTEM_ERR">
+            <PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="WARN">
+            <AppenderRef ref="Console"/>
+        </Root>
+    </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/test/plugin/scenarios/tomcat-9x-scenario/src/main/webapp/WEB-INF/web.xml b/test/plugin/scenarios/tomcat-9x-scenario/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..3a5de52afd
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-9x-scenario/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,58 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
+                      https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
+         version="5.0">
+    <display-name>skywalking-tomcat-9x-scenario</display-name>
+
+    <servlet>
+        <servlet-name>caseServlet</servlet-name>
+        <servlet-class>org.apache.skywalking.apm.testcase.tomcat9x.CaseServlet</servlet-class>
+    </servlet>
+
+    <servlet>
+        <servlet-name>healthCheck</servlet-name>
+        <servlet-class>org.apache.skywalking.apm.testcase.tomcat9x.HealthCheckServlet</servlet-class>
+    </servlet>
+
+    <servlet>
+        <servlet-name>errorCatch</servlet-name>
+        <servlet-class>org.apache.skywalking.apm.testcase.tomcat9x.ErrorCatchServlet</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>errorCatch</servlet-name>
+        <url-pattern>/case/errorCatch</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>healthCheck</servlet-name>
+        <url-pattern>/case/healthCheck</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>caseServlet</servlet-name>
+        <url-pattern>/case/tomcat-9x-scenario</url-pattern>
+    </servlet-mapping>
+    <error-page>
+        <error-code>404</error-code>
+        <location>/case/errorCatch</location>
+    </error-page>
+</web-app>
diff --git a/test/plugin/scenarios/tomcat-9x-scenario/support-version.list b/test/plugin/scenarios/tomcat-9x-scenario/support-version.list
new file mode 100644
index 0000000000..f4b16fb8ba
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-9x-scenario/support-version.list
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Use `.github/workflows/plugins-tomcat9-test.0.yaml` to control Tomcat verion
+# Current tested Tomcat 9.0.71
+all