From 7693ba5cf7deb0183b6191a748f2a6bebbaeeb85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E7=A6=B9=E5=85=89?= Date: Sat, 20 Jun 2020 17:49:17 +0800 Subject: [PATCH 1/2] add Quasar plugin --- .../trace/component/ComponentsDefine.java | 2 + apm-sniffer/apm-sdk-plugin/pom.xml | 1 + .../apm-sdk-plugin/quasar-plugin/pom.xml | 45 ++++++ .../apm/plugin/quasar/FiberInterceptor.java | 68 ++++++++++ .../quasar/define/FiberInstrumentation.java | 82 +++++++++++ .../src/main/resources/skywalking-plugin.def | 17 +++ .../java-agent/Supported-list.md | 1 + .../main/resources/component-libraries.yml | 3 + .../test/resources/component-libraries.yml | 3 + .../scenarios/quasar-scenario/bin/startup.sh | 21 +++ .../quasar-scenario/config/expectedData.yaml | 70 ++++++++++ .../quasar-scenario/configuration.yml | 20 +++ test/plugin/scenarios/quasar-scenario/pom.xml | 128 ++++++++++++++++++ .../src/main/assembly/assembly.xml | 41 ++++++ .../apm/testcase/quasar/Application.java | 39 ++++++ .../quasar/controller/CaseController.java | 82 +++++++++++ .../src/main/resources/application.yaml | 23 ++++ .../src/main/resources/log4j2.xml | 30 ++++ .../quasar-scenario/support-version.list | 23 ++++ 19 files changed, 699 insertions(+) create mode 100644 apm-sniffer/apm-sdk-plugin/quasar-plugin/pom.xml create mode 100644 apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/FiberInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/define/FiberInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/resources/skywalking-plugin.def create mode 100644 test/plugin/scenarios/quasar-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/quasar-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/quasar-scenario/configuration.yml create mode 100644 test/plugin/scenarios/quasar-scenario/pom.xml create mode 100644 test/plugin/scenarios/quasar-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/quasar-scenario/src/main/java/org/apache/skywalking/apm/testcase/quasar/Application.java create mode 100644 test/plugin/scenarios/quasar-scenario/src/main/java/org/apache/skywalking/apm/testcase/quasar/controller/CaseController.java create mode 100644 test/plugin/scenarios/quasar-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/quasar-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/quasar-scenario/support-version.list diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java index c608ae3346c4..963baa04d0ba 100755 --- a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java +++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java @@ -158,4 +158,6 @@ public class ComponentsDefine { public static final OfficialComponent FINAGLE = new OfficialComponent(85, "Finagle"); public static final OfficialComponent MARIADB_JDBC = new OfficialComponent(87, "mariadb-jdbc"); + + public static final OfficialComponent QUASAR = new OfficialComponent(88, "quasar"); } diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml index 4520b78a9c86..b9e43a3d7fa3 100644 --- a/apm-sniffer/apm-sdk-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/pom.xml @@ -90,6 +90,7 @@ lettuce-5.x-plugin avro-plugin finagle-6.25.x-plugin + quasar-plugin mariadb-2.x-plugin pom diff --git a/apm-sniffer/apm-sdk-plugin/quasar-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/quasar-plugin/pom.xml new file mode 100644 index 000000000000..4ba518df291e --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/quasar-plugin/pom.xml @@ -0,0 +1,45 @@ + + + + + 4.0.0 + + org.apache.skywalking + apm-sdk-plugin + 8.1.0-SNAPSHOT + + + apm-quasar-plugin + jar + + quasar-plugin + http://maven.apache.org + + 0.7.10 + + + + + co.paralleluniverse + quasar-core + ${quasar-core.version} + provided + + + \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/FiberInterceptor.java b/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/FiberInterceptor.java new file mode 100644 index 000000000000..744dd4db4673 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/FiberInterceptor.java @@ -0,0 +1,68 @@ +/* + * 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.plugin.quasar; + +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; + +import java.lang.reflect.Method; + +public class FiberInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor { + + private static final String OPERATION_NAME = "QUASAR/Fiber"; + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + AbstractSpan span = ContextManager.createLocalSpan(OPERATION_NAME); + span.setComponent(ComponentsDefine.QUASAR); + if (objInst.getSkyWalkingDynamicField() != null) { + ContextManager.continued((ContextSnapshot) objInst.getSkyWalkingDynamicField()); + objInst.setSkyWalkingDynamicField(null); + } + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + ContextManager.stopSpan(); + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + AbstractSpan span = ContextManager.activeSpan(); + span.errorOccurred(); + span.log(t); + } + + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + if (ContextManager.isActive()) { + objInst.setSkyWalkingDynamicField(ContextManager.capture()); + } + } +} diff --git a/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/define/FiberInstrumentation.java b/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/define/FiberInstrumentation.java new file mode 100644 index 000000000000..a42f6a79863a --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/java/org/apache/skywalking/apm/plugin/quasar/define/FiberInstrumentation.java @@ -0,0 +1,82 @@ +/* + * 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.plugin.quasar.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static net.bytebuddy.matcher.ElementMatchers.isProtected; +import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +public class FiberInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "co.paralleluniverse.fibers.Fiber"; + + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.quasar.FiberInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return takesArgumentWithType(3, "co.paralleluniverse.strands.SuspendableCallable"); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPTOR_CLASS; + } + } + }; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return isProtected().and(named("run")); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPTOR_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + public ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000000..a7b9327cdeec --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/quasar-plugin/src/main/resources/skywalking-plugin.def @@ -0,0 +1,17 @@ +# 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. + +quasar=org.apache.skywalking.apm.plugin.quasar.define.FiberInstrumentation \ No newline at end of file diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md index 28d9ca2c2755..d3321fa227e9 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -88,6 +88,7 @@ * Vert.x Web 3.x * Thread Schedule Framework * [Spring @Async](https://github.com/spring-projects/spring-framework) 4.x and 5.x + * [Quasar](https://github.com/puniverse/quasar) 0.7.x * Cache * [Ehcache](https://www.ehcache.org/) 2.x * Kotlin diff --git a/oap-server/server-bootstrap/src/main/resources/component-libraries.yml b/oap-server/server-bootstrap/src/main/resources/component-libraries.yml index efb647a74b71..bc3c384c59bd 100755 --- a/oap-server/server-bootstrap/src/main/resources/component-libraries.yml +++ b/oap-server/server-bootstrap/src/main/resources/component-libraries.yml @@ -293,6 +293,9 @@ Mariadb: mariadb-jdbc: id: 87 languages: Java +quasar: + id: 88 + languages: Java # .NET/.NET Core components # [3000, 4000) for C#/.NET only diff --git a/oap-server/server-core/src/test/resources/component-libraries.yml b/oap-server/server-core/src/test/resources/component-libraries.yml index 44a9d127ab9c..02ecbef9f6ea 100755 --- a/oap-server/server-core/src/test/resources/component-libraries.yml +++ b/oap-server/server-core/src/test/resources/component-libraries.yml @@ -257,6 +257,9 @@ Mariadb: mariadb-jdbc: id: 87 languages: Java +quasar: + id: 88 + languages: Java # .NET/.NET Core components diff --git a/test/plugin/scenarios/quasar-scenario/bin/startup.sh b/test/plugin/scenarios/quasar-scenario/bin/startup.sh new file mode 100644 index 000000000000..e633a34541f5 --- /dev/null +++ b/test/plugin/scenarios/quasar-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} -Dco.paralleluniverse.fibers.detectRunawayFibers=false ${home}/../libs/quasar-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/quasar-scenario/config/expectedData.yaml b/test/plugin/scenarios/quasar-scenario/config/expectedData.yaml new file mode 100644 index 000000000000..db06dbb3eed8 --- /dev/null +++ b/test/plugin/scenarios/quasar-scenario/config/expectedData.yaml @@ -0,0 +1,70 @@ +# 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. +segmentItems: +- serviceName: quasar-scenario + segmentSize: ge 3 + segments: + - segmentId: not null + spans: + - operationName: /quasar-scenario/case/quasar-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: url, value: 'http://localhost:8080/quasar-scenario/case/quasar-scenario'} + - {key: http.method, value: GET} + - segmentId: not null + spans: + - operationName: /quasar-scenario/case/ping + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 12 + isError: false + spanType: Exit + peer: localhost:8080 + skipAnalysis: false + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:8080/quasar-scenario/case/ping'} + - operationName: QUASAR/Fiber + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Unknown + startTime: nq 0 + endTime: nq 0 + componentId: 88 + isError: false + spanType: Local + peer: '' + skipAnalysis: false + refs: + - {parentEndpoint: /quasar-scenario/case/quasar-scenario, networkAddress: '', + refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: quasar-scenario, + traceId: not null} \ No newline at end of file diff --git a/test/plugin/scenarios/quasar-scenario/configuration.yml b/test/plugin/scenarios/quasar-scenario/configuration.yml new file mode 100644 index 000000000000..5f1c88af402e --- /dev/null +++ b/test/plugin/scenarios/quasar-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: jvm +entryService: http://localhost:8080/quasar-scenario/case/quasar-scenario +healthCheck: http://localhost:8080/quasar-scenario/case/healthCheck +startScript: ./bin/startup.sh diff --git a/test/plugin/scenarios/quasar-scenario/pom.xml b/test/plugin/scenarios/quasar-scenario/pom.xml new file mode 100644 index 000000000000..7e2825000f56 --- /dev/null +++ b/test/plugin/scenarios/quasar-scenario/pom.xml @@ -0,0 +1,128 @@ + + + + + org.apache.skywalking.apm.testcase + quasar-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + + 0.7.9 + ${test.framework.version} + + 2.1.6.RELEASE + 3.6.0 + + + skywalking-quasar-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 + + + + co.paralleluniverse + quasar-core + ${test.framework.version} + + + + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + + + + + quasar-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/quasar-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/quasar-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000000..498d1361a7b6 --- /dev/null +++ b/test/plugin/scenarios/quasar-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/quasar-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/quasar-scenario/src/main/java/org/apache/skywalking/apm/testcase/quasar/Application.java b/test/plugin/scenarios/quasar-scenario/src/main/java/org/apache/skywalking/apm/testcase/quasar/Application.java new file mode 100644 index 000000000000..8f675583a052 --- /dev/null +++ b/test/plugin/scenarios/quasar-scenario/src/main/java/org/apache/skywalking/apm/testcase/quasar/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 org.apache.skywalking.apm.testcase.quasar; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + private static final Logger logger = LogManager.getLogger(Application.class); + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception ex) { + logger.error("Application start error", ex); + throw ex; + } + } +} diff --git a/test/plugin/scenarios/quasar-scenario/src/main/java/org/apache/skywalking/apm/testcase/quasar/controller/CaseController.java b/test/plugin/scenarios/quasar-scenario/src/main/java/org/apache/skywalking/apm/testcase/quasar/controller/CaseController.java new file mode 100644 index 000000000000..6635fc2f7289 --- /dev/null +++ b/test/plugin/scenarios/quasar-scenario/src/main/java/org/apache/skywalking/apm/testcase/quasar/controller/CaseController.java @@ -0,0 +1,82 @@ +/* + * 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.quasar.controller; + +import co.paralleluniverse.fibers.Fiber; +import co.paralleluniverse.strands.SuspendableCallable; +import okhttp3.Call; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +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; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger logger = LogManager.getLogger(CaseController.class); + + private static final String SUCCESS = "Success"; + + @RequestMapping("/quasar-scenario") + @ResponseBody + public String testcase() throws Exception { + Fiber fiber = new Fiber("fiber", new SuspendableCallable() { + @Override + public Object run() { + try { + call("http://localhost:8080/quasar-scenario/case/ping"); + } catch (Exception e) { + logger.error("quasar error:", e); + } + return null; + } + } + ); + fiber.start(); + return SUCCESS; + } + + private String call(String url) throws IOException { + OkHttpClient okHttpClient = new OkHttpClient(); + final Request request = new Request.Builder().url(url).build(); + Call call = okHttpClient.newCall(request); + Response response = call.execute(); + return response.body().string(); + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() throws Exception { + return SUCCESS; + } + + @RequestMapping("/ping") + @ResponseBody + public String ping() throws Exception { + return SUCCESS; + } + +} diff --git a/test/plugin/scenarios/quasar-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/quasar-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000000..42c5fcf44be1 --- /dev/null +++ b/test/plugin/scenarios/quasar-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: /quasar-scenario +logging: + config: classpath:log4j2.xml diff --git a/test/plugin/scenarios/quasar-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/quasar-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000000..d74f8371eb84 --- /dev/null +++ b/test/plugin/scenarios/quasar-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/test/plugin/scenarios/quasar-scenario/support-version.list b/test/plugin/scenarios/quasar-scenario/support-version.list new file mode 100644 index 000000000000..2b8a81d6b530 --- /dev/null +++ b/test/plugin/scenarios/quasar-scenario/support-version.list @@ -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 +# "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 + +0.7.10 +0.7.9 +0.7.8 +0.7.4 +0.7.0 From fb6c2be6fb00360cb6ea2b74460da557191b4881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E7=A6=B9=E5=85=89?= Date: Sat, 20 Jun 2020 20:53:32 +0800 Subject: [PATCH 2/2] add test --- .github/workflows/plugins-test.3.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index 10e06d8e8096..8f4850a7a0e8 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -45,6 +45,7 @@ jobs: - { name: 'vertx-web-3.54minus-scenario', title: 'Vert.x Web 3.0.0-3.5.4 (16)' } - { name: 'vertx-web-3.6plus-scenario', title: 'Vert.x Web 3.6.0-3.9.1 (14)' } - { name: 'mariadb-scenario', title: 'Mariadb 2.x (8)' } + - { name: 'quasar-scenario', title: 'quasar 0.7.x (5)' } steps: - uses: actions/checkout@v2 with: