diff --git a/Jenkinsfile-Agent-Test b/Jenkinsfile-Agent-Test index 87554e684195966f2f5a8db5616c5c25ba0c8123..d30f0562fb3d21e87dd6a3ee9e29d76ec43fdd7e 100755 --- a/Jenkinsfile-Agent-Test +++ b/Jenkinsfile-Agent-Test @@ -81,6 +81,12 @@ pipeline { sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} dubbo-2.7.x-scenario' } } + + stage('spring async 4.3.x-5.1.x (35)'){ + steps{ + sh 'bash test/plugin/run.sh --build_id=${BUILD_ID} spring-async-scenario' + } + } } } stage('Group2') { diff --git a/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f546ea0111f847bb64bef71180602b7df751a073 --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml @@ -0,0 +1,139 @@ +# 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: + - {spring-async-scenario: 2} + instances: + - {spring-async-scenario: 1} + operationNames: + - spring-async-scenario: [/spring-async-scenario/case/healthCheck, /spring-async-scenario/case/spring-async, + /zh/team/] + heartbeat: [] +segmentItems: + - applicationCode: spring-async-scenario + segmentSize: 4 + segments: + - segmentId: not null + spans: + - operationName: /spring-async-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/healthCheck'} + - {key: http.method, value: HEAD} + - segmentId: not null + spans: + - operationName: /spring-async-scenario/case/spring-async + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/spring-async'} + - {key: http.method, value: GET} + - segmentId: not null + spans: + - operationName: /zh/team/ + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 2 + componentName: '' + isError: false + spanType: Exit + peer: skywalking.apache.org:80 + peerId: 0 + tags: + - {key: url, value: 'http://skywalking.apache.org/zh/team/?k1=v'} + - {key: http.method, value: GET} + - operationName: SpringAsync + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Unknown + startTime: nq 0 + endTime: nq 0 + componentId: 65 + componentName: '' + isError: false + spanType: Local + peer: '' + peerId: 0 + refs: + - {parentEndpointId: 0, parentEndpoint: /spring-async-scenario/case/spring-async, + networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: '', entryEndpoint: /spring-async-scenario/case/spring-async, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /zh/team/ + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 2 + componentName: '' + isError: false + spanType: Exit + peer: skywalking.apache.org:80 + peerId: 0 + tags: + - {key: url, value: 'http://skywalking.apache.org/zh/team/?k2=v'} + - {key: http.method, value: GET} + - operationName: SpringAsync + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Unknown + startTime: nq 0 + endTime: nq 0 + componentId: 65 + componentName: '' + isError: false + spanType: Local + peer: '' + peerId: 0 + refs: + - {parentEndpointId: 0, parentEndpoint: /spring-async-scenario/case/spring-async, + networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: '', entryEndpoint: /spring-async-scenario/case/spring-async, + entryServiceInstanceId: 1} + diff --git a/test/plugin/scenarios/spring-async-scenario/configuration.yml b/test/plugin/scenarios/spring-async-scenario/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..cbb8f7ff19a6bacfd3133cdd60175f859ff46138 --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/configuration.yml @@ -0,0 +1,20 @@ +# 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/spring-async-scenario/case/spring-async +healthCheck: http://localhost:8080/spring-async-scenario/case/healthCheck +framework: spring-async \ No newline at end of file diff --git a/test/plugin/scenarios/spring-async-scenario/pom.xml b/test/plugin/scenarios/spring-async-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..63c2d157ce09d0bd46e4230c720ff35af84958c9 --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.apache.skywalking + spring-async-scenario + 5.0.0 + + war + + + UTF-8 + 1.8 + 4.3.5.RELEASE + spring-async + + + skywalking-spring-async-scenario + + + + 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.springframework + spring-context + ${test.framework.version} + + + org.springframework + spring-aop + ${test.framework.version} + + + org.apache.httpcomponents + httpclient + 4.5.6 + + + + + spring-async-scenario + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + + + + + spring-snapshots + http://repo.spring.io/snapshot + + + spring-milestones + http://repo.spring.io/milestone + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncBean.java b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncBean.java new file mode 100644 index 0000000000000000000000000000000000000000..f82d34bcb3af6327c157f697acb3e04eaa2b71ec --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncBean.java @@ -0,0 +1,44 @@ +/* + * 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.spring.async; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +/** + * @author zhaoyuguang + */ +@Component +public class AsyncBean { + + @Autowired + private HttpBean httpBean; + + @Async + public void sendVisitBySystem() throws IOException { + httpBean.visit("http://skywalking.apache.org/zh/team/?k1=v"); + } + + @Async("customizeAsync") + public void sendVisitByCustomize() throws IOException { + httpBean.visit("http://skywalking.apache.org/zh/team/?k2=v"); + } +} diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncConfig.java b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..b9f42dda46b98685180f6783899970392b18b930 --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncConfig.java @@ -0,0 +1,44 @@ +/* + * 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.spring.async; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.task.AsyncTaskExecutor; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +/** + * @author zhaoyuguang + */ +@ComponentScan(basePackages = "org.apache.skywalking.apm.testcase.spring.async") +@EnableAsync +@Configuration +public class AsyncConfig { + + @Bean(value = "customizeAsync") + public AsyncTaskExecutor taskExecutor() { + ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); + taskExecutor.setMaxPoolSize(10); + taskExecutor.setCorePoolSize(2); + taskExecutor.setThreadNamePrefix("customize-async-thread-pool"); + taskExecutor.initialize(); + return taskExecutor; + } +} diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/CaseServlet.java b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/CaseServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..403058d40d9716e05213a51842ce3d9e56a9b936 --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/CaseServlet.java @@ -0,0 +1,54 @@ +/* + * 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.spring.async; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +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; + +/** + * @author zhangwei + */ +public class CaseServlet extends HttpServlet { + + private static final long serialVersionUID = -5173829093752900411L; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AsyncConfig.class); + AsyncBean async = applicationContext.getBean(AsyncBean.class); + + async.sendVisitBySystem(); + async.sendVisitByCustomize(); + + PrintWriter writer = resp.getWriter(); + writer.write("Success"); + writer.flush(); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + this.doGet(req, resp); + } +} diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/HealthCheckServlet.java b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/HealthCheckServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..036ec44511c1d5f7443519dc71deb0691c70ff01 --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/HealthCheckServlet.java @@ -0,0 +1,45 @@ +/* + * 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.spring.async; + +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; + +/** + * @author zhangwei + */ +public class HealthCheckServlet extends HttpServlet { + + private static final long serialVersionUID = 6730792920833279196L; + + @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 { + this.doGet(req, resp); + } +} diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/HttpBean.java b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/HttpBean.java new file mode 100644 index 0000000000000000000000000000000000000000..b8b4a405caa472678e36b15cd791bb04f2054361 --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/HttpBean.java @@ -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 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.spring.async; + +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 org.springframework.stereotype.Component; + +import java.io.IOException; + +/** + * @author zhaoyuguang + */ +@Component +public class HttpBean { + + public String visit(String url) throws IOException { + CloseableHttpClient httpclient = HttpClients.createDefault(); + try { + HttpGet httpget = new HttpGet(url); + ResponseHandler responseHandler = new ResponseHandler() { + @Override + public String handleResponse(org.apache.http.HttpResponse response) throws IOException { + HttpEntity entity = response.getEntity(); + return entity != null ? EntityUtils.toString(entity) : null; + } + + }; + return httpclient.execute(httpget, responseHandler); + } finally { + httpclient.close(); + } + } +} diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/webapp/WEB-INF/web.xml b/test/plugin/scenarios/spring-async-scenario/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..e001453333adaee496647e7d7b1053e99916141d --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + skywalking-ehcache-2.x-scenario + + + caseServlet + org.apache.skywalking.apm.testcase.spring.async.CaseServlet + + + caseServlet + /case/spring-async + + + + healthCheck + org.apache.skywalking.apm.testcase.spring.async.HealthCheckServlet + + + healthCheck + /case/healthCheck + + diff --git a/test/plugin/scenarios/spring-async-scenario/support-version.list b/test/plugin/scenarios/spring-async-scenario/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..4a473a4703c3e9784a295f76468f88df23073aec --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/support-version.list @@ -0,0 +1,51 @@ +# 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. + +4.3.5.RELEASE +4.3.6.RELEASE +4.3.7.RELEASE +4.3.8.RELEASE +4.3.9.RELEASE +4.3.10.RELEASE +4.3.11.RELEASE +4.3.12.RELEASE +4.3.14.RELEASE +4.3.15.RELEASE +4.3.16.RELEASE +4.3.17.RELEASE +4.3.18.RELEASE +4.3.19.RELEASE +4.3.20.RELEASE +4.3.21.RELEASE +4.3.22.RELEASE +4.3.23.RELEASE +5.0.4.RELEASE +5.0.5.RELEASE +5.0.6.RELEASE +5.0.7.RELEASE +5.0.8.RELEASE +5.0.9.RELEASE +5.0.10.RELEASE +5.0.11.RELEASE +5.0.12.RELEASE +5.0.13.RELEASE +5.1.2.RELEASE +5.1.3.RELEASE +5.1.4.RELEASE +5.1.5.RELEASE +5.1.6.RELEASE +5.1.7.RELEASE +5.1.8.RELEASE