From 9bed3c7c42305db28dfd28b5f07bb058926925c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E7=8E=89=E6=A1=94?= Date: Thu, 31 Oct 2019 19:07:09 +0800 Subject: [PATCH] [test/plugin] immigrate test webflux scenario. (#3756) * add webflux testcase --- Jenkinsfile-Agent-Test-2 | 10 +- .../webflux-scenario/config/expectedData.yaml | 310 ++++++++++++++++++ .../webflux-scenario/configuration.yml | 21 ++ .../plugin/scenarios/webflux-scenario/pom.xml | 58 ++++ .../webflux-scenario/support-version.list | 34 ++ .../webflux-dist/bin/startup.sh | 24 ++ .../webflux-scenario/webflux-dist/pom.xml | 54 +++ .../src/main/assembly/assembly.xml | 46 +++ .../webflux-projectA-scenario/pom.xml | 72 ++++ .../sc/webflux/projectA/Application.java | 29 ++ .../projectA/controller/TestController.java | 61 ++++ .../sc/webflux/projectA/utils/HttpUtils.java | 51 +++ .../src/main/resources/application.yml | 21 ++ .../webflux-projectB-scenario/pom.xml | 57 ++++ .../sc/webflux/projectB/Application.java | 29 ++ .../webflux/projectB/config/CustomFilter.java | 44 +++ .../controller/TestAnnotationController.java | 51 +++ .../projectB/route/RoutingConfiguration.java | 37 +++ .../webflux/projectB/route/TestHandler.java | 39 +++ .../src/main/resources/application.yml | 18 + 20 files changed, 1064 insertions(+), 2 deletions(-) create mode 100644 test/plugin/scenarios/webflux-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/webflux-scenario/configuration.yml create mode 100644 test/plugin/scenarios/webflux-scenario/pom.xml create mode 100644 test/plugin/scenarios/webflux-scenario/support-version.list create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-dist/bin/startup.sh create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-dist/pom.xml create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-dist/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/pom.xml create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/Application.java create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/controller/TestController.java create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/utils/HttpUtils.java create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/resources/application.yml create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/pom.xml create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/Application.java create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/config/CustomFilter.java create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/controller/TestAnnotationController.java create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/route/RoutingConfiguration.java create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/route/TestHandler.java create mode 100644 test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/resources/application.yml diff --git a/Jenkinsfile-Agent-Test-2 b/Jenkinsfile-Agent-Test-2 index a081d12e4..ad1d5f376 100755 --- a/Jenkinsfile-Agent-Test-2 +++ b/Jenkinsfile-Agent-Test-2 @@ -66,7 +66,7 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=wl2_${BUILD_ID} docker:build' } } - stage('Test Cases Report (156)') { + stage('Test Cases Report (174)') { steps { echo "reserve." } @@ -87,6 +87,12 @@ pipeline { } } + stage('spring-webflux 2.x (18)') { + steps { + sh 'bash test/plugin/run.sh --build_id=wl2_${BUILD_ID} webflux-scenario' + } + } + stage('dubbo 2.5.x-2.6.x (10)') { steps { sh 'bash test/plugin/run.sh --build_id=wl2_${BUILD_ID} dubbo-2.5.x-scenario' @@ -148,4 +154,4 @@ pipeline { deleteDir() } } -} \ No newline at end of file +} diff --git a/test/plugin/scenarios/webflux-scenario/config/expectedData.yaml b/test/plugin/scenarios/webflux-scenario/config/expectedData.yaml new file mode 100644 index 000000000..cb167cd0e --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/config/expectedData.yaml @@ -0,0 +1,310 @@ +# 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: + - {webflux-projectB-scenario: nq 0} + - {webflux-projectA-scenario: nq 0} + instances: + - {webflux-projectB-scenario: 1} + - {webflux-projectA-scenario: 1} + operationNames: + - webflux-projectB-scenario: [org.apache.skywalking.apm.testcase.sc.webflux.projectB.controller.TestAnnotationController.success, + org.apache.skywalking.apm.testcase.sc.webflux.projectB.controller.TestAnnotationController.hello, + WEBFLUX.handle, org.apache.skywalking.apm.testcase.sc.webflux.projectB.controller.TestAnnotationController.error, + org.apache.skywalking.apm.testcase.sc.webflux.projectB.controller.TestAnnotationController.healthCheck, + RoutingConfiguration.org.apache.skywalking.apm.testcase.sc.webflux.projectB.route.TestHandler] + - webflux-projectA-scenario: [/testcase/annotation/mono/hello, /projectA/testcase, + /testcase/annotation/success, /testcase/annotation/healthCheck, /notFound, /projectA/healthCheck, + /testcase/route/error, /testcase/route/success, /testcase/annotation/error] + heartbeat: [] +segmentItems: + - applicationCode: webflux-projectB-scenario + segmentSize: nq 0 + segments: + - segmentId: not null + spans: + - operationName: org.apache.skywalking.apm.testcase.sc.webflux.projectB.controller.TestAnnotationController.success + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 67 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: not null} + refs: + - {parentEndpointId: 0, parentEndpoint: /projectA/testcase, networkAddressId: 0, + entryEndpointId: 0, refType: CrossProcess, parentSpanId: not null, parentTraceSegmentId: not null, + parentServiceInstanceId: not null, networkAddress: not null, entryEndpoint: /projectA/testcase, + entryServiceInstanceId: not null} + - segmentId: not null + spans: + - operationName: org.apache.skywalking.apm.testcase.sc.webflux.projectB.controller.TestAnnotationController.error + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 67 + componentName: '' + isError: true + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: not null} + - {key: status_code, value: '500'} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: java.lang.RuntimeException} + - {key: message, value: test_error} + - {key: stack, value: not null} + refs: + - {parentEndpointId: 0, parentEndpoint: /projectA/testcase, networkAddressId: 0, + entryEndpointId: 0, refType: CrossProcess, parentSpanId: not null, parentTraceSegmentId: not null, + parentServiceInstanceId: not null, networkAddress: not null, entryEndpoint: /projectA/testcase, + entryServiceInstanceId: not null} + - segmentId: not null + spans: + - operationName: RoutingConfiguration.org.apache.skywalking.apm.testcase.sc.webflux.projectB.route.TestHandler + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 67 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: not null} + refs: + - {parentEndpointId: 0, parentEndpoint: /projectA/testcase, networkAddressId: 0, + entryEndpointId: 0, refType: CrossProcess, parentSpanId: not null, parentTraceSegmentId: not null, + parentServiceInstanceId: not null, networkAddress: not null, entryEndpoint: /projectA/testcase, + entryServiceInstanceId: not null} + - segmentId: not null + spans: + - operationName: RoutingConfiguration.org.apache.skywalking.apm.testcase.sc.webflux.projectB.route.TestHandler + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 67 + componentName: '' + isError: true + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: not null} + - {key: status_code, value: '500'} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: java.lang.RuntimeException} + - {key: message, value: test_error} + - {key: stack, value: not null} + refs: + - {parentEndpointId: 0, parentEndpoint: /projectA/testcase, networkAddressId: 0, + entryEndpointId: 0, refType: CrossProcess, parentSpanId: not null, parentTraceSegmentId: not null, + parentServiceInstanceId: not null, networkAddress: not null, entryEndpoint: /projectA/testcase, + entryServiceInstanceId: not null} + - segmentId: not null + spans: + - operationName: WEBFLUX.handle + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 67 + componentName: '' + isError: true + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: not null} + - {key: status_code, value: '404'} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: org.springframework.web.server.ResponseStatusException} + - {key: message, value: not null} + - {key: stack, value: not null} + refs: + - {parentEndpointId: 0, parentEndpoint: /projectA/testcase, networkAddressId: 0, + entryEndpointId: 0, refType: CrossProcess, parentSpanId: not null, parentTraceSegmentId: not null, + parentServiceInstanceId: not null, networkAddress: not null, entryEndpoint: /projectA/testcase, + entryServiceInstanceId: not null} + - segmentId: not null + spans: + - operationName: org.apache.skywalking.apm.testcase.sc.webflux.projectB.controller.TestAnnotationController.hello + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 67 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: not null} + refs: + - {parentEndpointId: 0, parentEndpoint: /projectA/testcase, networkAddressId: 0, + entryEndpointId: 0, refType: CrossProcess, parentSpanId: not null, parentTraceSegmentId: not null, + parentServiceInstanceId: not null, networkAddress: not null, entryEndpoint: /projectA/testcase, + entryServiceInstanceId: not null} + - applicationCode: webflux-projectA-scenario + segmentSize: nq 0 + segments: + - segmentId: not null + spans: + - operationName: /testcase/annotation/success + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 2 + componentName: '' + isError: false + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: url, value: not null} + - {key: http.method, value: GET} + - operationName: /testcase/annotation/error + operationId: 0 + parentSpanId: 0 + spanId: 2 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 2 + componentName: '' + isError: true + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: url, value: not null} + - {key: http.method, value: GET} + - {key: status_code, value: '500'} + - operationName: /testcase/route/success + operationId: 0 + parentSpanId: 0 + spanId: 3 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 2 + componentName: '' + isError: false + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: url, value: not null} + - {key: http.method, value: GET} + - operationName: /testcase/route/error + operationId: 0 + parentSpanId: 0 + spanId: 4 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 2 + componentName: '' + isError: true + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: url, value: not null} + - {key: http.method, value: GET} + - {key: status_code, value: '500'} + - operationName: /notFound + operationId: 0 + parentSpanId: 0 + spanId: 5 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 2 + componentName: '' + isError: true + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: url, value: not null} + - {key: http.method, value: GET} + - {key: status_code, value: '404'} + - operationName: /testcase/annotation/mono/hello + operationId: 0 + parentSpanId: 0 + spanId: 6 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 2 + componentName: '' + isError: false + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: url, value: not null} + - {key: http.method, value: GET} + - operationName: /projectA/testcase + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: not null} + - {key: http.method, value: GET} \ No newline at end of file diff --git a/test/plugin/scenarios/webflux-scenario/configuration.yml b/test/plugin/scenarios/webflux-scenario/configuration.yml new file mode 100644 index 000000000..37b70f99e --- /dev/null +++ b/test/plugin/scenarios/webflux-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/projectA/testcase +healthCheck: http://localhost:8080/projectA/healthCheck +startScript: ./bin/startup.sh +framework: spring-webflux \ No newline at end of file diff --git a/test/plugin/scenarios/webflux-scenario/pom.xml b/test/plugin/scenarios/webflux-scenario/pom.xml new file mode 100644 index 000000000..8502b9871 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.apache.skywalking + webflux-scenario + pom + 5.0.0 + + webflux-projectA-scenario + webflux-projectB-scenario + webflux-dist + + + skywalking-webflux-scenario + + + UTF-8 + 2.0.0.RELEASE + ${test.framework.version} + + + + webflux-scenario + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + + + diff --git a/test/plugin/scenarios/webflux-scenario/support-version.list b/test/plugin/scenarios/webflux-scenario/support-version.list new file mode 100644 index 000000000..13e43a550 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/support-version.list @@ -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. + +2.0.0.RELEASE +2.0.1.RELEASE +2.0.2.RELEASE +2.0.3.RELEASE +2.0.4.RELEASE +2.0.5.RELEASE +2.0.6.RELEASE +2.0.7.RELEASE +2.0.8.RELEASE +2.0.9.RELEASE +2.1.0.RELEASE +2.1.1.RELEASE +2.1.2.RELEASE +2.1.3.RELEASE +2.1.4.RELEASE +2.1.5.RELEASE +2.1.6.RELEASE +2.1.7.RELEASE \ No newline at end of file diff --git a/test/plugin/scenarios/webflux-scenario/webflux-dist/bin/startup.sh b/test/plugin/scenarios/webflux-scenario/webflux-dist/bin/startup.sh new file mode 100644 index 000000000..dc04739c3 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-dist/bin/startup.sh @@ -0,0 +1,24 @@ +#!/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} "-Dskywalking.agent.service_name=webflux-projectA-scenario" ${home}/../libs/webflux-projectA-scenario.jar & +sleep 1 + +java -jar ${agent_opts} "-Dskywalking.agent.service_name=webflux-projectB-scenario" ${home}/../libs/webflux-projectB-scenario.jar & diff --git a/test/plugin/scenarios/webflux-scenario/webflux-dist/pom.xml b/test/plugin/scenarios/webflux-scenario/webflux-dist/pom.xml new file mode 100644 index 000000000..019316de2 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-dist/pom.xml @@ -0,0 +1,54 @@ + + + + + org.apache.skywalking + webflux-scenario + 5.0.0 + + 4.0.0 + + webflux-dist + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ../target/ + + + + + + + diff --git a/test/plugin/scenarios/webflux-scenario/webflux-dist/src/main/assembly/assembly.xml b/test/plugin/scenarios/webflux-scenario/webflux-dist/src/main/assembly/assembly.xml new file mode 100644 index 000000000..7bc3d1092 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-dist/src/main/assembly/assembly.xml @@ -0,0 +1,46 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ../webflux-projectA-scenario/target/webflux-projectA-scenario.jar + ./libs + 0775 + + + ../webflux-projectB-scenario/target/webflux-projectB-scenario.jar + ./libs + 0775 + + + \ No newline at end of file diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/pom.xml b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/pom.xml new file mode 100644 index 000000000..0d1389a28 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/pom.xml @@ -0,0 +1,72 @@ + + + + + org.apache.skywalking + webflux-scenario + 5.0.0 + + 4.0.0 + + webflux-projectA-scenario + + + + org.springframework.boot + spring-boot-starter-web + ${test.framework.version} + + + org.apache.httpcomponents + httpclient + 4.5.6 + + + + + webflux-projectA-scenario + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + + + + + 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/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/Application.java b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/Application.java new file mode 100644 index 000000000..50d92733b --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/Application.java @@ -0,0 +1,29 @@ +/* + * 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.sc.webflux.projectA; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/controller/TestController.java b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/controller/TestController.java new file mode 100644 index 000000000..85cbffcbe --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/controller/TestController.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.sc.webflux.projectA.controller; + +import org.apache.skywalking.apm.testcase.sc.webflux.projectA.utils.HttpUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; + +@RestController +public class TestController { + + @Value("${projectB.host:localhost:18080}") + private String hostBAddress; + + @Autowired + private HttpUtils httpUtils; + + @RequestMapping("/testcase") + public String testcase() throws IOException { + visit("http://" + hostBAddress + "/testcase/annotation/success"); + visit("http://" + hostBAddress + "/testcase/annotation/error"); + visit("http://" + hostBAddress + "/testcase/route/success"); + visit("http://" + hostBAddress + "/testcase/route/error"); + visit("http://" + hostBAddress + "/notFound"); + visit("http://" + hostBAddress + "/testcase/annotation/mono/hello"); + return "test"; + } + + @RequestMapping("/healthCheck") + public String healthCheck() throws IOException { + httpUtils.visit("http://" + hostBAddress + "/testcase/annotation/healthCheck"); + return "test"; + } + + private void visit(String path){ + try { + httpUtils.visit(path); + } catch (Exception i) { + + } + } +} diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/utils/HttpUtils.java b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/utils/HttpUtils.java new file mode 100644 index 000000000..f9c3878ac --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectA/utils/HttpUtils.java @@ -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 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.sc.webflux.projectA.utils; + +import org.apache.http.HttpEntity; +import org.apache.http.client.ClientProtocolException; +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; + +@Component +public class HttpUtils { + + public String visit(String url) throws IOException { + CloseableHttpClient httpclient = HttpClients.createDefault(); + try { + HttpGet httpget = new HttpGet(url); + ResponseHandler responseHandler = new ResponseHandler() { + public String handleResponse( + org.apache.http.HttpResponse response) throws ClientProtocolException, 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/webflux-scenario/webflux-projectA-scenario/src/main/resources/application.yml b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/resources/application.yml new file mode 100644 index 000000000..80e791c13 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectA-scenario/src/main/resources/application.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. +# + +server: + servlet: + context-path: /projectA + port: 8080 \ No newline at end of file diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/pom.xml b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/pom.xml new file mode 100644 index 000000000..792dc6df9 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/pom.xml @@ -0,0 +1,57 @@ + + + + + webflux-scenario + org.apache.skywalking + 5.0.0 + + 4.0.0 + + webflux-projectB-scenario + + + + org.springframework.boot + spring-boot-starter-webflux + ${test.framework.version} + + + + + webflux-projectB-scenario + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/Application.java b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/Application.java new file mode 100644 index 000000000..733fdf41a --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/Application.java @@ -0,0 +1,29 @@ +/* + * 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.sc.webflux.projectB; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/config/CustomFilter.java b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/config/CustomFilter.java new file mode 100644 index 000000000..12abaea2a --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/config/CustomFilter.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.sc.webflux.projectB.config; + +import org.springframework.stereotype.Component; +import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.ServerWebExchangeDecorator; +import org.springframework.web.server.WebFilter; +import org.springframework.web.server.WebFilterChain; +import reactor.core.publisher.Mono; + +/** + * @author zhaoyuguang + */ + +@Component +public class CustomFilter implements WebFilter { + + @Override + public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { + return chain.filter(new MyServerWebExchangeDecorator(exchange)); + } + + public static class MyServerWebExchangeDecorator extends ServerWebExchangeDecorator { + public MyServerWebExchangeDecorator(ServerWebExchange delegate) { + super(delegate); + } + } + +} diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/controller/TestAnnotationController.java b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/controller/TestAnnotationController.java new file mode 100644 index 000000000..a9afbb5b4 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/controller/TestAnnotationController.java @@ -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 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.sc.webflux.projectB.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; + +@RestController +public class TestAnnotationController { + + @RequestMapping("/testcase/annotation/healthCheck") + public String healthCheck() { + return "healthCheck"; + } + + @RequestMapping("/testcase/annotation/success") + public String success() { + return "1"; + } + + @RequestMapping("/testcase/annotation/error") + public String error() { + if (1 == 1) { + throw new RuntimeException("test_error"); + } + return "1"; + } + + @GetMapping("/testcase/annotation/mono/hello") + public Mono hello(@RequestBody(required = false) String body) { + return Mono.just("Hello World"); + } +} diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/route/RoutingConfiguration.java b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/route/RoutingConfiguration.java new file mode 100644 index 000000000..f18545404 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/route/RoutingConfiguration.java @@ -0,0 +1,37 @@ +/* + * 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.sc.webflux.projectB.route; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; + +/** + * @author zhaoyuguang + */ +@Configuration +public class RoutingConfiguration { + @Bean + public RouterFunction routerFunction(TestHandler testHandler) { + return RouterFunctions.route(GET("/testcase/route/{test}"), testHandler::test); + } + +} diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/route/TestHandler.java b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/route/TestHandler.java new file mode 100644 index 000000000..fb58d2bf1 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/webflux/projectB/route/TestHandler.java @@ -0,0 +1,39 @@ +/* + * 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.sc.webflux.projectB.route; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; + +/** + * @author zhaoyuguang + */ +@Component +public class TestHandler { + + public Mono test(ServerRequest request) { + System.out.println(request.path()); + if (request.path().contains("error")) { + throw new RuntimeException("test_error"); + } + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("route")); + } +} diff --git a/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/resources/application.yml b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/resources/application.yml new file mode 100644 index 000000000..629f92f78 --- /dev/null +++ b/test/plugin/scenarios/webflux-scenario/webflux-projectB-scenario/src/main/resources/application.yml @@ -0,0 +1,18 @@ +# +# 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: 18080 \ No newline at end of file