From 4057dcc04a2e1124d22f18a49e052aa5ce3635c5 Mon Sep 17 00:00:00 2001 From: yingziisme Date: Tue, 27 Sep 2022 01:03:31 +0800 Subject: [PATCH] Fix testLatestDeps in dubbo instrumentation (#6754) Co-authored-by: Mateusz Rzeszutek --- .../apache-dubbo-2.7/javaagent/build.gradle.kts | 2 -- .../apachedubbo/v2_7/DubboTraceChainTest.groovy | 3 --- .../library-autoconfigure/build.gradle.kts | 2 -- .../apachedubbo/v2_7/DubboTraceChainTest.groovy | 3 --- .../apachedubbo/v2_7/AbstractDubboTraceChainTest.groovy | 9 ++++++--- .../apachedubbo/v2_7/impl/MiddleServiceImpl.java | 8 +++++--- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts b/instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts index a2d1930347..6c206efce0 100644 --- a/instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts +++ b/instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts @@ -27,6 +27,4 @@ tasks.withType().configureEach { jvmArgs("--add-opens=java.base/java.math=ALL-UNNAMED") // required on jdk17 jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") - - systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) } diff --git a/instrumentation/apache-dubbo-2.7/javaagent/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy b/instrumentation/apache-dubbo-2.7/javaagent/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy index 979bceae23..432be03056 100644 --- a/instrumentation/apache-dubbo-2.7/javaagent/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy +++ b/instrumentation/apache-dubbo-2.7/javaagent/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy @@ -6,9 +6,6 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7 import io.opentelemetry.instrumentation.test.AgentTestTrait -import spock.lang.IgnoreIf -// TODO (trask) fix the test on latest version of dubbo -@IgnoreIf({ Boolean.getBoolean("testLatestDeps") }) class DubboTraceChainTest extends AbstractDubboTraceChainTest implements AgentTestTrait { } diff --git a/instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts b/instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts index da8e63cc6a..c37558dd4f 100644 --- a/instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts +++ b/instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts @@ -19,6 +19,4 @@ tasks.withType().configureEach { jvmArgs("--add-opens=java.base/java.math=ALL-UNNAMED") // required on jdk17 jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") - - systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) } diff --git a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy index ca5050df5d..ee0b1040de 100644 --- a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy +++ b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy @@ -6,9 +6,6 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7 import io.opentelemetry.instrumentation.test.LibraryTestTrait -import spock.lang.IgnoreIf -// TODO (trask) fix the test on latest version of dubbo -@IgnoreIf({ Boolean.getBoolean("testLatestDeps") }) class DubboTraceChainTest extends AbstractDubboTraceChainTest implements LibraryTestTrait { } diff --git a/instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTraceChainTest.groovy b/instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTraceChainTest.groovy index 708b6c1fd3..ae0ccfa64c 100644 --- a/instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTraceChainTest.groovy +++ b/instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTraceChainTest.groovy @@ -59,12 +59,12 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification return service } - ServiceConfig configureMiddleServer(GenericService genericService) { + ServiceConfig configureMiddleServer(ReferenceConfig referenceConfig) { def registerConfig = new RegistryConfig() registerConfig.setAddress("N/A") ServiceConfig service = new ServiceConfig<>() service.setInterface(MiddleService) - service.setRef(new MiddleServiceImpl(genericService)) + service.setRef(new MiddleServiceImpl(referenceConfig)) service.setRegistry(registerConfig) return service } @@ -89,7 +89,7 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification DubboBootstrap middleBootstrap = DubboBootstrap.newInstance() middleBootstrap.application(new ApplicationConfig("dubbo-demo-middle")) .reference(reference) - .service(configureMiddleServer(reference.get())) + .service(configureMiddleServer(reference)) .protocol(middleProtocolConfig) .start() @@ -154,6 +154,9 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification "$SemanticAttributes.RPC_METHOD" "\$invoke" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == null || String } + "net.sock.peer.port" { it == null || Long } + "net.sock.peer.name" { it == null || String } } } span(4) { diff --git a/instrumentation/apache-dubbo-2.7/testing/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/impl/MiddleServiceImpl.java b/instrumentation/apache-dubbo-2.7/testing/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/impl/MiddleServiceImpl.java index bdc1b68982..c461a8c922 100644 --- a/instrumentation/apache-dubbo-2.7/testing/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/impl/MiddleServiceImpl.java +++ b/instrumentation/apache-dubbo-2.7/testing/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/impl/MiddleServiceImpl.java @@ -6,18 +6,20 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7.impl; import io.opentelemetry.instrumentation.apachedubbo.v2_7.api.MiddleService; +import org.apache.dubbo.config.ReferenceConfig; import org.apache.dubbo.rpc.service.GenericService; public class MiddleServiceImpl implements MiddleService { - private final GenericService genericService; + private final ReferenceConfig referenceConfig; - public MiddleServiceImpl(GenericService genericService) { - this.genericService = genericService; + public MiddleServiceImpl(ReferenceConfig referenceConfig) { + this.referenceConfig = referenceConfig; } @Override public String hello(String hello) { + GenericService genericService = (GenericService) referenceConfig.get(); return genericService .$invoke("hello", new String[] {String.class.getName()}, new Object[] {hello}) .toString();