From 8ad3bab42ebd4eadd07140e3ef585251b95918ab Mon Sep 17 00:00:00 2001 From: Alan Lau Date: Mon, 25 Nov 2019 11:37:52 +0800 Subject: [PATCH] [test/plugin] Immigrate tests okhttp scenario (#3905) * Immigrate tests okhttp scenario * Fix Header. * Fix license Header. * Modify code follow the reivew suggestions. * Fix expected.xml * Restore the missed config * Update okhttp elapsed time. * Update total time for Group1. * Fix the missed operationNames. --- Jenkinsfile-Agent-Test-2 | 8 +- docs/en/guides/Plugin-test.md | 3 +- .../scenarios/okhttp-scenario/bin/startup.sh | 21 +++ .../okhttp-scenario/config/expectedData.yaml | 119 +++++++++++++++ .../okhttp-scenario/configuration.yml | 21 +++ test/plugin/scenarios/okhttp-scenario/pom.xml | 143 ++++++++++++++++++ .../src/main/assembly/assembly.xml | 41 +++++ .../testcase/okhttp/Application.java | 39 +++++ .../okhttp/controller/CaseController.java | 76 ++++++++++ .../src/main/resources/application.properties | 18 +++ .../src/main/resources/log4j2.xml | 30 ++++ .../okhttp-scenario/support-version.list | 50 ++++++ 12 files changed, 567 insertions(+), 2 deletions(-) create mode 100644 test/plugin/scenarios/okhttp-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/okhttp-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/okhttp-scenario/configuration.yml create mode 100644 test/plugin/scenarios/okhttp-scenario/pom.xml create mode 100644 test/plugin/scenarios/okhttp-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/okhttp-scenario/src/main/java/test/apache/skywalking/testcase/okhttp/Application.java create mode 100644 test/plugin/scenarios/okhttp-scenario/src/main/java/test/apache/skywalking/testcase/okhttp/controller/CaseController.java create mode 100644 test/plugin/scenarios/okhttp-scenario/src/main/resources/application.properties create mode 100644 test/plugin/scenarios/okhttp-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/okhttp-scenario/support-version.list diff --git a/Jenkinsfile-Agent-Test-2 b/Jenkinsfile-Agent-Test-2 index eb15e93e47..0e15485bfe 100755 --- a/Jenkinsfile-Agent-Test-2 +++ b/Jenkinsfile-Agent-Test-2 @@ -67,7 +67,7 @@ pipeline { sh './mvnw -f test/plugin/pom.xml clean package -DskipTests docker:build' } } - stage('Test Cases Report (146)') { + stage('Test Cases Report (170)') { steps { echo "Test Cases Report" } @@ -105,6 +105,12 @@ pipeline { sh 'bash test/plugin/run.sh dubbo-2.7.x-scenario' } } + + stage('okhttp 3.0.x-3.14.x (34)') { + steps { + sh 'bash test/plugin/run.sh okhttp-scenario' + } + } } } diff --git a/docs/en/guides/Plugin-test.md b/docs/en/guides/Plugin-test.md index f2f70cbbce..5e64a2d493 100644 --- a/docs/en/guides/Plugin-test.md +++ b/docs/en/guides/Plugin-test.md @@ -630,13 +630,14 @@ canal 1.0.24-1.1.2 | 5 | 214.05 ### Workload 2 -#### Group 1 (2906.54s) +#### Group 1 (3936.54s) scenario name | versions | elapsed time (sec) ---|---|--- spring-tx 4.x+ | 10 | 555.00 spring 4.3.x-5.2.x | 54 | 1769.32 dubbo 2.5.x-2.6.x | 10 | 367.23 dubbo 2.7.x | 4 | 214.99 +okhttp 3.0.x-3.14.x | 34 | 1030 #### Group 2 (2550.66s) scenario name | versions | elapsed time (sec) diff --git a/test/plugin/scenarios/okhttp-scenario/bin/startup.sh b/test/plugin/scenarios/okhttp-scenario/bin/startup.sh new file mode 100644 index 0000000000..52b052cff5 --- /dev/null +++ b/test/plugin/scenarios/okhttp-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/okhttp-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/okhttp-scenario/config/expectedData.yaml b/test/plugin/scenarios/okhttp-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..48c4612381 --- /dev/null +++ b/test/plugin/scenarios/okhttp-scenario/config/expectedData.yaml @@ -0,0 +1,119 @@ +# 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: + - {okhttp-scenario: nq 0} + instances: + - {okhttp-scenario: 1} + operationNames: + - okhttp-scenario: [/case/receiveContext-0, /okhttp-case/case/receiveContext-0,/case/healthCheck, /case/okhttp-case, /case/receiveContext-1] + heartbeat: [] +segmentItems: +- applicationCode: okhttp-scenario + segmentSize: ge 5 + segments: + - segmentId: not null + spans: + - operationName: Async/okhttp-case/case/receiveContext-0 + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: null + startTime: nq 0 + endTime: nq 0 + componentId: 0 + componentName: null + isError: false + spanType: Local + peer: null + peerId: 0 + - operationName: /case/okhttp-case + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 14 + componentName: null + isError: false + spanType: Entry + peer: null + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/okhttp-case/case/okhttp-case'} + - {key: http.method, value: GET} + - segmentId: not null + spans: + - operationName: /case/receiveContext-0 + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 14 + componentName: null + isError: false + spanType: Entry + peer: null + peerId: 0 + tags: + - {key: url, value: 'http://127.0.0.1:8080/okhttp-case/case/receiveContext-0'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /okhttp-case/case/receiveContext-0, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: nq 0, parentServiceInstanceId: nq 0, networkAddress: '127.0.0.1:8080', entryEndpoint: /case/okhttp-case, entryServiceInstanceId: nq 0} + - segmentId: not null + spans: + - operationName: /case/receiveContext-1 + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 14 + componentName: null + isError: false + spanType: Entry + peer: null + peerId: 0 + tags: + - {key: url, value: 'http://127.0.0.1:8080/okhttp-case/case/receiveContext-1'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /okhttp-case/case/receiveContext-0, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: nq 0, parentServiceInstanceId: nq 0, networkAddress: '127.0.0.1:8080', entryEndpoint: /case/okhttp-case, entryServiceInstanceId: nq 0} + - segmentId: not null + spans: + - operationName: /okhttp-case/case/receiveContext-0 + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 12 + componentName: null + isError: false + spanType: Exit + peer: 127.0.0.1:8080 + peerId: 0 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://127.0.0.1:8080/okhttp-case/case/receiveContext-0'} + refs: + - {parentEndpointId: 0, parentEndpoint: /case/okhttp-case, networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: nq 0, parentServiceInstanceId: nq 0, networkAddress: '', entryEndpoint: /case/okhttp-case, entryServiceInstanceId: nq 0} diff --git a/test/plugin/scenarios/okhttp-scenario/configuration.yml b/test/plugin/scenarios/okhttp-scenario/configuration.yml new file mode 100644 index 0000000000..fd67136a16 --- /dev/null +++ b/test/plugin/scenarios/okhttp-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/okhttp-case/case/okhttp-case +healthCheck: http://localhost:8080/okhttp-case/case/healthCheck +startScript: ./bin/startup.sh +framework: OKHttp3 \ No newline at end of file diff --git a/test/plugin/scenarios/okhttp-scenario/pom.xml b/test/plugin/scenarios/okhttp-scenario/pom.xml new file mode 100644 index 0000000000..d6863cc5d7 --- /dev/null +++ b/test/plugin/scenarios/okhttp-scenario/pom.xml @@ -0,0 +1,143 @@ + + + + 4.0.0 + + org.apache.skywalking + okhttp-scenario + 5.0.0 + + skywalking-okhttp-scenario + + + UTF-8 + + 3.0.0 + ${test.framework.version} + + 2.6.2 + 4.3.8.RELEASE + 1.5.2.RELEASE + + + + + com.squareup.okhttp3 + okhttp + ${test.framework.version} + + + + org.springframework.boot + spring-boot-starter + ${spring-boot-version} + + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j.version} + + + org.apache.logging.log4j + log4j-jcl + ${log4j.version} + + + org.springframework.boot + spring-boot-starter-tomcat + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot-version} + + + + + okhttp-scenario + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + + + + 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/okhttp-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/okhttp-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..c34d25c392 --- /dev/null +++ b/test/plugin/scenarios/okhttp-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/okhttp-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/okhttp-scenario/src/main/java/test/apache/skywalking/testcase/okhttp/Application.java b/test/plugin/scenarios/okhttp-scenario/src/main/java/test/apache/skywalking/testcase/okhttp/Application.java new file mode 100644 index 0000000000..4f068862b6 --- /dev/null +++ b/test/plugin/scenarios/okhttp-scenario/src/main/java/test/apache/skywalking/testcase/okhttp/Application.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 test.apache.skywalking.testcase.okhttp; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; + +@EnableAutoConfiguration +@SpringBootApplication +@ComponentScan("test.apache.skywalking.testcase.okhttp") +public class Application extends SpringBootServletInitializer { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/okhttp-scenario/src/main/java/test/apache/skywalking/testcase/okhttp/controller/CaseController.java b/test/plugin/scenarios/okhttp-scenario/src/main/java/test/apache/skywalking/testcase/okhttp/controller/CaseController.java new file mode 100644 index 0000000000..fa70392cf9 --- /dev/null +++ b/test/plugin/scenarios/okhttp-scenario/src/main/java/test/apache/skywalking/testcase/okhttp/controller/CaseController.java @@ -0,0 +1,76 @@ +/* + * 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 test.apache.skywalking.testcase.okhttp.controller; + +import java.io.IOException; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/case") +public class CaseController { + + @RequestMapping("/receiveContext-1") + @ResponseBody + public String receiveContextService1() throws InterruptedException { + return "receiveContext-1"; + } + + @RequestMapping("/receiveContext-0") + @ResponseBody + public String receiveContextService0() throws InterruptedException { + return "receiveContext-0"; + } + + @RequestMapping("/okhttp-case") + @ResponseBody + public String okHttpScenario() { + Request request = new Request.Builder() + .url("http://127.0.0.1:8080/okhttp-case/case/receiveContext-0") + .build(); + + new OkHttpClient().newCall(request).enqueue(new Callback() { + @Override public void onFailure(Call call, IOException e) { + //Never do this + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + Request request = new Request.Builder() + .url("http://127.0.0.1:8080/okhttp-case/case/receiveContext-1") + .build(); + new OkHttpClient().newCall(request).execute(); + } + }); + + return "Success"; + } + + @RequestMapping(value = "/healthCheck") + @ResponseBody + public String healthCheck() { + return "Success"; + } +} diff --git a/test/plugin/scenarios/okhttp-scenario/src/main/resources/application.properties b/test/plugin/scenarios/okhttp-scenario/src/main/resources/application.properties new file mode 100644 index 0000000000..b75d49c49d --- /dev/null +++ b/test/plugin/scenarios/okhttp-scenario/src/main/resources/application.properties @@ -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=8080 +server.contextPath=/okhttp-case \ No newline at end of file diff --git a/test/plugin/scenarios/okhttp-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/okhttp-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/okhttp-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/okhttp-scenario/support-version.list b/test/plugin/scenarios/okhttp-scenario/support-version.list new file mode 100644 index 0000000000..5f9ee143f5 --- /dev/null +++ b/test/plugin/scenarios/okhttp-scenario/support-version.list @@ -0,0 +1,50 @@ +# 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. + +3.0.0 +3.0.1 +3.1.0 +3.1.1 +3.1.2 +3.2.0 +3.3.0 +3.3.1 +3.4.0 +3.4.1 +3.4.2 +3.5.0 +3.6.0 +3.7.0 +3.8.0 +3.8.1 +3.9.0 +3.9.1 +3.10.0 +3.11.0 +3.12.0 +3.12.1 +3.12.2 +3.12.3 +3.12.4 +3.12.5 +3.12.6 +3.13.0 +3.13.1 +3.14.0 +3.14.1 +3.14.2 +3.14.3 +3.14.4 \ No newline at end of file -- GitLab