Skip to content

Commit 4057dcc

Browse files
yingziismeMateusz Rzeszutek
and
Mateusz Rzeszutek
authored
Fix testLatestDeps in dubbo instrumentation (#6754)
Co-authored-by: Mateusz Rzeszutek <[email protected]>
1 parent 6fdea85 commit 4057dcc

File tree

6 files changed

+11
-16
lines changed

6 files changed

+11
-16
lines changed

instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts

-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@ tasks.withType<Test>().configureEach {
2727
jvmArgs("--add-opens=java.base/java.math=ALL-UNNAMED")
2828
// required on jdk17
2929
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
30-
31-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
3230
}

instrumentation/apache-dubbo-2.7/javaagent/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
package io.opentelemetry.instrumentation.apachedubbo.v2_7
77

88
import io.opentelemetry.instrumentation.test.AgentTestTrait
9-
import spock.lang.IgnoreIf
109

11-
// TODO (trask) fix the test on latest version of dubbo
12-
@IgnoreIf({ Boolean.getBoolean("testLatestDeps") })
1310
class DubboTraceChainTest extends AbstractDubboTraceChainTest implements AgentTestTrait {
1411
}

instrumentation/apache-dubbo-2.7/library-autoconfigure/build.gradle.kts

-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,4 @@ tasks.withType<Test>().configureEach {
1919
jvmArgs("--add-opens=java.base/java.math=ALL-UNNAMED")
2020
// required on jdk17
2121
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
22-
23-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
2422
}

instrumentation/apache-dubbo-2.7/library-autoconfigure/src/test/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTraceChainTest.groovy

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
package io.opentelemetry.instrumentation.apachedubbo.v2_7
77

88
import io.opentelemetry.instrumentation.test.LibraryTestTrait
9-
import spock.lang.IgnoreIf
109

11-
// TODO (trask) fix the test on latest version of dubbo
12-
@IgnoreIf({ Boolean.getBoolean("testLatestDeps") })
1310
class DubboTraceChainTest extends AbstractDubboTraceChainTest implements LibraryTestTrait {
1411
}

instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTraceChainTest.groovy

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
5959
return service
6060
}
6161

62-
ServiceConfig configureMiddleServer(GenericService genericService) {
62+
ServiceConfig configureMiddleServer(ReferenceConfig<HelloService> referenceConfig) {
6363
def registerConfig = new RegistryConfig()
6464
registerConfig.setAddress("N/A")
6565
ServiceConfig<MiddleServiceImpl> service = new ServiceConfig<>()
6666
service.setInterface(MiddleService)
67-
service.setRef(new MiddleServiceImpl(genericService))
67+
service.setRef(new MiddleServiceImpl(referenceConfig))
6868
service.setRegistry(registerConfig)
6969
return service
7070
}
@@ -89,7 +89,7 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
8989
DubboBootstrap middleBootstrap = DubboBootstrap.newInstance()
9090
middleBootstrap.application(new ApplicationConfig("dubbo-demo-middle"))
9191
.reference(reference)
92-
.service(configureMiddleServer(reference.get()))
92+
.service(configureMiddleServer(reference))
9393
.protocol(middleProtocolConfig)
9494
.start()
9595

@@ -154,6 +154,9 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
154154
"$SemanticAttributes.RPC_METHOD" "\$invoke"
155155
"$SemanticAttributes.NET_PEER_NAME" "localhost"
156156
"$SemanticAttributes.NET_PEER_PORT" Long
157+
"net.sock.peer.addr" { it == null || String }
158+
"net.sock.peer.port" { it == null || Long }
159+
"net.sock.peer.name" { it == null || String }
157160
}
158161
}
159162
span(4) {

instrumentation/apache-dubbo-2.7/testing/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/impl/MiddleServiceImpl.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
package io.opentelemetry.instrumentation.apachedubbo.v2_7.impl;
77

88
import io.opentelemetry.instrumentation.apachedubbo.v2_7.api.MiddleService;
9+
import org.apache.dubbo.config.ReferenceConfig;
910
import org.apache.dubbo.rpc.service.GenericService;
1011

1112
public class MiddleServiceImpl implements MiddleService {
1213

13-
private final GenericService genericService;
14+
private final ReferenceConfig<?> referenceConfig;
1415

15-
public MiddleServiceImpl(GenericService genericService) {
16-
this.genericService = genericService;
16+
public MiddleServiceImpl(ReferenceConfig<?> referenceConfig) {
17+
this.referenceConfig = referenceConfig;
1718
}
1819

1920
@Override
2021
public String hello(String hello) {
22+
GenericService genericService = (GenericService) referenceConfig.get();
2123
return genericService
2224
.$invoke("hello", new String[] {String.class.getName()}, new Object[] {hello})
2325
.toString();

0 commit comments

Comments
 (0)