diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index 74419fcc4..655b1b5e2 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -99,6 +99,7 @@ jobs: - guava-eventbus-scenario - shenyu-2.4.x-scenario - jdk-threadpool-scenario + - shenyu-2.4.x-dubbo-scenario steps: - uses: actions/checkout@v2 with: diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/pom.xml b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/pom.xml index 4d13809af..42f3c4048 100644 --- a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/pom.xml +++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/pom.xml @@ -31,6 +31,7 @@ UTF-8 5.0.0.RELEASE + 2.7.0 @@ -46,6 +47,15 @@ apm-spring-webflux-5.x-plugin ${project.version} + + + org.apache.dubbo + dubbo + ${apache-dubbo.version} + provided + + + diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/ApacheDubboPluginInterceptor.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/ApacheDubboPluginInterceptor.java new file mode 100644 index 000000000..1a22f3612 --- /dev/null +++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/ApacheDubboPluginInterceptor.java @@ -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. + * + */ + +package org.apache.skywalking.apm.plugin.shenyu.v24x; + +import java.lang.reflect.Method; + +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +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.plugin.shenyu.v24x.util.CommonUtil; + +/** + * shenyu ApacheDubboPlugin Interceptor. + */ +public class ApacheDubboPluginInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + CommonUtil.createLocalSpan(allArguments, "DubboPlugin"); + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Object ret) throws Throwable { + return CommonUtil.stopLocalSpan(allArguments, ret); + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + CommonUtil.logErrorLocalSpan(allArguments, t); + } +} diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/Constant.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/Constant.java new file mode 100644 index 000000000..5efeb737f --- /dev/null +++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/Constant.java @@ -0,0 +1,25 @@ +/* + * 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.shenyu.v24x; + +public class Constant { + public static final String SKYWALKING_CONTEXT_SNAPSHOT = "SKYWALKING_CONTEXT_SNAPSHOT"; + + public static final String PROXY_RPC_SPAN = "PROXY_RPC_SPAN"; +} diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/GlobalPluginExecuteMethodInterceptor.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/GlobalPluginExecuteMethodInterceptor.java index be727601b..5c65d9fe2 100644 --- a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/GlobalPluginExecuteMethodInterceptor.java +++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/GlobalPluginExecuteMethodInterceptor.java @@ -18,11 +18,6 @@ package org.apache.skywalking.apm.plugin.shenyu.v24x; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - import org.apache.skywalking.apm.agent.core.context.CarrierItem; import org.apache.skywalking.apm.agent.core.context.ContextCarrier; import org.apache.skywalking.apm.agent.core.context.ContextManager; @@ -39,21 +34,27 @@ import org.springframework.http.HttpHeaders; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchangeDecorator; import org.springframework.web.server.adapter.DefaultServerWebExchange; - import reactor.core.publisher.Mono; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import static org.apache.skywalking.apm.plugin.shenyu.v24x.Constant.SKYWALKING_CONTEXT_SNAPSHOT; + /** * Apache shenyu global-plugin interceptor. */ public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsAroundInterceptor { public static final String SHENYU_AGENT_TRACE_ID = "shenyu-agent-trace-id"; - public static final String SKYWALKING_CONTEXT_SNAPSHOT = "SKYWALKING_CONTEXT_SNAPSHOT"; + public static final String SKYWALKING_SPAN = "SKYWALKING_SPAN"; @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, - MethodInterceptResult result) throws Throwable { + MethodInterceptResult result) throws Throwable { ServerWebExchange exchange = (ServerWebExchange) allArguments[0]; ContextCarrier carrier = new ContextCarrier(); @@ -85,7 +86,7 @@ public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsArou @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, - Object ret) throws Throwable { + Object ret) throws Throwable { ServerWebExchange exchange = (ServerWebExchange) allArguments[0]; @@ -105,22 +106,22 @@ public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsArou return monoReturn .doOnError(throwable -> span.errorOccurred().log(throwable)) .doFinally(s -> { - try { - Optional.ofNullable(exchange.getResponse().getStatusCode()).ifPresent(httpStatus -> { - Tags.HTTP_RESPONSE_STATUS_CODE.set(span, httpStatus.value()); - if (httpStatus.isError()) { - span.errorOccurred(); - } - }); - } finally { - span.asyncFinish(); - } + try { + Optional.ofNullable(exchange.getResponse().getStatusCode()).ifPresent(httpStatus -> { + Tags.HTTP_RESPONSE_STATUS_CODE.set(span, httpStatus.value()); + if (httpStatus.isError()) { + span.errorOccurred(); + } + }); + } finally { + span.asyncFinish(); + } }); } @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, - Class[] argumentsTypes, Throwable t) { + Class[] argumentsTypes, Throwable t) { } public static EnhancedInstance getInstance(Object o) { diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/define/ApacheDubboPluginInstrumentation.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/define/ApacheDubboPluginInstrumentation.java new file mode 100644 index 000000000..731caf4bf --- /dev/null +++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/define/ApacheDubboPluginInstrumentation.java @@ -0,0 +1,73 @@ +/* + * 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.shenyu.v24x.define; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +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 net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; + +public class ApacheDubboPluginInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "org.apache.shenyu.plugin.apache.dubbo.ApacheDubboPlugin"; + + private static final String INTERCEPT_CLASS = + "org.apache.skywalking.apm.plugin.shenyu.v24x.ApacheDubboPluginInterceptor"; + + private static final String INTERCEPT_METHOD = "doDubboInvoker"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(INTERCEPT_METHOD); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + +} diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/util/CommonUtil.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/util/CommonUtil.java new file mode 100644 index 000000000..be15215bc --- /dev/null +++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/util/CommonUtil.java @@ -0,0 +1,78 @@ +/* + * 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.shenyu.v24x.util; + +import static org.apache.skywalking.apm.plugin.shenyu.v24x.Constant.PROXY_RPC_SPAN; + +import java.util.Objects; + +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.context.trace.SpanLayer; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.ServerWebExchangeDecorator; +import org.springframework.web.server.adapter.DefaultServerWebExchange; + +public class CommonUtil { + + public static EnhancedInstance getEnhancedServerWebExchange(Object o) { + EnhancedInstance instance = null; + if (o instanceof DefaultServerWebExchange) { + instance = (EnhancedInstance) o; + } else if (o instanceof ServerWebExchangeDecorator) { + ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate(); + return getEnhancedServerWebExchange(delegate); + } + return instance; + } + + public static void createLocalSpan(Object[] allArguments, String localOp) { + ServerWebExchange exchange = (ServerWebExchange) allArguments[0]; + EnhancedInstance enhancedInstance = CommonUtil.getEnhancedServerWebExchange(allArguments[0]); + AbstractSpan span = ContextManager.createLocalSpan(localOp); + span.setComponent(ComponentsDefine.APACHE_SHENYU); + SpanLayer.asRPCFramework(span); + if (enhancedInstance != null && enhancedInstance.getSkyWalkingDynamicField() != null) { + ContextManager.continued((ContextSnapshot) enhancedInstance.getSkyWalkingDynamicField()); + } + exchange.getAttributes().put(PROXY_RPC_SPAN, span); + } + + public static Object stopLocalSpan(Object[] allArguments, Object ret) { + ServerWebExchange exchange = (ServerWebExchange) allArguments[0]; + AbstractSpan span = (AbstractSpan) exchange.getAttributes().get(PROXY_RPC_SPAN); + if (Objects.isNull(span)) { + return ret; + } + ContextManager.stopSpan(span); + return ret; + } + + public static void logErrorLocalSpan(Object[] allArguments, Throwable t) { + ServerWebExchange exchange = (ServerWebExchange) allArguments[0]; + AbstractSpan span = (AbstractSpan) exchange.getAttributes().get(PROXY_RPC_SPAN); + if (Objects.isNull(span)) { + return ; + } + span.errorOccurred().log(t); + } +} diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/resources/skywalking-plugin.def index 3aec1ba56..a2fb65952 100644 --- a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/resources/skywalking-plugin.def +++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/resources/skywalking-plugin.def @@ -16,3 +16,5 @@ shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.GlobalPluginInstrumentation shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.ServerWebExchangeInstrumentation +shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.ApacheDubboPluginInstrumentation + diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/config/expectedData.yaml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/config/expectedData.yaml new file mode 100644 index 000000000..6df4aa21b --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/config/expectedData.yaml @@ -0,0 +1,134 @@ +# 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: shenyu-gateway + segmentSize: nq 0 + segments: + - segmentId: not null + spans: + - operationName: test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.$invoke(String,String[],Object[]) + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 3 + isError: false + spanType: Exit + peer: localhost:9999 + skipAnalysis: false + tags: + - { key: url, value: 'dubbo://localhost:9999/test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.$invoke(String,String[],Object[])' } + - operationName: DubboPlugin + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 127 + isError: false + spanType: Local + peer: '' + skipAnalysis: false + refs: + - { parentEndpoint: /dubbo/findById, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: shenyu-gateway, + traceId: not null } + - segmentId: not null + spans: + - operationName: /dubbo/findById + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 127 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - { key: url, value: 'http://localhost:9196/dubbo/findById?id=1' } + - { key: http.method, value: GET } + - { key: http.status_code, value: '200' } + refs: + - { parentEndpoint: 'GET:/entry/dubbo-service', networkAddress: 'localhost:9196', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: entry-service, + traceId: not null } + + - serviceName: dubbo-provider + segmentSize: nq 0 + segments: + - segmentId: not null + spans: + - operationName: test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.findById(String) + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 3 + isError: false + spanType: Entry + peer: not null + skipAnalysis: false + tags: + - { key: url, value: not null } + refs: + - {parentEndpoint: DubboPlugin, networkAddress: 'localhost:9999', refType: CrossProcess, + parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null , parentService: shenyu-gateway, + traceId: not null } + + - serviceName: entry-service + segmentSize: nq 0 + segments: + - segmentId: not null + spans: + - operationName: /dubbo/findById + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 13 + isError: false + spanType: Exit + peer: localhost:9196 + skipAnalysis: false + tags: + - {key: url, value: 'http://localhost:9196/dubbo/findById'} + - {key: http.method, value: GET} + - operationName: GET:/entry/dubbo-service + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 14 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: url, value: 'http://localhost:8888/entry/dubbo-service'} + - {key: http.method, value: GET} + +meterItems: [] \ No newline at end of file diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/configuration.yml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/configuration.yml new file mode 100644 index 000000000..7fcc25b22 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/configuration.yml @@ -0,0 +1,24 @@ +# 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:8888/entry/dubbo-service +healthCheck: http://localhost:8888/entry/check +startScript: ./bin/startup.sh +runningMode: with_optional +withPlugins: apm-shenyu-2.4.x-plugin-*.jar +environment: +dependencies: diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/pom.xml new file mode 100644 index 000000000..126cafc97 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/pom.xml @@ -0,0 +1,107 @@ + + + + + + org.apache.skywalking + shenyu-2.4.x-dubbo-scenario + 1.0.0 + pom + + 4.0.0 + + + shenyu-dubbo-entry + shenyu-dubbo-gateway + shenyu-dubbo + shenyu-dubbo-dist + + + + UTF-8 + 1.8 + 2.4.2 + 2.2.2.RELEASE + 2.4.2 + 1.18.20 + 2.7.0 + + 1.2.79 + + + skywalking-shenyu-2.4.x-dubbo-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + org.apache.shenyu + shenyu-spring-boot-starter-gateway + ${test.framework.version} + + + org.apache.shenyu + shenyu-spring-boot-starter-plugin-apache-dubbo + ${test.framework.version} + + + + org.apache.dubbo + dubbo + ${dubbo.version} + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + + + shenyu-2.4.x-dubbo-scenario + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + + + + + + diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/bin/startup.sh b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/bin/startup.sh new file mode 100644 index 000000000..b93b655fe --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/bin/startup.sh @@ -0,0 +1,29 @@ +#!/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=shenyu-gateway" ${home}/../libs/shenyu-dubbo-gateway.jar & +sleep 2 + +java -jar ${agent_opts} "-Dskywalking.agent.service_name=dubbo-provider" ${home}/../libs/shenyu-dubbo.jar & +sleep 1 + +java -jar ${agent_opts} "-Dskywalking.agent.service_name=entry-service" ${home}/../libs/shenyu-dubbo-entry.jar & +sleep 1 + diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/pom.xml new file mode 100644 index 000000000..ae1c34acc --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/pom.xml @@ -0,0 +1,59 @@ + + + + + shenyu-2.4.x-dubbo-scenario + org.apache.skywalking + 1.0.0 + + 4.0.0 + + shenyu-dubbo-dist + + + 8 + 8 + + + + + + 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/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/src/main/assembly/assembly.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/src/main/assembly/assembly.xml new file mode 100644 index 000000000..82fd2b8ca --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/src/main/assembly/assembly.xml @@ -0,0 +1,51 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ../shenyu-dubbo-entry/target/shenyu-dubbo-entry.jar + ./libs + 0775 + + + ../shenyu-dubbo-gateway/target/shenyu-dubbo-gateway.jar + ./libs + 0775 + + + ../shenyu-dubbo/target/shenyu-dubbo.jar + ./libs + 0775 + + + \ No newline at end of file diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/pom.xml new file mode 100644 index 000000000..5de653848 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/pom.xml @@ -0,0 +1,67 @@ + + + + + + shenyu-2.4.x-dubbo-scenario + org.apache.skywalking + 1.0.0 + + 4.0.0 + + shenyu-dubbo-entry + + + 8 + 8 + + + + + org.springframework.boot + spring-boot-starter-webflux + + + + org.springframework.boot + spring-boot-starter-logging + + + + + shenyu-dubbo-entry + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/EntryApplication.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/EntryApplication.java new file mode 100644 index 000000000..7b7a477de --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/EntryApplication.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 test.apache.skywalking.apm.testcase.shenyu.entry; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class EntryApplication { + + public static void main(final String[] args) { + SpringApplication.run(EntryApplication.class, args); + } +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/http/HttpEntryController.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/http/HttpEntryController.java new file mode 100644 index 000000000..bc5e2b900 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/http/HttpEntryController.java @@ -0,0 +1,58 @@ +/* + * 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.apm.testcase.shenyu.entry.http; + +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +/** + * http entry service. + */ +@RestController +@RequestMapping("/entry") +public class HttpEntryController { + + private static final String ORDER_GATEWAY_URL = "http://localhost:9196/dubbo/findById?id=1"; + + private final RestTemplate restTemplate = new RestTemplate(); + + @RequestMapping("/check") + public String healthCheck() { + return "ok"; + } + + @GetMapping(value = "/dubbo-service", produces = {APPLICATION_JSON_VALUE}) + public ResponseEntity httpService() throws Exception { + TimeUnit.MILLISECONDS.sleep(100); + ResponseEntity entity = restTemplate.getForEntity(ORDER_GATEWAY_URL, String.class); + if (entity.getStatusCode().is2xxSuccessful()) { + return ResponseEntity.ok(Optional.ofNullable(entity.getBody()).orElse("")); + } + return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body("failed"); + } + +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/resources/application.yml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/resources/application.yml new file mode 100644 index 000000000..516dbbeca --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/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: 8888 + diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/pom.xml new file mode 100644 index 000000000..2e67518d4 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/pom.xml @@ -0,0 +1,85 @@ + + + + + + shenyu-2.4.x-dubbo-scenario + org.apache.skywalking + 1.0.0 + + 4.0.0 + + shenyu-dubbo-gateway + + + 8 + 8 + + + + org.springframework.boot + spring-boot-starter-webflux + + + + org.apache.shenyu + shenyu-spring-boot-starter-gateway + + + org.apache.shenyu + shenyu-spring-boot-starter-plugin-apache-dubbo + + + org.apache.dubbo + dubbo + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + com.alibaba + fastjson + + + + + shenyu-dubbo-gateway + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/GatewayApplication.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/GatewayApplication.java new file mode 100644 index 000000000..a9b9d8917 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/GatewayApplication.java @@ -0,0 +1,33 @@ +/* + * 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.apm.testcase.shenyu.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * shenyu gateway application. + */ +@SpringBootApplication +public class GatewayApplication { + + public static void main(String[] args) { + SpringApplication.run(GatewayApplication.class, args); + } + +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/init/InitRouterRunner.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/init/InitRouterRunner.java new file mode 100644 index 000000000..0f986929a --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/init/InitRouterRunner.java @@ -0,0 +1,108 @@ +/* + * 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.apm.testcase.shenyu.gateway.init; + +import java.io.InputStream; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.apache.shenyu.common.dto.MetaData; +import org.apache.shenyu.common.dto.PluginData; +import org.apache.shenyu.common.dto.RuleData; +import org.apache.shenyu.common.dto.SelectorData; +import org.apache.shenyu.common.dto.convert.plugin.DubboRegisterConfig; +import org.apache.shenyu.plugin.apache.dubbo.cache.ApacheDubboConfigCache; +import org.apache.shenyu.plugin.global.cache.MetaDataCache; +import org.apache.shenyu.sync.data.api.PluginDataSubscriber; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.parser.Feature; +import com.fasterxml.jackson.core.type.TypeReference; + +import lombok.extern.slf4j.Slf4j; + +/** + * init gateway router runner. + */ +@Slf4j +@Component +public class InitRouterRunner implements CommandLineRunner { + + @Autowired + private PluginDataSubscriber subscriber; + + @Override + public void run(String... args) throws Exception { + String pluginPath = "/shenyu-plugin.json"; + String selectorPath = "/shenyu-selector.json"; + String rulePath = "/shenyu-rule.json"; + + try ( + InputStream pluginStream = getClass().getResourceAsStream(pluginPath); + InputStream selectorStream = getClass().getResourceAsStream(selectorPath); + InputStream ruleStream = getClass().getResourceAsStream(rulePath)) { + + Map pluginDataMap = JSON.parseObject(pluginStream, + new TypeReference>() { + }.getType(), Feature.AllowComment); + Map> selectorDataMap = JSON.parseObject(selectorStream, + new TypeReference>>() { + }.getType(), Feature.AllowComment); + Map> ruleDataMap = JSON.parseObject(ruleStream, + new TypeReference>>() { + }.getType(), Feature.AllowComment); + + pluginDataMap.values().forEach(subscriber::onSubscribe); + selectorDataMap.values().stream().flatMap(Collection::stream) + .forEach(data -> subscriber.onSelectorSubscribe(data)); + ruleDataMap.values().stream().flatMap(Collection::stream).forEach(subscriber::onRuleSubscribe); + + initDubbo(); + log.info("init router data finish."); + } catch (Exception e) { + log.error("init router failed", e); + } + } + + private void initDubbo() { + DubboRegisterConfig config = new DubboRegisterConfig(); + config.setProtocol("dubbo"); + config.setRegister("N/A"); + ApacheDubboConfigCache.getInstance().init(config); + + MetaData metaData = new MetaData(); + metaData.setId("1"); + metaData.setAppName("demo"); + metaData.setContextPath("/dubbo"); + metaData.setPath("/dubbo/findById"); + metaData.setRpcType("dubbo"); + metaData.setServiceName("test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService"); + metaData.setMethodName("findById"); + metaData.setParameterTypes("java.lang.String"); + metaData.setRpcExt("{\"url\":\"dubbo://localhost:9999\",\"loadbalance\":\"random\",\"retries\":0," + + "\"timeout\":3000,\"sent\":false,\"cluster\":\"failover\"}"); + metaData.setEnabled(true); + ApacheDubboConfigCache.getInstance().build(metaData); + MetaDataCache.getInstance().cache(metaData); + } + +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/application.yml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/application.yml new file mode 100644 index 000000000..cf59ab432 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/application.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. +# + +server: + port: 9196 + +spring: + main: + allow-bean-definition-overriding: true diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-plugin.json b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-plugin.json new file mode 100644 index 000000000..31a55a4e5 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-plugin.json @@ -0,0 +1,252 @@ +/** +# +# 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. +# +*/ +{ + "request": { + "id": "20", + "name": "request", + "config": null, + "role": "HttpProcess", + "enabled": false, + "sort": 120 + }, + "jwt": { + "id": "19", + "name": "jwt", + "config": "{\"secretKey\":\"key\"}", + "role": "Authentication", + "enabled": false, + "sort": 30 + }, + "paramMapping": { + "id": "22", + "name": "paramMapping", + "config": "{\"ruleHandlePageType\":\"custom\"}", + "role": "HttpProcess", + "enabled": false, + "sort": 70 + }, + "modifyResponse": { + "id": "23", + "name": "modifyResponse", + "config": "{\"ruleHandlePageType\":\"custom\"}", + "role": "HttpProcess", + "enabled": false, + "sort": 220 + }, + "sign": { + "id": "1", + "name": "sign", + "config": null, + "role": "Authentication", + "enabled": false, + "sort": 20 + }, + "dubbo": { + "id": "6", + "name": "dubbo", + "config": "{\"register\":\"N/A\",\"multiSelectorHandle\":\"1\",\"threadpool\":\"cached\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0}", + "role": "Proxy", + "enabled": true, + "sort": 310 + }, + "motan": { + "id": "17", + "name": "motan", + "config": "{\"register\":\"127.0.0.1:2181\"}", + "role": "Proxy", + "enabled": false, + "sort": 310 + }, + "oauth2": { + "id": "21", + "name": "oauth2", + "config": null, + "role": "Authentication", + "enabled": false, + "sort": 40 + }, + "rateLimiter": { + "id": "4", + "name": "rateLimiter", + "config": "{\"master\":\"mymaster\",\"mode\":\"standalone\",\"url\":\"192.168.1.1:6379\",\"password\":\"abc\"}", + "role": "FaultTolerance", + "enabled": false, + "sort": 60 + }, + "websocket": { + "id": "26", + "name": "websocket", + "config": "{\"multiSelectorHandle\":\"1\"}", + "role": "Proxy", + "enabled": true, + "sort": 200 + }, + "mqtt": { + "id": "28", + "name": "mqtt", + "config": "{\"port\": 9500,\"bossGroupThreadCount\": 1,\"maxPayloadSize\": 65536,\"workerGroupThreadCount\": 12,\"userName\": \"shenyu\",\"password\": \"shenyu\",\"isEncryptPassword\": false,\"encryptMode\": \"\",\"leakDetectorLevel\": \"DISABLED\"}", + "role": "Proxy", + "enabled": false, + "sort": 125 + }, + "tars": { + "id": "13", + "name": "tars tested", + "config": "{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}", + "role": "Proxy", + "enabled": false, + "sort": 310 + }, + "cryptorRequest": { + "id": "24", + "name": "cryptorRequest", + "config": null, + "role": "Cryptor", + "enabled": true, + "sort": 100 + }, + "divide": { + "id": "5", + "name": "divide", + "config": "{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}", + "role": "Proxy", + "enabled": false, + "sort": 200 + }, + "waf": { + "id": "2", + "name": "waf", + "config": "{\"model\":\"black\"}", + "role": "Authentication", + "enabled": false, + "sort": 50 + }, + "redirect": { + "id": "16", + "name": "redirect", + "config": null, + "role": "HttpProcess", + "enabled": false, + "sort": 110 + }, + "sentinel": { + "id": "10", + "name": "sentinel", + "config": null, + "role": "FaultTolerance", + "enabled": false, + "sort": 140 + }, + "hystrix": { + "id": "9", + "name": "hystrix", + "config": null, + "role": "FaultTolerance", + "enabled": false, + "sort": 130 + }, + "sofa": { + "id": "11", + "name": "sofa", + "config": "{\"protocol\":\"zookeeper\",\"register\":\"127.0.0.1:2181\"}", + "role": "Proxy", + "enabled": false, + "sort": 310 + }, + "cache": { + "id": "30", + "name": "cache", + "config": "{\"cacheType\":\"memory\"}", + "role": "Cache", + "enabled": false, + "sort": 10 + }, + "contextPath": { + "id": "14", + "name": "contextPath", + "config": null, + "role": "HttpProcess", + "enabled": true, + "sort": 80 + }, + "generalContext": { + "id": "27", + "name": "generalContext", + "config": null, + "role": "Common", + "enabled": true, + "sort": 125 + }, + "rewrite": { + "id": "3", + "name": "rewrite", + "config": null, + "role": "HttpProcess", + "enabled": false, + "sort": 90 + }, + "springCloud": { + "id": "8", + "name": "springCloud", + "config": null, + "role": "Proxy", + "enabled": false, + "sort": 200 + }, + "grpc": { + "id": "15", + "name": "grpc", + "config": "{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\",\"threadpool\":\"cached\"}", + "role": "Proxy", + "enabled": false, + "sort": 310 + }, + "resilience4j": { + "id": "12", + "name": "resilience4j", + "config": null, + "role": "FaultTolerance", + "enabled": false, + "sort": 310 + }, + "logging": { + "id": "18", + "name": "logging", + "config": null, + "role": "Logging", + "enabled": false, + "sort": 160 + }, + "cryptorResponse": { + "id": "25", + "name": "cryptorResponse", + "config": null, + "role": "Cryptor", + "enabled": true, + "sort": 410 + }, + "loggingRocketMQ": { + "id": "29", + "name": "loggingRocketMQ", + "config": "{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\": \"localhost:9876\",\"producerGroup\":\"shenyu-plugin-logging-rocketmq\"}", + "role": "Logging", + "enabled": false, + "sort": 170 + } +} \ No newline at end of file diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-rule.json b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-rule.json new file mode 100644 index 000000000..528fd4cc8 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-rule.json @@ -0,0 +1,41 @@ +/** +# +# 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. +# +*/ +{ + "1": [ + { + "id":"1", + "name":"/dubbo/findById", + "pluginName":"dubbo", + "selectorId":"1", + "matchMode":0, + "sort":1, + "enabled":true, + "loged":true, + "handle":"{\"retries\":0,\"loadbalance\":\"random\",\"timeout\":3000}", + "conditionDataList":[ + { + "paramType":"uri", + "operator":"=", + "paramName":"/", + "paramValue":"/dubbo/findById" + } + ] + } + ] +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-selector.json b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-selector.json new file mode 100644 index 000000000..a28bff6d5 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/resources/shenyu-selector.json @@ -0,0 +1,43 @@ +/** +# +# 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. +# +*/ +{ + "dubbo": [ + { + "id":"1", + "pluginId":"6", + "pluginName":"dubbo", + "name":"/dubbo", + "matchMode":0, + "type":1, + "sort":1, + "enabled":true, + "logged":true, + "continued":true, + "handle":"[{\"port\":0,\"weight\":50,\"warmup\":10,\"protocol\":\"dubbo://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:9999\",\"status\":true,\"timestamp\":1650471116019}]", + "conditionList":[ + { + "paramType":"uri", + "operator":"match", + "paramName":"/", + "paramValue":"/dubbo/**" + } + ] + } + ] +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/pom.xml new file mode 100644 index 000000000..646ce2be3 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/pom.xml @@ -0,0 +1,72 @@ + + + + + + shenyu-2.4.x-dubbo-scenario + org.apache.skywalking + 1.0.0 + + 4.0.0 + + shenyu-dubbo + + + 8 + 8 + + + + + org.springframework.boot + spring-boot-starter-webflux + + + + org.springframework.boot + spring-boot-starter-logging + + + + org.apache.dubbo + dubbo + + + + + shenyu-dubbo + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/DubboConfig.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/DubboConfig.java new file mode 100644 index 000000000..043650b7b --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/DubboConfig.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 test.apache.skywalking.apm.testcase.shenyu.http; + +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ProtocolConfig; +import org.apache.dubbo.config.ReferenceConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.ServiceConfig; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService; +import test.apache.skywalking.apm.testcase.shenyu.http.services.impl.OrderServiceImpl; + +@Configuration +public class DubboConfig { + + private ApplicationConfig applicationConfig = new ApplicationConfig("demo"); + + private RegistryConfig registryConfig = new RegistryConfig("N/A"); + + private ProtocolConfig protocolConfig = new ProtocolConfig("dubbo", 9999); + + @Bean(destroyMethod = "unexport") + public ServiceConfig service() { + ServiceConfig serviceConfig = new ServiceConfig<>(); + serviceConfig.setApplication(applicationConfig); + serviceConfig.setRegistry(registryConfig); + serviceConfig.setProtocol(protocolConfig); + serviceConfig.setInterface(OrderService.class); + serviceConfig.setRef(new OrderServiceImpl()); + serviceConfig.setTimeout(5000); + serviceConfig.export(); + return serviceConfig; + } + + @Bean(destroyMethod = "destroy") + public ReferenceConfig reference() { + ReferenceConfig referenceConfig = new ReferenceConfig<>(); + referenceConfig.setApplication(applicationConfig); + referenceConfig.setInterface(OrderService.class); + referenceConfig.setUrl("dubbo://localhost:9999"); + return referenceConfig; + } + +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/ShenyuDubboApplication.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/ShenyuDubboApplication.java new file mode 100644 index 000000000..599480379 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/ShenyuDubboApplication.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 test.apache.skywalking.apm.testcase.shenyu.http; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ShenyuDubboApplication { + + public static void main(final String[] args) { + SpringApplication.run(ShenyuDubboApplication.class, args); + } +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/controller/HealthController.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/controller/HealthController.java new file mode 100644 index 000000000..16212f7f5 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/controller/HealthController.java @@ -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. + */ + +package test.apache.skywalking.apm.testcase.shenyu.http.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * http health check endpoint. + */ +@RestController +@RequestMapping("/health") +public class HealthController { + + @RequestMapping("/check") + public String healthCheck() { + return "ok"; + } +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/services/OrderService.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/services/OrderService.java new file mode 100644 index 000000000..3142cd426 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/services/OrderService.java @@ -0,0 +1,24 @@ +/* + * 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.apm.testcase.shenyu.http.services; + +public interface OrderService { + + String findById(String id); +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/services/impl/OrderServiceImpl.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/services/impl/OrderServiceImpl.java new file mode 100644 index 000000000..00c36910f --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/java/test/apache/skywalking/apm/testcase/shenyu/http/services/impl/OrderServiceImpl.java @@ -0,0 +1,30 @@ +/* + * 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.apm.testcase.shenyu.http.services.impl; + +import test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService; + +public class OrderServiceImpl implements OrderService { + + @Override + public String findById(String id) { + + return "order data of id = " + id; + } +} diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/resources/application.yml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/src/main/resources/application.yml new file mode 100644 index 000000000..d2de3dc50 --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo/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: 7777 + diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/support-version.list b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/support-version.list new file mode 100644 index 000000000..c470a193d --- /dev/null +++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/support-version.list @@ -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. + +# lists your version here (Contains only the last version number of each minor version.) +2.4.2