Skip to content

Commit 3e9fd79

Browse files
committed
Add grpc 1.26.0->1.58.0 test case
support usePlaintext differential calling
1 parent 22b38a6 commit 3e9fd79

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import io.grpc.ManagedChannelBuilder;
2424
import io.grpc.stub.ClientCallStreamObserver;
2525
import io.grpc.stub.ClientResponseObserver;
26+
27+
import java.lang.reflect.Method;
2628
import java.util.Arrays;
2729
import java.util.Iterator;
2830
import java.util.List;
@@ -35,6 +37,8 @@
3537
import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc;
3638
import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest;
3739
import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply;
40+
import org.springframework.cglib.core.ReflectUtils;
41+
import org.springframework.util.ReflectionUtils;
3842
import org.springframework.web.bind.annotation.RequestMapping;
3943
import org.springframework.web.bind.annotation.ResponseBody;
4044
import org.springframework.web.bind.annotation.RestController;
@@ -56,7 +60,17 @@ public class CaseController {
5660

5761
@PostConstruct
5862
public void up() {
59-
channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext(true).build();
63+
ManagedChannelBuilder<?> managedChannelBuilder = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort);
64+
Method usePlaintext = ReflectionUtils.findMethod(managedChannelBuilder.getClass(), "usePlaintext");
65+
if (usePlaintext != null) {
66+
int paramCount = usePlaintext.getParameterCount();
67+
if (paramCount == 0) {// no parame method usePlaintext()
68+
ReflectionUtils.invokeMethod(usePlaintext, managedChannelBuilder);
69+
} else if (paramCount == 1 && usePlaintext.getParameterTypes()[0] == boolean.class) {// boolean method usePlaintext(true)
70+
ReflectionUtils.invokeMethod(usePlaintext, managedChannelBuilder, true);
71+
}
72+
}
73+
channel = managedChannelBuilder.build();
6074
greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor()));
6175
greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor()));
6276
greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor()));

test/plugin/scenarios/grpc-scenario/support-version.list

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,40 @@
1919

2020
# Contains only the last version number of each minor version
2121

22+
1.58.0
23+
1.57.0
24+
1.57.0
25+
1.56.0
26+
1.55.1
27+
1.54.0
28+
1.53.0
29+
1.52.0
30+
1.51.0
31+
1.50.0
32+
1.49.0
33+
1.48.0
34+
1.47.0
35+
1.46.0
36+
1.45.0
37+
1.44.0
38+
1.43.0
39+
1.42.0
40+
1.41.0
41+
1.40.0
42+
1.39.0
43+
1.38.0
44+
1.37.0
45+
1.36.0
46+
1.35.0
47+
1.34.0
48+
1.33.0
49+
1.32.1
50+
1.31.0
51+
1.30.0
52+
1.29.0
53+
1.28.0
54+
1.27.0
55+
1.26.0
2256
1.25.0
2357
1.24.2
2458
1.23.1

0 commit comments

Comments
 (0)