From d867b7aa3eab8f82b76c9589e02dcae6ce2872e9 Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Tue, 5 Sep 2023 15:27:34 +0200 Subject: [PATCH] Add reflection v1alpha test case --- grpc/client_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/grpc/client_test.go b/grpc/client_test.go index 4d161c3..b617e7e 100644 --- a/grpc/client_test.go +++ b/grpc/client_test.go @@ -23,6 +23,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" + v1alphagrpc "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" grpcstats "google.golang.org/grpc/stats" "google.golang.org/grpc/status" @@ -563,7 +564,31 @@ func TestClient(t *testing.T) { { name: "ReflectInvoke", setup: func(tb *httpmultibin.HTTPMultiBin) { + // this register both reflection APIs v1 and v1alpha reflection.Register(tb.ServerGRPC) + + tb.GRPCStub.EmptyCallFunc = func(ctx context.Context, _ *grpc_testing.Empty) (*grpc_testing.Empty, error) { + return &grpc_testing.Empty{}, nil + } + }, + initString: codeBlock{ + code: `var client = new grpc.Client();`, + }, + vuString: codeBlock{ + code: ` + client.connect("GRPCBIN_ADDR", {reflect: true}) + client.invoke("grpc.testing.TestService/EmptyCall", {}) + `, + }, + }, + { + name: "ReflectV1Alpha_Invoke", + setup: func(tb *httpmultibin.HTTPMultiBin) { + // this register only v1alpha (this could be removed with removal v1alpha from grpc-go) + s := tb.ServerGRPC + svr := reflection.NewServer(reflection.ServerOptions{Services: s}) + v1alphagrpc.RegisterServerReflectionServer(s, svr) + tb.GRPCStub.EmptyCallFunc = func(ctx context.Context, _ *grpc_testing.Empty) (*grpc_testing.Empty, error) { return &grpc_testing.Empty{}, nil } @@ -581,7 +606,9 @@ func TestClient(t *testing.T) { { name: "ReflectV1Invoke", setup: func(tb *httpmultibin.HTTPMultiBin) { + // this register only reflection APIs v1 reflection.RegisterV1(tb.ServerGRPC) + tb.GRPCStub.EmptyCallFunc = func(ctx context.Context, _ *grpc_testing.Empty) (*grpc_testing.Empty, error) { return &grpc_testing.Empty{}, nil }