From e139e163662d33295bee4e9e1cecb59ee9e81be7 Mon Sep 17 00:00:00 2001 From: zhang-wei Date: Tue, 10 Dec 2019 13:22:32 +0800 Subject: [PATCH] [test/plugin] immigrate jdk http scenario (#4035) * jdk-http * jdk-http-scenario * action --- .github/workflows/plugins-test.yaml | 4 +- .../jdk-http-scenario/bin/startup.sh | 21 ++++ .../config/expectedData.yaml | 85 +++++++++++++ .../jdk-http-scenario/configuration.yml | 23 ++++ .../scenarios/jdk-http-scenario/pom.xml | 113 ++++++++++++++++++ .../src/main/assembly/assembly.xml | 41 +++++++ .../apm/testcase/jdkhttp/Application.java | 35 ++++++ .../jdkhttp/controller/CaseController.java | 62 ++++++++++ .../src/main/resources/application.yaml | 23 ++++ .../src/main/resources/log4j2.xml | 30 +++++ .../jdk-http-scenario/support-version.list | 19 +++ 11 files changed, 455 insertions(+), 1 deletion(-) create mode 100644 test/plugin/scenarios/jdk-http-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/jdk-http-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/jdk-http-scenario/configuration.yml create mode 100644 test/plugin/scenarios/jdk-http-scenario/pom.xml create mode 100644 test/plugin/scenarios/jdk-http-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/jdk-http-scenario/src/main/java/org/apache/skywalking/apm/testcase/jdkhttp/Application.java create mode 100644 test/plugin/scenarios/jdk-http-scenario/src/main/java/org/apache/skywalking/apm/testcase/jdkhttp/controller/CaseController.java create mode 100644 test/plugin/scenarios/jdk-http-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/jdk-http-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/jdk-http-scenario/support-version.list diff --git a/.github/workflows/plugins-test.yaml b/.github/workflows/plugins-test.yaml index 415fd31d4d..8270883184 100644 --- a/.github/workflows/plugins-test.yaml +++ b/.github/workflows/plugins-test.yaml @@ -445,7 +445,7 @@ jobs: - name: Run elasticsearch-6.x-scenario 6.7.1-6.8.4 (7) run: bash test/plugin/run.sh elasticsearch-6.x-scenario - Oracle_Kafka: + Oracle_Kafka_JdkHttp: runs-on: ubuntu-18.04 timeout-minutes: 90 strategy: @@ -474,6 +474,8 @@ jobs: bash test/plugin/run.sh oracle-scenario - name: Run kafka 0.11.0.0-2.3.0 (16) run: bash test/plugin/run.sh kafka-scenario + - name: Run jdk http (1) + run: bash test/plugin/run.sh jdk-http-scenario MySQL: runs-on: ubuntu-18.04 diff --git a/test/plugin/scenarios/jdk-http-scenario/bin/startup.sh b/test/plugin/scenarios/jdk-http-scenario/bin/startup.sh new file mode 100644 index 0000000000..7a40e28178 --- /dev/null +++ b/test/plugin/scenarios/jdk-http-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/jdk-http-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/jdk-http-scenario/config/expectedData.yaml b/test/plugin/scenarios/jdk-http-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..de4357b0eb --- /dev/null +++ b/test/plugin/scenarios/jdk-http-scenario/config/expectedData.yaml @@ -0,0 +1,85 @@ +# 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: + - {jdk-http-scenario: 2} + instances: + - {jdk-http-scenario: 1} + operationNames: + - jdk-http-scenario: [/jdk-http-scenario/case/receiveContext-0, /jdk-http-scenario/case/jdk-http-scenario] + heartbeat: [] +segmentItems: + - applicationCode: jdk-http-scenario + segmentSize: gt 2 + segments: + - segmentId: not null + spans: + - operationName: /jdk-http-scenario/case/receiveContext-0 + 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/jdk-http-scenario/case/receiveContext-0'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /jdk-http-scenario/case/jdk-http-scenario, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /jdk-http-scenario/case/jdk-http-scenario, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /jdk-http-scenario/case/receiveContext-0 + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 66 + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:8080/jdk-http-scenario/case/receiveContext-0'} + - operationName: /jdk-http-scenario/case/jdk-http-scenario + 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/jdk-http-scenario/case/jdk-http-scenario'} + - {key: http.method, value: GET} diff --git a/test/plugin/scenarios/jdk-http-scenario/configuration.yml b/test/plugin/scenarios/jdk-http-scenario/configuration.yml new file mode 100644 index 0000000000..08f7c66a1f --- /dev/null +++ b/test/plugin/scenarios/jdk-http-scenario/configuration.yml @@ -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. + +type: jvm +entryService: http://localhost:8080/jdk-http-scenario/case/jdk-http-scenario +healthCheck: http://localhost:8080/jdk-http-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: jdk-http-scenario +runningMode: with_bootstrap +withPlugins: apm-jdk-http-plugin-*.jar diff --git a/test/plugin/scenarios/jdk-http-scenario/pom.xml b/test/plugin/scenarios/jdk-http-scenario/pom.xml new file mode 100644 index 0000000000..b2dfb45160 --- /dev/null +++ b/test/plugin/scenarios/jdk-http-scenario/pom.xml @@ -0,0 +1,113 @@ + + + + + org.apache.skywalking.apm.testcase + jdk-http-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + + YOUR VERSION + + 2.1.6.RELEASE + + + skywalking-jdk-http-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 + + + + + jdk-http-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/jdk-http-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/jdk-http-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..c543047594 --- /dev/null +++ b/test/plugin/scenarios/jdk-http-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/jdk-http-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/jdk-http-scenario/src/main/java/org/apache/skywalking/apm/testcase/jdkhttp/Application.java b/test/plugin/scenarios/jdk-http-scenario/src/main/java/org/apache/skywalking/apm/testcase/jdkhttp/Application.java new file mode 100644 index 0000000000..315fd0be48 --- /dev/null +++ b/test/plugin/scenarios/jdk-http-scenario/src/main/java/org/apache/skywalking/apm/testcase/jdkhttp/Application.java @@ -0,0 +1,35 @@ +/* + * 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.jdkhttp; + +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/jdk-http-scenario/src/main/java/org/apache/skywalking/apm/testcase/jdkhttp/controller/CaseController.java b/test/plugin/scenarios/jdk-http-scenario/src/main/java/org/apache/skywalking/apm/testcase/jdkhttp/controller/CaseController.java new file mode 100644 index 0000000000..6b1ffaf273 --- /dev/null +++ b/test/plugin/scenarios/jdk-http-scenario/src/main/java/org/apache/skywalking/apm/testcase/jdkhttp/controller/CaseController.java @@ -0,0 +1,62 @@ +/* + * 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.jdkhttp.controller; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger logger = LogManager.getLogger(CaseController.class); + + private static final String SUCCESS = "Success"; + + @RequestMapping("/jdk-http-scenario") + @ResponseBody + public String testcase() throws IOException { + URL url = new URL("http://localhost:8080/jdk-http-scenario/case/receiveContext-0"); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.addRequestProperty("key","value"); + int responseCode = connection.getResponseCode(); + return "Success:" + responseCode; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + // your codes + return SUCCESS; + } + + @RequestMapping("/receiveContext-0") + @ResponseBody + public String receiveContextService0() { + return "receiveContext-0"; + } + +} diff --git a/test/plugin/scenarios/jdk-http-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/jdk-http-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000..64b24a47dc --- /dev/null +++ b/test/plugin/scenarios/jdk-http-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: /jdk-http-scenario +logging: + config: classpath:log4j2.xml \ No newline at end of file diff --git a/test/plugin/scenarios/jdk-http-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/jdk-http-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/jdk-http-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jdk-http-scenario/support-version.list b/test/plugin/scenarios/jdk-http-scenario/support-version.list new file mode 100644 index 0000000000..14415183e6 --- /dev/null +++ b/test/plugin/scenarios/jdk-http-scenario/support-version.list @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version +# "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 + +all \ No newline at end of file -- GitLab