From d3ae124a07fcb3eeddc18d84c5df3e82e182380c Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Tue, 12 Jan 2021 12:23:41 -0800 Subject: [PATCH] cleanup: use different import alias for services than messages (#4148) --- benchmark/benchmain/main.go | 18 ++++---- benchmark/benchmark.go | 24 ++++++----- benchmark/client/main.go | 4 +- benchmark/worker/benchmark_client.go | 10 +++-- benchmark/worker/main.go | 12 +++--- binarylog/binarylog_end2end_test.go | 28 +++++++------ interop/alts/client/client.go | 4 +- interop/alts/server/server.go | 5 ++- interop/client/client.go | 7 ++-- interop/grpclb_fallback/client.go | 14 ++++--- interop/http2/negative_http2_client.go | 18 ++++---- interop/server/server.go | 5 ++- interop/test_utils.go | 58 +++++++++++++------------- interop/xds/client/client.go | 20 +++++---- interop/xds/server/server.go | 8 ++-- stats/stats_test.go | 26 ++++++------ stress/client/main.go | 7 ++-- 17 files changed, 149 insertions(+), 119 deletions(-) diff --git a/benchmark/benchmain/main.go b/benchmark/benchmain/main.go index 509a1b905..55427035f 100644 --- a/benchmark/benchmain/main.go +++ b/benchmark/benchmain/main.go @@ -65,10 +65,12 @@ import ( "google.golang.org/grpc/benchmark/stats" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/internal/channelz" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" "google.golang.org/grpc/test/bufconn" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) var ( @@ -259,7 +261,7 @@ func unconstrainedStreamBenchmark(start startFunc, stop ucStopFunc, bf stats.Fea // service. The client is configured using the different options in the passed // 'bf'. Also returns a cleanup function to close the client and release // resources. -func makeClient(bf stats.Features) (testpb.BenchmarkServiceClient, func()) { +func makeClient(bf stats.Features) (testgrpc.BenchmarkServiceClient, func()) { nw := &latency.Network{Kbps: bf.Kbps, Latency: bf.Latency, MTU: bf.MTU} opts := []grpc.DialOption{} sopts := []grpc.ServerOption{} @@ -327,7 +329,7 @@ func makeClient(bf stats.Features) (testpb.BenchmarkServiceClient, func()) { lis = nw.Listener(lis) stopper := bm.StartServer(bm.ServerInfo{Type: "protobuf", Listener: lis}, sopts...) conn := bm.NewClientConn("" /* target not used */, opts...) - return testpb.NewBenchmarkServiceClient(conn), func() { + return testgrpc.NewBenchmarkServiceClient(conn), func() { conn.Close() stopper() } @@ -351,7 +353,7 @@ func makeFuncUnary(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) { func makeFuncStream(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) { tc, cleanup := makeClient(bf) - streams := make([]testpb.BenchmarkService_StreamingCallClient, bf.MaxConcurrentCalls) + streams := make([]testgrpc.BenchmarkService_StreamingCallClient, bf.MaxConcurrentCalls) for i := 0; i < bf.MaxConcurrentCalls; i++ { stream, err := tc.StreamingCall(context.Background()) if err != nil { @@ -402,10 +404,10 @@ func makeFuncUnconstrainedStream(bf stats.Features) (rpcSendFunc, rpcRecvFunc, r }, cleanup } -func setupUnconstrainedStream(bf stats.Features) ([]testpb.BenchmarkService_StreamingCallClient, *testpb.SimpleRequest, rpcCleanupFunc) { +func setupUnconstrainedStream(bf stats.Features) ([]testgrpc.BenchmarkService_StreamingCallClient, *testpb.SimpleRequest, rpcCleanupFunc) { tc, cleanup := makeClient(bf) - streams := make([]testpb.BenchmarkService_StreamingCallClient, bf.MaxConcurrentCalls) + streams := make([]testgrpc.BenchmarkService_StreamingCallClient, bf.MaxConcurrentCalls) md := metadata.Pairs(benchmark.UnconstrainedStreamingHeader, "1") ctx := metadata.NewOutgoingContext(context.Background(), md) for i := 0; i < bf.MaxConcurrentCalls; i++ { @@ -428,13 +430,13 @@ func setupUnconstrainedStream(bf stats.Features) ([]testpb.BenchmarkService_Stre // Makes a UnaryCall gRPC request using the given BenchmarkServiceClient and // request and response sizes. -func unaryCaller(client testpb.BenchmarkServiceClient, reqSize, respSize int) { +func unaryCaller(client testgrpc.BenchmarkServiceClient, reqSize, respSize int) { if err := bm.DoUnaryCall(client, reqSize, respSize); err != nil { logger.Fatalf("DoUnaryCall failed: %v", err) } } -func streamCaller(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) { +func streamCaller(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, respSize int) { if err := bm.DoStreamingRoundTrip(stream, reqSize, respSize); err != nil { logger.Fatalf("DoStreamingRoundTrip failed: %v", err) } diff --git a/benchmark/benchmark.go b/benchmark/benchmark.go index 92fbeb888..a8ae40fa6 100644 --- a/benchmark/benchmark.go +++ b/benchmark/benchmark.go @@ -31,9 +31,11 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) var logger = grpclog.Component("benchmark") @@ -61,7 +63,7 @@ func NewPayload(t testpb.PayloadType, size int) *testpb.Payload { } type testServer struct { - testpb.UnimplementedBenchmarkServiceServer + testgrpc.UnimplementedBenchmarkServiceServer } func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { @@ -75,7 +77,7 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (* // of ping-pong. const UnconstrainedStreamingHeader = "unconstrained-streaming" -func (s *testServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error { +func (s *testServer) StreamingCall(stream testgrpc.BenchmarkService_StreamingCallServer) error { if md, ok := metadata.FromIncomingContext(stream.Context()); ok && len(md[UnconstrainedStreamingHeader]) != 0 { return s.UnconstrainedStreamingCall(stream) } @@ -100,7 +102,7 @@ func (s *testServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallS } } -func (s *testServer) UnconstrainedStreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error { +func (s *testServer) UnconstrainedStreamingCall(stream testgrpc.BenchmarkService_StreamingCallServer) error { in := new(testpb.SimpleRequest) // Receive a message to learn response type and size. err := stream.RecvMsg(in) @@ -151,7 +153,7 @@ func (s *testServer) UnconstrainedStreamingCall(stream testpb.BenchmarkService_S // byteBufServer is a gRPC server that sends and receives byte buffer. // The purpose is to benchmark the gRPC performance without protobuf serialization/deserialization overhead. type byteBufServer struct { - testpb.UnimplementedBenchmarkServiceServer + testgrpc.UnimplementedBenchmarkServiceServer respSize int32 } @@ -161,7 +163,7 @@ func (s *byteBufServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) return &testpb.SimpleResponse{}, nil } -func (s *byteBufServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error { +func (s *byteBufServer) StreamingCall(stream testgrpc.BenchmarkService_StreamingCallServer) error { for { var in []byte err := stream.(grpc.ServerStream).RecvMsg(&in) @@ -201,13 +203,13 @@ func StartServer(info ServerInfo, opts ...grpc.ServerOption) func() { s := grpc.NewServer(opts...) switch info.Type { case "protobuf": - testpb.RegisterBenchmarkServiceServer(s, &testServer{}) + testgrpc.RegisterBenchmarkServiceServer(s, &testServer{}) case "bytebuf": respSize, ok := info.Metadata.(int32) if !ok { logger.Fatalf("failed to StartServer, invalid metadata: %v, for Type: %v", info.Metadata, info.Type) } - testpb.RegisterBenchmarkServiceServer(s, &byteBufServer{respSize: respSize}) + testgrpc.RegisterBenchmarkServiceServer(s, &byteBufServer{respSize: respSize}) default: logger.Fatalf("failed to StartServer, unknown Type: %v", info.Type) } @@ -218,7 +220,7 @@ func StartServer(info ServerInfo, opts ...grpc.ServerOption) func() { } // DoUnaryCall performs an unary RPC with given stub and request and response sizes. -func DoUnaryCall(tc testpb.BenchmarkServiceClient, reqSize, respSize int) error { +func DoUnaryCall(tc testgrpc.BenchmarkServiceClient, reqSize, respSize int) error { pl := NewPayload(testpb.PayloadType_COMPRESSABLE, reqSize) req := &testpb.SimpleRequest{ ResponseType: pl.Type, @@ -232,7 +234,7 @@ func DoUnaryCall(tc testpb.BenchmarkServiceClient, reqSize, respSize int) error } // DoStreamingRoundTrip performs a round trip for a single streaming rpc. -func DoStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error { +func DoStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, respSize int) error { pl := NewPayload(testpb.PayloadType_COMPRESSABLE, reqSize) req := &testpb.SimpleRequest{ ResponseType: pl.Type, @@ -253,7 +255,7 @@ func DoStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, re } // DoByteBufStreamingRoundTrip performs a round trip for a single streaming rpc, using a custom codec for byte buffer. -func DoByteBufStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error { +func DoByteBufStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, respSize int) error { out := make([]byte, reqSize) if err := stream.(grpc.ClientStream).SendMsg(&out); err != nil { return fmt.Errorf("/BenchmarkService/StreamingCall.(ClientStream).SendMsg(_) = %v, want ", err) diff --git a/benchmark/client/main.go b/benchmark/client/main.go index c74434846..caf2db70a 100644 --- a/benchmark/client/main.go +++ b/benchmark/client/main.go @@ -53,6 +53,8 @@ import ( "google.golang.org/grpc/benchmark/stats" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/internal/syscall" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" testpb "google.golang.org/grpc/interop/grpc_testing" ) @@ -164,7 +166,7 @@ func runWithConn(cc *grpc.ClientConn, req *testpb.SimpleRequest, warmDeadline, e } func makeCaller(cc *grpc.ClientConn, req *testpb.SimpleRequest) func() { - client := testpb.NewBenchmarkServiceClient(cc) + client := testgrpc.NewBenchmarkServiceClient(cc) if *rpcType == "unary" { return func() { if _, err := client.UnaryCall(context.Background(), req); err != nil { diff --git a/benchmark/worker/benchmark_client.go b/benchmark/worker/benchmark_client.go index f760c7c36..43af38dc5 100644 --- a/benchmark/worker/benchmark_client.go +++ b/benchmark/worker/benchmark_client.go @@ -32,9 +32,11 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" "google.golang.org/grpc/internal/syscall" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/status" "google.golang.org/grpc/testdata" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) var caFile = flag.String("ca_file", "", "The file containing the CA root cert file") @@ -243,7 +245,7 @@ func startBenchmarkClient(config *testpb.ClientConfig) (*benchmarkClient, error) func (bc *benchmarkClient) doCloseLoopUnary(conns []*grpc.ClientConn, rpcCountPerConn int, reqSize int, respSize int) { for ic, conn := range conns { - client := testpb.NewBenchmarkServiceClient(conn) + client := testgrpc.NewBenchmarkServiceClient(conn) // For each connection, create rpcCountPerConn goroutines to do rpc. for j := 0; j < rpcCountPerConn; j++ { // Create histogram for each goroutine. @@ -285,7 +287,7 @@ func (bc *benchmarkClient) doCloseLoopUnary(conns []*grpc.ClientConn, rpcCountPe } func (bc *benchmarkClient) doCloseLoopStreaming(conns []*grpc.ClientConn, rpcCountPerConn int, reqSize int, respSize int, payloadType string) { - var doRPC func(testpb.BenchmarkService_StreamingCallClient, int, int) error + var doRPC func(testgrpc.BenchmarkService_StreamingCallClient, int, int) error if payloadType == "bytebuf" { doRPC = benchmark.DoByteBufStreamingRoundTrip } else { @@ -294,7 +296,7 @@ func (bc *benchmarkClient) doCloseLoopStreaming(conns []*grpc.ClientConn, rpcCou for ic, conn := range conns { // For each connection, create rpcCountPerConn goroutines to do rpc. for j := 0; j < rpcCountPerConn; j++ { - c := testpb.NewBenchmarkServiceClient(conn) + c := testgrpc.NewBenchmarkServiceClient(conn) stream, err := c.StreamingCall(context.Background()) if err != nil { logger.Fatalf("%v.StreamingCall(_) = _, %v", c, err) diff --git a/benchmark/worker/main.go b/benchmark/worker/main.go index 4ecf99723..901341f51 100644 --- a/benchmark/worker/main.go +++ b/benchmark/worker/main.go @@ -35,8 +35,10 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/status" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) var ( @@ -75,12 +77,12 @@ func (byteBufCodec) String() string { // workerServer implements WorkerService rpc handlers. // It can create benchmarkServer or benchmarkClient on demand. type workerServer struct { - testpb.UnimplementedWorkerServiceServer + testgrpc.UnimplementedWorkerServiceServer stop chan<- bool serverPort int } -func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) error { +func (s *workerServer) RunServer(stream testgrpc.WorkerService_RunServerServer) error { var bs *benchmarkServer defer func() { // Close benchmark server when stream ends. @@ -135,7 +137,7 @@ func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) er } } -func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) error { +func (s *workerServer) RunClient(stream testgrpc.WorkerService_RunClientServer) error { var bc *benchmarkClient defer func() { // Shut down benchmark client when stream ends. @@ -209,7 +211,7 @@ func main() { s := grpc.NewServer() stop := make(chan bool) - testpb.RegisterWorkerServiceServer(s, &workerServer{ + testgrpc.RegisterWorkerServiceServer(s, &workerServer{ stop: stop, serverPort: *serverPort, }) diff --git a/binarylog/binarylog_end2end_test.go b/binarylog/binarylog_end2end_test.go index e06ffec91..61eeb68ed 100644 --- a/binarylog/binarylog_end2end_test.go +++ b/binarylog/binarylog_end2end_test.go @@ -31,13 +31,15 @@ import ( "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/binarylog" - pb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" "google.golang.org/grpc/grpclog" iblog "google.golang.org/grpc/internal/binarylog" "google.golang.org/grpc/internal/grpctest" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + + pb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) var grpclogLogger = grpclog.Component("binarylog") @@ -126,7 +128,7 @@ func payloadToID(p *testpb.Payload) int32 { } type testServer struct { - testpb.UnimplementedTestServiceServer + testgrpc.UnimplementedTestServiceServer te *test } @@ -148,7 +150,7 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (* return &testpb.SimpleResponse{Payload: in.Payload}, nil } -func (s *testServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServer) error { +func (s *testServer) FullDuplexCall(stream testgrpc.TestService_FullDuplexCallServer) error { md, ok := metadata.FromIncomingContext(stream.Context()) if ok { if err := stream.SendHeader(md); err != nil { @@ -176,7 +178,7 @@ func (s *testServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServ } } -func (s *testServer) StreamingInputCall(stream testpb.TestService_StreamingInputCallServer) error { +func (s *testServer) StreamingInputCall(stream testgrpc.TestService_StreamingInputCallServer) error { md, ok := metadata.FromIncomingContext(stream.Context()) if ok { if err := stream.SendHeader(md); err != nil { @@ -200,7 +202,7 @@ func (s *testServer) StreamingInputCall(stream testpb.TestService_StreamingInput } } -func (s *testServer) StreamingOutputCall(in *testpb.StreamingOutputCallRequest, stream testpb.TestService_StreamingOutputCallServer) error { +func (s *testServer) StreamingOutputCall(in *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error { md, ok := metadata.FromIncomingContext(stream.Context()) if ok { if err := stream.SendHeader(md); err != nil { @@ -227,7 +229,7 @@ func (s *testServer) StreamingOutputCall(in *testpb.StreamingOutputCallRequest, type test struct { t *testing.T - testService testpb.TestServiceServer // nil means none + testService testgrpc.TestServiceServer // nil means none // srv and srvAddr are set once startServer is called. srv *grpc.Server srvAddr string // Server IP without port. @@ -282,7 +284,7 @@ func (lw *listenerWrapper) Accept() (net.Conn, error) { // startServer starts a gRPC server listening. Callers should defer a // call to te.tearDown to clean up. -func (te *test) startServer(ts testpb.TestServiceServer) { +func (te *test) startServer(ts testgrpc.TestServiceServer) { te.testService = ts lis, err := net.Listen("tcp", "localhost:0") @@ -298,7 +300,7 @@ func (te *test) startServer(ts testpb.TestServiceServer) { s := grpc.NewServer(opts...) te.srv = s if te.testService != nil { - testpb.RegisterTestServiceServer(s, te.testService) + testgrpc.RegisterTestServiceServer(s, te.testService) } go s.Serve(lis) @@ -343,7 +345,7 @@ func (te *test) doUnaryCall(c *rpcConfig) (*testpb.SimpleRequest, *testpb.Simple req *testpb.SimpleRequest err error ) - tc := testpb.NewTestServiceClient(te.clientConn()) + tc := testgrpc.NewTestServiceClient(te.clientConn()) if c.success { req = &testpb.SimpleRequest{Payload: idToPayload(errorID + 1)} } else { @@ -363,7 +365,7 @@ func (te *test) doFullDuplexCallRoundtrip(c *rpcConfig) ([]proto.Message, []prot resps []proto.Message err error ) - tc := testpb.NewTestServiceClient(te.clientConn()) + tc := testgrpc.NewTestServiceClient(te.clientConn()) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() ctx = metadata.NewOutgoingContext(ctx, testMetadata) @@ -412,7 +414,7 @@ func (te *test) doClientStreamCall(c *rpcConfig) ([]proto.Message, proto.Message resp *testpb.StreamingInputCallResponse err error ) - tc := testpb.NewTestServiceClient(te.clientConn()) + tc := testgrpc.NewTestServiceClient(te.clientConn()) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() ctx = metadata.NewOutgoingContext(ctx, testMetadata) @@ -445,7 +447,7 @@ func (te *test) doServerStreamCall(c *rpcConfig) (proto.Message, []proto.Message err error ) - tc := testpb.NewTestServiceClient(te.clientConn()) + tc := testgrpc.NewTestServiceClient(te.clientConn()) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() ctx = metadata.NewOutgoingContext(ctx, testMetadata) diff --git a/interop/alts/client/client.go b/interop/alts/client/client.go index 9fc0e3c15..aef601ff8 100644 --- a/interop/alts/client/client.go +++ b/interop/alts/client/client.go @@ -27,6 +27,8 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/grpclog" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" testpb "google.golang.org/grpc/interop/grpc_testing" ) @@ -51,7 +53,7 @@ func main() { logger.Fatalf("gRPC Client: failed to dial the server at %v: %v", *serverAddr, err) } defer conn.Close() - grpcClient := testpb.NewTestServiceClient(conn) + grpcClient := testgrpc.NewTestServiceClient(conn) // Call the EmptyCall API. ctx := context.Background() diff --git a/interop/alts/server/server.go b/interop/alts/server/server.go index 0d0f375a0..9db675025 100644 --- a/interop/alts/server/server.go +++ b/interop/alts/server/server.go @@ -29,8 +29,9 @@ import ( "google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/interop" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/tap" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" ) const ( @@ -64,7 +65,7 @@ func main() { } altsTC := alts.NewServerCreds(opts) grpcServer := grpc.NewServer(grpc.Creds(altsTC), grpc.InTapHandle(authz)) - testpb.RegisterTestServiceServer(grpcServer, interop.NewTestServer()) + testgrpc.RegisterTestServiceServer(grpcServer, interop.NewTestServer()) grpcServer.Serve(lis) } diff --git a/interop/client/client.go b/interop/client/client.go index 2d7823062..8854ed2d7 100644 --- a/interop/client/client.go +++ b/interop/client/client.go @@ -32,9 +32,10 @@ import ( "google.golang.org/grpc/credentials/oauth" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/interop" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/resolver" "google.golang.org/grpc/testdata" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" ) const ( @@ -188,7 +189,7 @@ func main() { logger.Fatalf("Fail to dial: %v", err) } defer conn.Close() - tc := testpb.NewTestServiceClient(conn) + tc := testgrpc.NewTestServiceClient(conn) switch *testCase { case "empty_unary": interop.DoEmptyUnaryCall(tc) @@ -272,7 +273,7 @@ func main() { interop.DoUnimplementedMethod(conn) logger.Infoln("UnimplementedMethod done") case "unimplemented_service": - interop.DoUnimplementedService(testpb.NewUnimplementedServiceClient(conn)) + interop.DoUnimplementedService(testgrpc.NewUnimplementedServiceClient(conn)) logger.Infoln("UnimplementedService done") case "pick_first_unary": interop.DoPickFirstUnary(tc) diff --git a/interop/grpclb_fallback/client.go b/interop/grpclb_fallback/client.go index 262d7458a..61b2fae69 100644 --- a/interop/grpclb_fallback/client.go +++ b/interop/grpclb_fallback/client.go @@ -37,6 +37,8 @@ import ( "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/credentials/google" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" testpb "google.golang.org/grpc/interop/grpc_testing" ) @@ -55,7 +57,7 @@ var ( errorLog = log.New(os.Stderr, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile) ) -func doRPCAndGetPath(client testpb.TestServiceClient, timeout time.Duration) testpb.GrpclbRouteType { +func doRPCAndGetPath(client testgrpc.TestServiceClient, timeout time.Duration) testpb.GrpclbRouteType { infoLog.Printf("doRPCAndGetPath timeout:%v\n", timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() @@ -128,7 +130,7 @@ func runCmd(command string) { } } -func waitForFallbackAndDoRPCs(client testpb.TestServiceClient, fallbackDeadline time.Time) { +func waitForFallbackAndDoRPCs(client testgrpc.TestServiceClient, fallbackDeadline time.Time) { fallbackRetryCount := 0 fellBack := false for time.Now().Before(fallbackDeadline) { @@ -160,7 +162,7 @@ func doFastFallbackBeforeStartup() { fallbackDeadline := time.Now().Add(5 * time.Second) conn := createTestConn() defer conn.Close() - client := testpb.NewTestServiceClient(conn) + client := testgrpc.NewTestServiceClient(conn) waitForFallbackAndDoRPCs(client, fallbackDeadline) } @@ -169,14 +171,14 @@ func doSlowFallbackBeforeStartup() { fallbackDeadline := time.Now().Add(20 * time.Second) conn := createTestConn() defer conn.Close() - client := testpb.NewTestServiceClient(conn) + client := testgrpc.NewTestServiceClient(conn) waitForFallbackAndDoRPCs(client, fallbackDeadline) } func doFastFallbackAfterStartup() { conn := createTestConn() defer conn.Close() - client := testpb.NewTestServiceClient(conn) + client := testgrpc.NewTestServiceClient(conn) if g := doRPCAndGetPath(client, 20*time.Second); g != testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_BACKEND { errorLog.Fatalf("Expected RPC to take grpclb route type BACKEND. Got: %v", g) } @@ -188,7 +190,7 @@ func doFastFallbackAfterStartup() { func doSlowFallbackAfterStartup() { conn := createTestConn() defer conn.Close() - client := testpb.NewTestServiceClient(conn) + client := testgrpc.NewTestServiceClient(conn) if g := doRPCAndGetPath(client, 20*time.Second); g != testpb.GrpclbRouteType_GRPCLB_ROUTE_TYPE_BACKEND { errorLog.Fatalf("Expected RPC to take grpclb route type BACKEND. Got: %v", g) } diff --git a/interop/http2/negative_http2_client.go b/interop/http2/negative_http2_client.go index 8ead7f49c..9ed34f757 100644 --- a/interop/http2/negative_http2_client.go +++ b/interop/http2/negative_http2_client.go @@ -35,8 +35,10 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/interop" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/status" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) var ( @@ -66,7 +68,7 @@ func largeSimpleRequest() *testpb.SimpleRequest { } // sends two unary calls. The server asserts that the calls use different connections. -func goaway(tc testpb.TestServiceClient) { +func goaway(tc testgrpc.TestServiceClient) { interop.DoLargeUnaryCall(tc) // sleep to ensure that the client has time to recv the GOAWAY. // TODO(ncteisen): make this less hacky. @@ -74,7 +76,7 @@ func goaway(tc testpb.TestServiceClient) { interop.DoLargeUnaryCall(tc) } -func rstAfterHeader(tc testpb.TestServiceClient) { +func rstAfterHeader(tc testgrpc.TestServiceClient) { req := largeSimpleRequest() reply, err := tc.UnaryCall(context.Background(), req) if reply != nil { @@ -85,7 +87,7 @@ func rstAfterHeader(tc testpb.TestServiceClient) { } } -func rstDuringData(tc testpb.TestServiceClient) { +func rstDuringData(tc testgrpc.TestServiceClient) { req := largeSimpleRequest() reply, err := tc.UnaryCall(context.Background(), req) if reply != nil { @@ -96,7 +98,7 @@ func rstDuringData(tc testpb.TestServiceClient) { } } -func rstAfterData(tc testpb.TestServiceClient) { +func rstAfterData(tc testgrpc.TestServiceClient) { req := largeSimpleRequest() reply, err := tc.UnaryCall(context.Background(), req) if reply != nil { @@ -107,12 +109,12 @@ func rstAfterData(tc testpb.TestServiceClient) { } } -func ping(tc testpb.TestServiceClient) { +func ping(tc testgrpc.TestServiceClient) { // The server will assert that every ping it sends was ACK-ed by the client. interop.DoLargeUnaryCall(tc) } -func maxStreams(tc testpb.TestServiceClient) { +func maxStreams(tc testgrpc.TestServiceClient) { interop.DoLargeUnaryCall(tc) var wg sync.WaitGroup for i := 0; i < 15; i++ { @@ -135,7 +137,7 @@ func main() { logger.Fatalf("Fail to dial: %v", err) } defer conn.Close() - tc := testpb.NewTestServiceClient(conn) + tc := testgrpc.NewTestServiceClient(conn) switch *testCase { case "goaway": goaway(tc) diff --git a/interop/server/server.go b/interop/server/server.go index c70e450bb..16360abe9 100644 --- a/interop/server/server.go +++ b/interop/server/server.go @@ -29,8 +29,9 @@ import ( "google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/interop" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/testdata" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" ) var ( @@ -76,6 +77,6 @@ func main() { opts = append(opts, grpc.Creds(altsTC)) } server := grpc.NewServer(opts...) - testpb.RegisterTestServiceServer(server, interop.NewTestServer()) + testgrpc.RegisterTestServiceServer(server, interop.NewTestServer()) server.Serve(lis) } diff --git a/interop/test_utils.go b/interop/test_utils.go index 78f937a83..cbcbcc4da 100644 --- a/interop/test_utils.go +++ b/interop/test_utils.go @@ -33,9 +33,11 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) var ( @@ -67,7 +69,7 @@ func ClientNewPayload(t testpb.PayloadType, size int) *testpb.Payload { } // DoEmptyUnaryCall performs a unary RPC with empty request and response messages. -func DoEmptyUnaryCall(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoEmptyUnaryCall(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { reply, err := tc.EmptyCall(context.Background(), &testpb.Empty{}, args...) if err != nil { logger.Fatal("/TestService/EmptyCall RPC failed: ", err) @@ -78,7 +80,7 @@ func DoEmptyUnaryCall(tc testpb.TestServiceClient, args ...grpc.CallOption) { } // DoLargeUnaryCall performs a unary RPC with large payload in the request and response. -func DoLargeUnaryCall(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoLargeUnaryCall(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) req := &testpb.SimpleRequest{ ResponseType: testpb.PayloadType_COMPRESSABLE, @@ -97,7 +99,7 @@ func DoLargeUnaryCall(tc testpb.TestServiceClient, args ...grpc.CallOption) { } // DoClientStreaming performs a client streaming RPC. -func DoClientStreaming(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoClientStreaming(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { stream, err := tc.StreamingInputCall(context.Background(), args...) if err != nil { logger.Fatalf("%v.StreamingInputCall(_) = _, %v", tc, err) @@ -123,7 +125,7 @@ func DoClientStreaming(tc testpb.TestServiceClient, args ...grpc.CallOption) { } // DoServerStreaming performs a server streaming RPC. -func DoServerStreaming(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoServerStreaming(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { respParam := make([]*testpb.ResponseParameters, len(respSizes)) for i, s := range respSizes { respParam[i] = &testpb.ResponseParameters{ @@ -167,7 +169,7 @@ func DoServerStreaming(tc testpb.TestServiceClient, args ...grpc.CallOption) { } // DoPingPong performs ping-pong style bi-directional streaming RPC. -func DoPingPong(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoPingPong(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { stream, err := tc.FullDuplexCall(context.Background(), args...) if err != nil { logger.Fatalf("%v.FullDuplexCall(_) = _, %v", tc, err) @@ -211,7 +213,7 @@ func DoPingPong(tc testpb.TestServiceClient, args ...grpc.CallOption) { } // DoEmptyStream sets up a bi-directional streaming with zero message. -func DoEmptyStream(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoEmptyStream(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { stream, err := tc.FullDuplexCall(context.Background(), args...) if err != nil { logger.Fatalf("%v.FullDuplexCall(_) = _, %v", tc, err) @@ -225,7 +227,7 @@ func DoEmptyStream(tc testpb.TestServiceClient, args ...grpc.CallOption) { } // DoTimeoutOnSleepingServer performs an RPC on a sleep server which causes RPC timeout. -func DoTimeoutOnSleepingServer(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoTimeoutOnSleepingServer(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Millisecond) defer cancel() stream, err := tc.FullDuplexCall(ctx, args...) @@ -249,7 +251,7 @@ func DoTimeoutOnSleepingServer(tc testpb.TestServiceClient, args ...grpc.CallOpt } // DoComputeEngineCreds performs a unary RPC with compute engine auth. -func DoComputeEngineCreds(tc testpb.TestServiceClient, serviceAccount, oauthScope string) { +func DoComputeEngineCreds(tc testgrpc.TestServiceClient, serviceAccount, oauthScope string) { pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) req := &testpb.SimpleRequest{ ResponseType: testpb.PayloadType_COMPRESSABLE, @@ -281,7 +283,7 @@ func getServiceAccountJSONKey(keyFile string) []byte { } // DoServiceAccountCreds performs a unary RPC with service account auth. -func DoServiceAccountCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oauthScope string) { +func DoServiceAccountCreds(tc testgrpc.TestServiceClient, serviceAccountKeyFile, oauthScope string) { pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) req := &testpb.SimpleRequest{ ResponseType: testpb.PayloadType_COMPRESSABLE, @@ -306,7 +308,7 @@ func DoServiceAccountCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, o } // DoJWTTokenCreds performs a unary RPC with JWT token auth. -func DoJWTTokenCreds(tc testpb.TestServiceClient, serviceAccountKeyFile string) { +func DoJWTTokenCreds(tc testgrpc.TestServiceClient, serviceAccountKeyFile string) { pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) req := &testpb.SimpleRequest{ ResponseType: testpb.PayloadType_COMPRESSABLE, @@ -340,7 +342,7 @@ func GetToken(serviceAccountKeyFile string, oauthScope string) *oauth2.Token { } // DoOauth2TokenCreds performs a unary RPC with OAUTH2 token auth. -func DoOauth2TokenCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oauthScope string) { +func DoOauth2TokenCreds(tc testgrpc.TestServiceClient, serviceAccountKeyFile, oauthScope string) { pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) req := &testpb.SimpleRequest{ ResponseType: testpb.PayloadType_COMPRESSABLE, @@ -365,7 +367,7 @@ func DoOauth2TokenCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oaut } // DoPerRPCCreds performs a unary RPC with per RPC OAUTH2 token. -func DoPerRPCCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oauthScope string) { +func DoPerRPCCreds(tc testgrpc.TestServiceClient, serviceAccountKeyFile, oauthScope string) { jsonKey := getServiceAccountJSONKey(serviceAccountKeyFile) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) req := &testpb.SimpleRequest{ @@ -393,7 +395,7 @@ func DoPerRPCCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oauthScop } // DoGoogleDefaultCredentials performs an unary RPC with google default credentials -func DoGoogleDefaultCredentials(tc testpb.TestServiceClient, defaultServiceAccount string) { +func DoGoogleDefaultCredentials(tc testgrpc.TestServiceClient, defaultServiceAccount string) { pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) req := &testpb.SimpleRequest{ ResponseType: testpb.PayloadType_COMPRESSABLE, @@ -412,7 +414,7 @@ func DoGoogleDefaultCredentials(tc testpb.TestServiceClient, defaultServiceAccou } // DoComputeEngineChannelCredentials performs an unary RPC with compute engine channel credentials -func DoComputeEngineChannelCredentials(tc testpb.TestServiceClient, defaultServiceAccount string) { +func DoComputeEngineChannelCredentials(tc testgrpc.TestServiceClient, defaultServiceAccount string) { pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) req := &testpb.SimpleRequest{ ResponseType: testpb.PayloadType_COMPRESSABLE, @@ -436,7 +438,7 @@ var testMetadata = metadata.MD{ } // DoCancelAfterBegin cancels the RPC after metadata has been sent but before payloads are sent. -func DoCancelAfterBegin(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoCancelAfterBegin(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { ctx, cancel := context.WithCancel(metadata.NewOutgoingContext(context.Background(), testMetadata)) stream, err := tc.StreamingInputCall(ctx, args...) if err != nil { @@ -450,7 +452,7 @@ func DoCancelAfterBegin(tc testpb.TestServiceClient, args ...grpc.CallOption) { } // DoCancelAfterFirstResponse cancels the RPC after receiving the first message from the server. -func DoCancelAfterFirstResponse(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoCancelAfterFirstResponse(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { ctx, cancel := context.WithCancel(context.Background()) stream, err := tc.FullDuplexCall(ctx, args...) if err != nil { @@ -504,7 +506,7 @@ func validateMetadata(header, trailer metadata.MD) { } // DoCustomMetadata checks that metadata is echoed back to the client. -func DoCustomMetadata(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoCustomMetadata(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { // Testing with UnaryCall. pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, 1) req := &testpb.SimpleRequest{ @@ -566,7 +568,7 @@ func DoCustomMetadata(tc testpb.TestServiceClient, args ...grpc.CallOption) { } // DoStatusCodeAndMessage checks that the status code is propagated back to the client. -func DoStatusCodeAndMessage(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoStatusCodeAndMessage(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { var code int32 = 2 msg := "test status message" expectedErr := status.Error(codes.Code(code), msg) @@ -602,7 +604,7 @@ func DoStatusCodeAndMessage(tc testpb.TestServiceClient, args ...grpc.CallOption // DoSpecialStatusMessage verifies Unicode and whitespace is correctly processed // in status message. -func DoSpecialStatusMessage(tc testpb.TestServiceClient, args ...grpc.CallOption) { +func DoSpecialStatusMessage(tc testgrpc.TestServiceClient, args ...grpc.CallOption) { const ( code int32 = 2 msg string = "\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n" @@ -622,7 +624,7 @@ func DoSpecialStatusMessage(tc testpb.TestServiceClient, args ...grpc.CallOption } // DoUnimplementedService attempts to call a method from an unimplemented service. -func DoUnimplementedService(tc testpb.UnimplementedServiceClient) { +func DoUnimplementedService(tc testgrpc.UnimplementedServiceClient) { _, err := tc.UnimplementedCall(context.Background(), &testpb.Empty{}) if status.Code(err) != codes.Unimplemented { logger.Fatalf("%v.UnimplementedCall() = _, %v, want _, %v", tc, status.Code(err), codes.Unimplemented) @@ -639,7 +641,7 @@ func DoUnimplementedMethod(cc *grpc.ClientConn) { // DoPickFirstUnary runs multiple RPCs (rpcCount) and checks that all requests // are sent to the same backend. -func DoPickFirstUnary(tc testpb.TestServiceClient) { +func DoPickFirstUnary(tc testgrpc.TestServiceClient) { const rpcCount = 100 pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, 1) @@ -672,11 +674,11 @@ func DoPickFirstUnary(tc testpb.TestServiceClient) { } type testServer struct { - testpb.UnimplementedTestServiceServer + testgrpc.UnimplementedTestServiceServer } // NewTestServer creates a test server for test service. -func NewTestServer() testpb.TestServiceServer { +func NewTestServer() testgrpc.TestServiceServer { return &testServer{} } @@ -724,7 +726,7 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (* }, nil } -func (s *testServer) StreamingOutputCall(args *testpb.StreamingOutputCallRequest, stream testpb.TestService_StreamingOutputCallServer) error { +func (s *testServer) StreamingOutputCall(args *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error { cs := args.GetResponseParameters() for _, c := range cs { if us := c.GetIntervalUs(); us > 0 { @@ -743,7 +745,7 @@ func (s *testServer) StreamingOutputCall(args *testpb.StreamingOutputCallRequest return nil } -func (s *testServer) StreamingInputCall(stream testpb.TestService_StreamingInputCallServer) error { +func (s *testServer) StreamingInputCall(stream testgrpc.TestService_StreamingInputCallServer) error { var sum int for { in, err := stream.Recv() @@ -760,7 +762,7 @@ func (s *testServer) StreamingInputCall(stream testpb.TestService_StreamingInput } } -func (s *testServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServer) error { +func (s *testServer) FullDuplexCall(stream testgrpc.TestService_FullDuplexCallServer) error { if md, ok := metadata.FromIncomingContext(stream.Context()); ok { if initialMetadata, ok := md[initialMetadataKey]; ok { header := metadata.Pairs(initialMetadataKey, initialMetadata[0]) @@ -802,7 +804,7 @@ func (s *testServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServ } } -func (s *testServer) HalfDuplexCall(stream testpb.TestService_HalfDuplexCallServer) error { +func (s *testServer) HalfDuplexCall(stream testgrpc.TestService_HalfDuplexCallServer) error { var msgBuf []*testpb.StreamingOutputCallRequest for { in, err := stream.Recv() diff --git a/interop/xds/client/client.go b/interop/xds/client/client.go index 7afdb20e8..0b8e9dee3 100644 --- a/interop/xds/client/client.go +++ b/interop/xds/client/client.go @@ -32,10 +32,12 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/grpclog" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" "google.golang.org/grpc/peer" _ "google.golang.org/grpc/xds" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) func init() { @@ -163,7 +165,7 @@ var ( ) type statsService struct { - testpb.UnimplementedLoadBalancerStatsServiceServer + testgrpc.UnimplementedLoadBalancerStatsServiceServer } func hasRPCSucceeded() bool { @@ -235,7 +237,7 @@ func (s *statsService) GetClientAccumulatedStats(ctx context.Context, in *testpb } type configureService struct { - testpb.UnimplementedXdsUpdateClientConfigureServiceServer + testgrpc.UnimplementedXdsUpdateClientConfigureServiceServer } func (s *configureService) Configure(ctx context.Context, in *testpb.ClientConfigureRequest) (*testpb.ClientConfigureResponse, error) { @@ -334,25 +336,25 @@ func main() { } s := grpc.NewServer() defer s.Stop() - testpb.RegisterLoadBalancerStatsServiceServer(s, &statsService{}) - testpb.RegisterXdsUpdateClientConfigureServiceServer(s, &configureService{}) + testgrpc.RegisterLoadBalancerStatsServiceServer(s, &statsService{}) + testgrpc.RegisterXdsUpdateClientConfigureServiceServer(s, &configureService{}) go s.Serve(lis) - clients := make([]testpb.TestServiceClient, *numChannels) + clients := make([]testgrpc.TestServiceClient, *numChannels) for i := 0; i < *numChannels; i++ { conn, err := grpc.DialContext(context.Background(), *server, grpc.WithInsecure()) if err != nil { logger.Fatalf("Fail to dial: %v", err) } defer conn.Close() - clients[i] = testpb.NewTestServiceClient(conn) + clients[i] = testgrpc.NewTestServiceClient(conn) } ticker := time.NewTicker(time.Second / time.Duration(*qps**numChannels)) defer ticker.Stop() sendRPCs(clients, ticker) } -func makeOneRPC(c testpb.TestServiceClient, cfg *rpcConfig) (*peer.Peer, *rpcInfo, error) { +func makeOneRPC(c testgrpc.TestServiceClient, cfg *rpcConfig) (*peer.Peer, *rpcInfo, error) { ctx, cancel := context.WithTimeout(context.Background(), *rpcTimeout) defer cancel() @@ -392,7 +394,7 @@ func makeOneRPC(c testpb.TestServiceClient, cfg *rpcConfig) (*peer.Peer, *rpcInf return &p, &info, err } -func sendRPCs(clients []testpb.TestServiceClient, ticker *time.Ticker) { +func sendRPCs(clients []testgrpc.TestServiceClient, ticker *time.Ticker) { var i int for range ticker.C { // Get and increment request ID, and save a list of watchers that are diff --git a/interop/xds/server/server.go b/interop/xds/server/server.go index 45b844882..4989eb728 100644 --- a/interop/xds/server/server.go +++ b/interop/xds/server/server.go @@ -29,8 +29,10 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/grpclog" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) var ( @@ -50,7 +52,7 @@ func getHostname() string { } type server struct { - testpb.UnimplementedTestServiceServer + testgrpc.UnimplementedTestServiceServer } func (s *server) EmptyCall(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) { @@ -71,6 +73,6 @@ func main() { logger.Fatalf("failed to listen: %v", err) } s := grpc.NewServer() - testpb.RegisterTestServiceServer(s, &server{}) + testgrpc.RegisterTestServiceServer(s, &server{}) s.Serve(lis) } diff --git a/stats/stats_test.go b/stats/stats_test.go index aac8166f7..306f2f6b8 100644 --- a/stats/stats_test.go +++ b/stats/stats_test.go @@ -31,10 +31,12 @@ import ( "github.com/golang/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/internal/grpctest" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/metadata" "google.golang.org/grpc/stats" "google.golang.org/grpc/status" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + testpb "google.golang.org/grpc/interop/grpc_testing" ) const defaultTestTimeout = 10 * time.Second @@ -87,7 +89,7 @@ func payloadToID(p *testpb.Payload) int32 { } type testServer struct { - testpb.UnimplementedTestServiceServer + testgrpc.UnimplementedTestServiceServer } func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { @@ -105,7 +107,7 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (* return &testpb.SimpleResponse{Payload: in.Payload}, nil } -func (s *testServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServer) error { +func (s *testServer) FullDuplexCall(stream testgrpc.TestService_FullDuplexCallServer) error { if err := stream.SendHeader(testHeaderMetadata); err != nil { return status.Errorf(status.Code(err), "%v.SendHeader(%v) = %v, want %v", stream, testHeaderMetadata, err, nil) } @@ -130,7 +132,7 @@ func (s *testServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServ } } -func (s *testServer) StreamingInputCall(stream testpb.TestService_StreamingInputCallServer) error { +func (s *testServer) StreamingInputCall(stream testgrpc.TestService_StreamingInputCallServer) error { if err := stream.SendHeader(testHeaderMetadata); err != nil { return status.Errorf(status.Code(err), "%v.SendHeader(%v) = %v, want %v", stream, testHeaderMetadata, err, nil) } @@ -151,7 +153,7 @@ func (s *testServer) StreamingInputCall(stream testpb.TestService_StreamingInput } } -func (s *testServer) StreamingOutputCall(in *testpb.StreamingOutputCallRequest, stream testpb.TestService_StreamingOutputCallServer) error { +func (s *testServer) StreamingOutputCall(in *testpb.StreamingOutputCallRequest, stream testgrpc.TestService_StreamingOutputCallServer) error { if err := stream.SendHeader(testHeaderMetadata); err != nil { return status.Errorf(status.Code(err), "%v.SendHeader(%v) = %v, want %v", stream, testHeaderMetadata, err, nil) } @@ -178,7 +180,7 @@ type test struct { clientStatsHandler stats.Handler serverStatsHandler stats.Handler - testServer testpb.TestServiceServer // nil means none + testServer testgrpc.TestServiceServer // nil means none // srv and srvAddr are set once startServer is called. srv *grpc.Server srvAddr string @@ -213,7 +215,7 @@ func newTest(t *testing.T, tc *testConfig, ch stats.Handler, sh stats.Handler) * // startServer starts a gRPC server listening. Callers should defer a // call to te.tearDown to clean up. -func (te *test) startServer(ts testpb.TestServiceServer) { +func (te *test) startServer(ts testgrpc.TestServiceServer) { te.testServer = ts lis, err := net.Listen("tcp", "localhost:0") if err != nil { @@ -232,7 +234,7 @@ func (te *test) startServer(ts testpb.TestServiceServer) { s := grpc.NewServer(opts...) te.srv = s if te.testServer != nil { - testpb.RegisterTestServiceServer(s, te.testServer) + testgrpc.RegisterTestServiceServer(s, te.testServer) } go s.Serve(lis) @@ -288,7 +290,7 @@ func (te *test) doUnaryCall(c *rpcConfig) (*testpb.SimpleRequest, *testpb.Simple req *testpb.SimpleRequest err error ) - tc := testpb.NewTestServiceClient(te.clientConn()) + tc := testgrpc.NewTestServiceClient(te.clientConn()) if c.success { req = &testpb.SimpleRequest{Payload: idToPayload(errorID + 1)} } else { @@ -307,7 +309,7 @@ func (te *test) doFullDuplexCallRoundtrip(c *rpcConfig) ([]proto.Message, []prot resps []proto.Message err error ) - tc := testpb.NewTestServiceClient(te.clientConn()) + tc := testgrpc.NewTestServiceClient(te.clientConn()) tCtx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) defer cancel() stream, err := tc.FullDuplexCall(metadata.NewOutgoingContext(tCtx, testMetadata), grpc.WaitForReady(!c.failfast)) @@ -348,7 +350,7 @@ func (te *test) doClientStreamCall(c *rpcConfig) ([]proto.Message, *testpb.Strea resp *testpb.StreamingInputCallResponse err error ) - tc := testpb.NewTestServiceClient(te.clientConn()) + tc := testgrpc.NewTestServiceClient(te.clientConn()) tCtx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) defer cancel() stream, err := tc.StreamingInputCall(metadata.NewOutgoingContext(tCtx, testMetadata), grpc.WaitForReady(!c.failfast)) @@ -379,7 +381,7 @@ func (te *test) doServerStreamCall(c *rpcConfig) (*testpb.StreamingOutputCallReq err error ) - tc := testpb.NewTestServiceClient(te.clientConn()) + tc := testgrpc.NewTestServiceClient(te.clientConn()) var startID int32 if !c.success { diff --git a/stress/client/main.go b/stress/client/main.go index c5bfffa4e..37e2a38f4 100644 --- a/stress/client/main.go +++ b/stress/client/main.go @@ -35,10 +35,11 @@ import ( "google.golang.org/grpc/credentials" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/interop" - testpb "google.golang.org/grpc/interop/grpc_testing" "google.golang.org/grpc/status" - metricspb "google.golang.org/grpc/stress/grpc_testing" "google.golang.org/grpc/testdata" + + testgrpc "google.golang.org/grpc/interop/grpc_testing" + metricspb "google.golang.org/grpc/stress/grpc_testing" ) var ( @@ -209,7 +210,7 @@ func startServer(server *server, port int) { // performRPCs uses weightedRandomTestSelector to select test case and runs the tests. func performRPCs(gauge *gauge, conn *grpc.ClientConn, selector *weightedRandomTestSelector, stop <-chan bool) { - client := testpb.NewTestServiceClient(conn) + client := testgrpc.NewTestServiceClient(conn) var numCalls int64 startTime := time.Now() for {