diff --git a/.github/workflows/plugins-test.yaml b/.github/workflows/plugins-test.yaml index 0317d8a0cc1b101b4e257af04feecf75b2b0baa7..db94cbe7c1b275468ea86102f4f8e830e3988ede 100644 --- a/.github/workflows/plugins-test.yaml +++ b/.github/workflows/plugins-test.yaml @@ -53,7 +53,7 @@ jobs: - name: Run okhttp 3.0.x-3.14.x (34) run: bash test/plugin/run.sh okhttp-scenario - Spring31x_ES5_Gateway_Avro: + Spring31x_ES5_Gateway_Avro_Struts25: runs-on: ubuntu-18.04 timeout-minutes: 90 strategy: @@ -83,6 +83,8 @@ jobs: run: bash test/plugin/run.sh elasticsearch-5.x-scenario - name: Run avro 1.7.0-1.8.2 (10) run: bash test/plugin/run.sh avro-scenario + - name: Run struts2.5-scenario (14) + run: bash test/plugin/run.sh struts2.5-scenario Toolkit_Webflux_SocketIO_RabbitMQ_GSON: runs-on: ubuntu-18.04 @@ -333,7 +335,7 @@ jobs: - name: Run zookeeper 3.4.x (14) run: bash test/plugin/run.sh zookeeper-scenario - Spring43: + Spring43_Struts23: runs-on: ubuntu-18.04 timeout-minutes: 90 strategy: @@ -357,6 +359,8 @@ jobs: run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local >/dev/null - name: Run spring 4.3.x-5.2.x (54) run: bash test/plugin/run.sh spring-4.3.x-scenario + - name: Run struts2.3-scenario (35) + run: bash test/plugin/run.sh struts2.3-scenario PostgreSQL94: runs-on: ubuntu-18.04 @@ -525,7 +529,7 @@ jobs: - name: Run mysql 5.1.2-8.0.15 (53) run: bash test/plugin/run.sh mysql-scenario - LETTUCE_PlayFramework: + LETTUCE_PlayFramework_H2: runs-on: ubuntu-18.04 timeout-minutes: 90 strategy: @@ -551,3 +555,5 @@ jobs: run: bash test/plugin/run.sh lettuce-scenario - name: Run Play! Framework run: bash test/plugin/run.sh play-scenario + - name: Run h2-scenario (24) + run: bash test/plugin/run.sh h2-scenario diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/pom.xml b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/pom.xml index 072ed85525916e87b7141a07c69015dc453a344c..026b5000a3b098a546d53cfea6fe46163ffa9b91 100644 --- a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/pom.xml +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/pom.xml @@ -30,10 +30,9 @@ UTF-8 1.8 - YOUR VERSION - 2.1.6.RELEASE + 1.18.10 skywalking-${scenario_name} @@ -65,6 +64,12 @@ org.springframework.boot spring-boot-starter-log4j2 + + org.projectlombok + lombok + ${lombok.version} + provided + diff --git a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/controller/CaseController.java b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/controller/CaseController.java index af5bd2315b49a1e562deaac42095ec6602d08bb5..cde343bc713d920f162c6b4eb892525d886e5439 100644 --- a/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/controller/CaseController.java +++ b/test/plugin/archetypes/jvm/src/main/resources/archetype-resources/src/main/java/controller/CaseController.java @@ -16,22 +16,18 @@ * */ -package $ +package ${package}.controller; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import lombok.extern.log4j.Log4j2; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; -{package}.controller; - @RestController @RequestMapping("/case") +@Log4j2 public class CaseController { - private static final Logger logger = LogManager.getLogger(CaseController.class); - private static final String SUCCESS = "Success"; @RequestMapping("/${scenario_case}") diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/pom.xml b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/pom.xml index 6316d61a3b814e5fd4800c5bf00ea4ccf2e1c395..7d4acfb0ad8acfd39aba9410a7611c7c915ec0e9 100644 --- a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/pom.xml +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/pom.xml @@ -33,6 +33,7 @@ UTF-8 1.8 YOUR VERSION + 1.18.10 @@ -52,6 +53,12 @@ log4j-core 2.8.1 + + org.projectlombok + lombok + ${lombok.version} + provided + diff --git a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/CaseServlet.java b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/CaseServlet.java index a65c423f00845acba68089a65be5afd21e88cede..ee6abc16126085cde8952c19a20503ae0eb91702 100644 --- a/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/CaseServlet.java +++ b/test/plugin/archetypes/tomcat/src/main/resources/archetype-resources/src/main/java/CaseServlet.java @@ -18,12 +18,12 @@ package $package; -import java.io.IOException; -import java.io.PrintWriter; 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 { diff --git a/test/plugin/scenarios/h2-scenario/bin/startup.sh b/test/plugin/scenarios/h2-scenario/bin/startup.sh new file mode 100644 index 0000000000000000000000000000000000000000..42b57dc3d33c9efb2fcf80d6742c2624ec449af6 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# 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. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/h2-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/h2-scenario/config/expectedData.yaml b/test/plugin/scenarios/h2-scenario/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..052ac92cc6452878810df9d7ccef770cee809da8 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/config/expectedData.yaml @@ -0,0 +1,115 @@ +# 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. +registryItems: + applications: + - {h2-scenario: 2} + instances: + - {h2-scenario: 1} + operationNames: + - h2-scenario: [/h2-scenario/case/h2-scenario] + heartbeat: [] +segmentItems: + - applicationCode: h2-scenario + segmentSize: gt 1 + segments: + - segmentId: not null + spans: + - operationName: H2/JDBI/PreparedStatement/execute + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 32 + componentName: '' + isError: false + spanType: Exit + peer: localhost:-1 + peerId: 0 + tags: + - {key: db.type, value: sql} + - {key: db.instance, value: test} + - key: db.statement + value: "CREATE TABLE test_007(\nid VARCHAR(1) PRIMARY KEY, \nvalue VARCHAR(1)\ + \ NOT NULL)" + - operationName: H2/JDBI/CallableStatement/execute + operationId: 0 + parentSpanId: 0 + spanId: 2 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 32 + componentName: '' + isError: false + spanType: Exit + peer: localhost:-1 + peerId: 0 + tags: + - {key: db.type, value: sql} + - {key: db.instance, value: test} + - {key: db.statement, value: 'INSERT INTO test_007(id, value) VALUES(?,?)'} + - operationName: H2/JDBI/Statement/execute + operationId: 0 + parentSpanId: 0 + spanId: 3 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 32 + componentName: '' + isError: false + spanType: Exit + peer: localhost:-1 + peerId: 0 + tags: + - {key: db.type, value: sql} + - {key: db.instance, value: test} + - {key: db.statement, value: DROP table test_007} + - operationName: H2/JDBI/Connection/close + operationId: 0 + parentSpanId: 0 + spanId: 4 + spanLayer: Database + startTime: gt 0 + endTime: gt 0 + componentId: 32 + componentName: '' + isError: false + spanType: Exit + peer: localhost:-1 + peerId: 0 + tags: + - {key: db.type, value: sql} + - {key: db.instance, value: test} + - {key: db.statement, value: ''} + - operationName: /h2-scenario/case/h2-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/h2-scenario/case/h2-scenario'} + - {key: http.method, value: GET} diff --git a/test/plugin/scenarios/h2-scenario/configuration.yml b/test/plugin/scenarios/h2-scenario/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..b109abb1f946f79b56c459cb62c466a256f4a746 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/configuration.yml @@ -0,0 +1,21 @@ +# 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: jvm +entryService: http://localhost:8080/h2-scenario/case/h2-scenario +healthCheck: http://localhost:8080/h2-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: h2-scenario \ No newline at end of file diff --git a/test/plugin/scenarios/h2-scenario/pom.xml b/test/plugin/scenarios/h2-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..e0f1dd2de7f8a1aea23cbfa30b58567d88595c53 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/pom.xml @@ -0,0 +1,124 @@ + + + + + org.apache.skywalking.apm.testcase + h2-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 1.4.177 + 2.1.6.RELEASE + 1.18.10 + + + skywalking-h2-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot-version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + com.h2database + h2 + ${test.framework.version} + + + + + h2-scenario + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/h2-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/h2-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000000000000000000000000000000000..cc43dda81b1800d916d5ed2c57332735a63cf9f1 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/h2-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/Application.java b/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/Application.java new file mode 100644 index 0000000000000000000000000000000000000000..8cdfba4bb563aa79b2e12671393dfb78dd78d6c9 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/Application.java @@ -0,0 +1,34 @@ +/* + * 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.h2; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/controller/CaseController.java b/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/controller/CaseController.java new file mode 100644 index 0000000000000000000000000000000000000000..32304af5b23349c23c4961eab728f9a46cbc0f49 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/controller/CaseController.java @@ -0,0 +1,60 @@ +/* + * 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.h2.controller; + +import lombok.extern.log4j.Log4j2; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +@Log4j2 +public class CaseController { + + private static final String SUCCESS = "Success"; + + private static final String CREATE_TABLE_SQL = "CREATE TABLE test_007(\n" + + "id VARCHAR(1) PRIMARY KEY, \n" + + "value VARCHAR(1) NOT NULL)"; + private static final String INSERT_DATA_SQL = "INSERT INTO test_007(id, value) VALUES(?,?)"; + private static final String DROP_TABLE_SQL = "DROP table test_007"; + + @RequestMapping("/h2-scenario") + @ResponseBody + public String testcase() throws Exception { + try (SQLExecutor sqlExecute = new SQLExecutor()) { + sqlExecute.createTable(CREATE_TABLE_SQL); + sqlExecute.insertData(INSERT_DATA_SQL, "1", "1"); + sqlExecute.dropTable(DROP_TABLE_SQL); + } catch (Exception e) { + log.error("Failed to execute sql.", e); + throw e; + } + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + // your codes + return SUCCESS; + } + +} diff --git a/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/controller/SQLExecutor.java b/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/controller/SQLExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..1f6e3b34636b716df1252d0c0deda9e887364ff7 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/src/main/java/org/apache/skywalking/apm/testcase/h2/controller/SQLExecutor.java @@ -0,0 +1,75 @@ +/* + * 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.h2.controller; + +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Statement; + +public class SQLExecutor implements AutoCloseable { + + private static final String URL = "jdbc:h2:mem:test"; + private static final String USERNAME = "root"; + private static final String PASSWORD = "root"; + + private Connection connection; + + public SQLExecutor() throws SQLException { + try { + Class.forName("org.h2.Driver"); + } catch (ClassNotFoundException e) { + // + } + connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); + } + + public void createTable(String sql) throws SQLException { + PreparedStatement preparedStatement = connection.prepareStatement(sql); + preparedStatement.execute(); + preparedStatement.close(); + } + + public void insertData(String sql, String id, String value) throws SQLException { + CallableStatement preparedStatement = connection.prepareCall(sql); + preparedStatement.setString(1, id); + preparedStatement.setString(2, value); + preparedStatement.execute(); + preparedStatement.close(); + } + + public void dropTable(String sql) throws SQLException { + Statement preparedStatement = connection.createStatement(); + preparedStatement.execute(sql); + preparedStatement.close(); + } + + public void closeConnection() throws SQLException { + if (this.connection != null) { + this.connection.close(); + } + } + + @Override + public void close() throws Exception { + closeConnection(); + } +} diff --git a/test/plugin/scenarios/h2-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/h2-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000000000000000000000000000000000..10fe9489d15ad4ba91fd45bb9c42c22d9d05b3df --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/src/main/resources/application.yaml @@ -0,0 +1,23 @@ +# +# 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. +# +# +server: + port: 8080 + servlet: + context-path: /h2-scenario +logging: + config: classpath:log4j2.xml \ No newline at end of file diff --git a/test/plugin/scenarios/h2-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/h2-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..9849ed5a8abd116a9000e64cc18f05e583f21c98 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/h2-scenario/support-version.list b/test/plugin/scenarios/h2-scenario/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..f2d7a43046ff549141e77dd95968906b90b640b4 --- /dev/null +++ b/test/plugin/scenarios/h2-scenario/support-version.list @@ -0,0 +1,41 @@ +# 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 +# "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. + +# lists your version here +1.4.177 +1.4.178 +1.4.179 +1.4.180 +1.4.181 +1.4.182 +1.4.183 +1.4.184 +1.4.185 +1.4.186 +1.4.187 +1.4.188 +1.4.189 +1.4.190 +1.4.191 +1.4.192 +1.4.193 +1.4.194 +1.4.195 +1.4.196 +1.4.197 +1.4.198 +1.4.199 +1.4.200 \ No newline at end of file diff --git a/test/plugin/scenarios/mysql-scenario/src/main/java/org/apache/skywalking/apm/testcase/mysql/SQLExecutor.java b/test/plugin/scenarios/mysql-scenario/src/main/java/org/apache/skywalking/apm/testcase/mysql/SQLExecutor.java index 405189907679fc0a15bfbac271ed15f03bf6a604..77e020534049f441c182ae6dbf96bd450c0aaaec 100644 --- a/test/plugin/scenarios/mysql-scenario/src/main/java/org/apache/skywalking/apm/testcase/mysql/SQLExecutor.java +++ b/test/plugin/scenarios/mysql-scenario/src/main/java/org/apache/skywalking/apm/testcase/mysql/SQLExecutor.java @@ -24,7 +24,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; -public class SQLExecutor { +public class SQLExecutor implements AutoCloseable { private Connection connection; public SQLExecutor() throws SQLException { @@ -61,4 +61,9 @@ public class SQLExecutor { this.connection.close(); } } + + @Override + public void close() throws Exception { + closeConnection(); + } } diff --git a/test/plugin/scenarios/mysql-scenario/src/main/java/org/apache/skywalking/apm/testcase/mysql/controller/CaseController.java b/test/plugin/scenarios/mysql-scenario/src/main/java/org/apache/skywalking/apm/testcase/mysql/controller/CaseController.java index d0121b729b37c6282b989f91dde80e939a5bac42..f72b4efe62c6927bebee1436bfca32fbae80e14c 100644 --- a/test/plugin/scenarios/mysql-scenario/src/main/java/org/apache/skywalking/apm/testcase/mysql/controller/CaseController.java +++ b/test/plugin/scenarios/mysql-scenario/src/main/java/org/apache/skywalking/apm/testcase/mysql/controller/CaseController.java @@ -18,7 +18,6 @@ package org.apache.skywalking.apm.testcase.mysql.controller; -import java.sql.SQLException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.skywalking.apm.testcase.mysql.SQLExecutor; @@ -26,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; +import java.sql.SQLException; + @RestController @RequestMapping("/case") public class CaseController { @@ -42,32 +43,24 @@ public class CaseController { @RequestMapping("/mysql-scenario") @ResponseBody - public String testcase() { - SQLExecutor sqlExecute = null; - try { - sqlExecute = new SQLExecutor(); + public String testcase() throws Exception { + try (SQLExecutor sqlExecute = new SQLExecutor()) { sqlExecute.createTable(CREATE_TABLE_SQL); sqlExecute.insertData(INSERT_DATA_SQL, "1", "1"); sqlExecute.dropTable(DROP_TABLE_SQL); - } catch (SQLException e) { + } catch (Exception e) { logger.error("Failed to execute sql.", e); - } finally { - if (sqlExecute != null) { - try { - sqlExecute.closeConnection(); - } catch (SQLException e) { - logger.error("Failed to close connection.", e); - } - } + throw e; } - return SUCCESS; } @RequestMapping("/healthCheck") @ResponseBody - public String healthCheck() { - // your codes + public String healthCheck() throws Exception { + try (SQLExecutor sqlExecutor = new SQLExecutor()) { + // ignore + } return SUCCESS; } diff --git a/test/plugin/scenarios/struts2.3-scenario/config/expectedData.yaml b/test/plugin/scenarios/struts2.3-scenario/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c7e5e8b4536133f93c2648a4c4bd04f77176ccb6 --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/config/expectedData.yaml @@ -0,0 +1,91 @@ +# 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. +registryItems: + applications: + - {struts2.3-scenario: 2} + instances: + - {struts2.3-scenario: 1} + operationNames: + - struts2.3-scenario: [/struts2.3-scenario/struts-scenario/case1.action, /struts2.3-scenario/struts-scenario/case.action] + heartbeat: [] +segmentItems: + - applicationCode: struts2.3-scenario + segmentSize: gt 2 + segments: + - segmentId: not null + spans: + - operationName: /struts2.3-scenario/struts-scenario/case1.action + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 15 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/struts2.3-scenario/struts-scenario/case1.action'} + - {key: http.method, value: GET} + logs: + - logEvent: + - {key: forward-url, value: /struts2.3-scenario/jsp/success.jsp} + refs: + - {parentEndpointId: 0, parentEndpoint: /struts2.3-scenario/struts-scenario/case.action, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /struts2.3-scenario/struts-scenario/case.action, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /struts2.3-scenario/struts-scenario/case1.action + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 2 + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/struts2.3-scenario/struts-scenario/case1.action'} + - {key: http.method, value: GET} + - operationName: /struts2.3-scenario/struts-scenario/case.action + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 15 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/struts2.3-scenario/struts-scenario/case.action'} + - {key: http.method, value: GET} + logs: + - logEvent: + - {key: forward-url, value: /struts2.3-scenario/jsp/success.jsp} \ No newline at end of file diff --git a/test/plugin/scenarios/struts2.3-scenario/configuration.yml b/test/plugin/scenarios/struts2.3-scenario/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..99145cd51e3291c0f39c1ab7a066065fa7bad03c --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/configuration.yml @@ -0,0 +1,22 @@ +# 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/struts2.3-scenario/struts-scenario/case.action +healthCheck: http://localhost:8080/struts2.3-scenario/case/healthCheck +framework: struts2.3-scenario +environment: +dependencies: \ No newline at end of file diff --git a/test/plugin/scenarios/struts2.3-scenario/pom.xml b/test/plugin/scenarios/struts2.3-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f055d91a83b06c5812cebab7588b48e068f1803 --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/pom.xml @@ -0,0 +1,88 @@ + + + + + org.apache.skywalking.apm.testcase + struts2.3-scenario + 1.0.0 + war + + 4.0.0 + + skywalking-struts2.3-scenario + + + UTF-8 + 1.8 + 2.3.4 + 1.18.10 + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + org.apache.logging.log4j + log4j-api + 2.8.1 + + + org.apache.logging.log4j + log4j-core + 2.8.1 + + + org.apache.struts + struts2-core + ${test.framework.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + org.apache.httpcomponents + httpclient + 4.3 + + + + + struts2.3-scenario + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + + diff --git a/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/Case1Action.java b/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/Case1Action.java new file mode 100644 index 0000000000000000000000000000000000000000..9f40d9c99f20296f0a27f363f32c92141d3a316f --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/Case1Action.java @@ -0,0 +1,28 @@ +/* + * 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.struts; + +import java.io.IOException; + +public class Case1Action { + + public String execute() throws IOException { + return "SUCCESS"; + } +} diff --git a/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/CaseAction.java b/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/CaseAction.java new file mode 100644 index 0000000000000000000000000000000000000000..a2405d9b1f9114233a3fd820f21511d212cc92d7 --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/CaseAction.java @@ -0,0 +1,47 @@ +/* + * 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.struts; + +import org.apache.http.HttpEntity; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; + +public class CaseAction { + + public String execute() throws IOException { + visit(); + return "SUCCESS"; + } + + private static void visit() throws IOException { + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpGet httpget = new HttpGet("http://localhost:8080/struts2.3-scenario/struts-scenario/case1.action"); + ResponseHandler responseHandler = response -> { + HttpEntity entity = response.getEntity(); + return entity != null ? EntityUtils.toString(entity) : null; + }; + httpClient.execute(httpget, responseHandler); + } + } +} diff --git a/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/HealthCheckServlet.java b/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/HealthCheckServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..0271b753476614d755ef68b6723299b86724e9ae --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/HealthCheckServlet.java @@ -0,0 +1,41 @@ +/* + * 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.struts; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class HealthCheckServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + // your codes + 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/struts2.3-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/struts2.3-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..9849ed5a8abd116a9000e64cc18f05e583f21c98 --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/struts2.3-scenario/src/main/resources/struts.xml b/test/plugin/scenarios/struts2.3-scenario/src/main/resources/struts.xml new file mode 100644 index 0000000000000000000000000000000000000000..bae340e22ffd8007dbc7cfb9cc191836ed4b54d6 --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/src/main/resources/struts.xml @@ -0,0 +1,32 @@ + + + + + + + + /jsp/success.jsp + + + /jsp/success.jsp + + + diff --git a/test/plugin/scenarios/struts2.3-scenario/src/main/webapp/WEB-INF/web.xml b/test/plugin/scenarios/struts2.3-scenario/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..2a382f5dccd2615a9efbc67899b0ba9dae4ac7fe --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + skywalking-struts2.3-scenario + + + struts2 + org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter + + + + struts2 + /struts-scenario/* + + + + healthCheck + org.apache.skywalking.apm.testcase.struts.HealthCheckServlet + + + + healthCheck + /case/healthCheck + + diff --git a/test/plugin/scenarios/struts2.3-scenario/src/main/webapp/jsp/success.jsp b/test/plugin/scenarios/struts2.3-scenario/src/main/webapp/jsp/success.jsp new file mode 100644 index 0000000000000000000000000000000000000000..82c72c0efeef218a08b640ed8a46d31e42f8e45f --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/src/main/webapp/jsp/success.jsp @@ -0,0 +1,25 @@ +<%-- + 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. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + +Success + + diff --git a/test/plugin/scenarios/struts2.3-scenario/support-version.list b/test/plugin/scenarios/struts2.3-scenario/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..e7cef99a7d92d6b25675a821b93f784157831684 --- /dev/null +++ b/test/plugin/scenarios/struts2.3-scenario/support-version.list @@ -0,0 +1,53 @@ +# 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 +# "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. + +# lists your version here + +2.3.1 +2.3.1.1 +2.3.1.2 +2.3.3 +2.3.4 +2.3.4.1 +2.3.7 +2.3.8 +2.3.12 +2.3.14 +2.3.14.1 +2.3.14.2 +2.3.24.3 +2.3.15 +2.3.15.1 +2.3.15.2 +2.3.15.3 +2.3.16 +2.3.20 +2.3.20.1 +2.3.20.3 +2.3.24 +2.3.24.1 +2.3.24.3 +2.3.28 +2.3.28.1 +2.3.29 +2.3.30 +2.3.31 +2.3.32 +2.3.33 +2.3.34 +2.3.35 +2.3.36 +2.3.37 \ No newline at end of file diff --git a/test/plugin/scenarios/struts2.5-scenario/config/expectedData.yaml b/test/plugin/scenarios/struts2.5-scenario/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3e274b130e3cff1f8459238194be1a41e7603ba3 --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/config/expectedData.yaml @@ -0,0 +1,91 @@ +# 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. +registryItems: + applications: + - {struts2.5-scenario: 2} + instances: + - {struts2.5-scenario: 1} + operationNames: + - struts2.5-scenario: [/struts2.5-scenario/struts-scenario/case1.action, /struts2.5-scenario/struts-scenario/case.action] + heartbeat: [] +segmentItems: + - applicationCode: struts2.5-scenario + segmentSize: gt 2 + segments: + - segmentId: not null + spans: + - operationName: /struts2.5-scenario/struts-scenario/case1.action + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 15 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/struts2.5-scenario/struts-scenario/case1.action'} + - {key: http.method, value: GET} + logs: + - logEvent: + - {key: forward-url, value: /struts2.5-scenario/jsp/success.jsp} + refs: + - {parentEndpointId: 0, parentEndpoint: /struts2.5-scenario/struts-scenario/case.action, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /struts2.5-scenario/struts-scenario/case.action, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /struts2.5-scenario/struts-scenario/case1.action + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 2 + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/struts2.5-scenario/struts-scenario/case1.action'} + - {key: http.method, value: GET} + - operationName: /struts2.5-scenario/struts-scenario/case.action + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: 15 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/struts2.5-scenario/struts-scenario/case.action'} + - {key: http.method, value: GET} + logs: + - logEvent: + - {key: forward-url, value: /struts2.5-scenario/jsp/success.jsp} \ No newline at end of file diff --git a/test/plugin/scenarios/struts2.5-scenario/configuration.yml b/test/plugin/scenarios/struts2.5-scenario/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..7d5ccf44a9f8b54fa060220bf2a94648f1f6f090 --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/configuration.yml @@ -0,0 +1,22 @@ +# 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/struts2.5-scenario/struts-scenario/case.action +healthCheck: http://localhost:8080/struts2.5-scenario/case/healthCheck +framework: struts2.5-scenario +environment: +dependencies: \ No newline at end of file diff --git a/test/plugin/scenarios/struts2.5-scenario/pom.xml b/test/plugin/scenarios/struts2.5-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..3fcbfb6324fbb68e0aee9c36c231b007af1752b9 --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/pom.xml @@ -0,0 +1,87 @@ + + + + + org.apache.skywalking.apm.testcase + struts2.5-scenario + 1.0.0 + war + + 4.0.0 + + skywalking-struts2.5-scenario + + + UTF-8 + 1.8 + 2.5.1 + 1.18.10 + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + org.apache.logging.log4j + log4j-api + 2.8.1 + + + org.apache.logging.log4j + log4j-core + 2.8.1 + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.apache.struts + struts2-core + ${test.framework.version} + + + org.apache.httpcomponents + httpclient + 4.3 + + + + + struts2.5-scenario + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + + diff --git a/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/Case1Action.java b/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/Case1Action.java new file mode 100644 index 0000000000000000000000000000000000000000..9f40d9c99f20296f0a27f363f32c92141d3a316f --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/Case1Action.java @@ -0,0 +1,28 @@ +/* + * 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.struts; + +import java.io.IOException; + +public class Case1Action { + + public String execute() throws IOException { + return "SUCCESS"; + } +} diff --git a/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/CaseAction.java b/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/CaseAction.java new file mode 100644 index 0000000000000000000000000000000000000000..c9350b63de747e66ecfb19dadefaa6843649a093 --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/CaseAction.java @@ -0,0 +1,47 @@ +/* + * 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.struts; + +import org.apache.http.HttpEntity; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; + +public class CaseAction { + + public String execute() throws IOException { + visit(); + return "SUCCESS"; + } + + private static void visit() throws IOException { + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpGet httpget = new HttpGet("http://localhost:8080/struts2.5-scenario/struts-scenario/case1.action"); + ResponseHandler responseHandler = response -> { + HttpEntity entity = response.getEntity(); + return entity != null ? EntityUtils.toString(entity) : null; + }; + httpClient.execute(httpget, responseHandler); + } + } +} diff --git a/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/HealthCheckServlet.java b/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/HealthCheckServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..0271b753476614d755ef68b6723299b86724e9ae --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/src/main/java/org/apache/skywalking/apm/testcase/struts/HealthCheckServlet.java @@ -0,0 +1,41 @@ +/* + * 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.struts; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class HealthCheckServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + // your codes + 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/struts2.5-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/struts2.5-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..9849ed5a8abd116a9000e64cc18f05e583f21c98 --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/struts2.5-scenario/src/main/resources/struts.xml b/test/plugin/scenarios/struts2.5-scenario/src/main/resources/struts.xml new file mode 100644 index 0000000000000000000000000000000000000000..bae340e22ffd8007dbc7cfb9cc191836ed4b54d6 --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/src/main/resources/struts.xml @@ -0,0 +1,32 @@ + + + + + + + + /jsp/success.jsp + + + /jsp/success.jsp + + + diff --git a/test/plugin/scenarios/struts2.5-scenario/src/main/webapp/WEB-INF/web.xml b/test/plugin/scenarios/struts2.5-scenario/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..bb64728a6cc777862a6276fafcf261428bc01547 --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + skywalking-struts2.5-scenario + + + struts2 + org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter + + + + struts2 + /struts-scenario/* + + + + healthCheck + org.apache.skywalking.apm.testcase.struts.HealthCheckServlet + + + + healthCheck + /case/healthCheck + + diff --git a/test/plugin/scenarios/struts2.5-scenario/src/main/webapp/jsp/success.jsp b/test/plugin/scenarios/struts2.5-scenario/src/main/webapp/jsp/success.jsp new file mode 100644 index 0000000000000000000000000000000000000000..82c72c0efeef218a08b640ed8a46d31e42f8e45f --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/src/main/webapp/jsp/success.jsp @@ -0,0 +1,25 @@ +<%-- + 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. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Title + + +Success + + diff --git a/test/plugin/scenarios/struts2.5-scenario/support-version.list b/test/plugin/scenarios/struts2.5-scenario/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..173df135b663fb66780a270c34df843ccc16120d --- /dev/null +++ b/test/plugin/scenarios/struts2.5-scenario/support-version.list @@ -0,0 +1,33 @@ +# 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 +# "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. + +# lists your version here + +2.5 +2.5.1 +2.5.2 +2.5.8 +2.5.10 +2.5.10.1 +2.5.12 +2.5.13 +2.5.14 +2.5.14.1 +2.5.16 +2.5.17 +2.5.18 +2.5.20 +2.5.22 diff --git a/test/plugin/scenarios/undertow-scenario/config/expectedData.yaml b/test/plugin/scenarios/undertow-scenario/config/expectedData.yaml index 010032df772de18c57427dad624994dd330bf5f7..a600a80abeb40a49f1e217c0be91ccb3c3ddf294 100644 --- a/test/plugin/scenarios/undertow-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/undertow-scenario/config/expectedData.yaml @@ -36,7 +36,7 @@ segmentItems: spanLayer: Http startTime: nq 0 endTime: nq 0 - componentId: 49 + componentId: 84 componentName: '' isError: false spanType: Entry @@ -54,7 +54,7 @@ segmentItems: spanLayer: Http startTime: nq 0 endTime: nq 0 - componentId: 49 + componentId: 84 componentName: '' isError: false spanType: Entry @@ -77,7 +77,7 @@ segmentItems: spanLayer: Http startTime: nq 0 endTime: nq 0 - componentId: 49 + componentId: 84 componentName: '' isError: false spanType: Entry @@ -116,7 +116,7 @@ segmentItems: spanLayer: Unknown startTime: nq 0 endTime: nq 0 - componentId: 49 + componentId: 84 componentName: '' isError: false spanType: Local @@ -152,7 +152,7 @@ segmentItems: spanLayer: Unknown startTime: nq 0 endTime: nq 0 - componentId: 49 + componentId: 84 componentName: '' isError: false spanType: Local