cleanup: use different import alias for services than messages (#4148)

This commit is contained in:
Doug Fawley 2021-01-12 12:23:41 -08:00 committed by GitHub
parent 4cf4a98505
commit d3ae124a07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 149 additions and 119 deletions

View File

@ -65,10 +65,12 @@ import (
"google.golang.org/grpc/benchmark/stats" "google.golang.org/grpc/benchmark/stats"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/internal/channelz" "google.golang.org/grpc/internal/channelz"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/test/bufconn" "google.golang.org/grpc/test/bufconn"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "google.golang.org/grpc/interop/grpc_testing"
) )
var ( 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 // service. The client is configured using the different options in the passed
// 'bf'. Also returns a cleanup function to close the client and release // 'bf'. Also returns a cleanup function to close the client and release
// resources. // 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} nw := &latency.Network{Kbps: bf.Kbps, Latency: bf.Latency, MTU: bf.MTU}
opts := []grpc.DialOption{} opts := []grpc.DialOption{}
sopts := []grpc.ServerOption{} sopts := []grpc.ServerOption{}
@ -327,7 +329,7 @@ func makeClient(bf stats.Features) (testpb.BenchmarkServiceClient, func()) {
lis = nw.Listener(lis) lis = nw.Listener(lis)
stopper := bm.StartServer(bm.ServerInfo{Type: "protobuf", Listener: lis}, sopts...) stopper := bm.StartServer(bm.ServerInfo{Type: "protobuf", Listener: lis}, sopts...)
conn := bm.NewClientConn("" /* target not used */, opts...) conn := bm.NewClientConn("" /* target not used */, opts...)
return testpb.NewBenchmarkServiceClient(conn), func() { return testgrpc.NewBenchmarkServiceClient(conn), func() {
conn.Close() conn.Close()
stopper() stopper()
} }
@ -351,7 +353,7 @@ func makeFuncUnary(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) {
func makeFuncStream(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) { func makeFuncStream(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) {
tc, cleanup := makeClient(bf) 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++ { for i := 0; i < bf.MaxConcurrentCalls; i++ {
stream, err := tc.StreamingCall(context.Background()) stream, err := tc.StreamingCall(context.Background())
if err != nil { if err != nil {
@ -402,10 +404,10 @@ func makeFuncUnconstrainedStream(bf stats.Features) (rpcSendFunc, rpcRecvFunc, r
}, cleanup }, 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) tc, cleanup := makeClient(bf)
streams := make([]testpb.BenchmarkService_StreamingCallClient, bf.MaxConcurrentCalls) streams := make([]testgrpc.BenchmarkService_StreamingCallClient, bf.MaxConcurrentCalls)
md := metadata.Pairs(benchmark.UnconstrainedStreamingHeader, "1") md := metadata.Pairs(benchmark.UnconstrainedStreamingHeader, "1")
ctx := metadata.NewOutgoingContext(context.Background(), md) ctx := metadata.NewOutgoingContext(context.Background(), md)
for i := 0; i < bf.MaxConcurrentCalls; i++ { 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 // Makes a UnaryCall gRPC request using the given BenchmarkServiceClient and
// request and response sizes. // 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 { if err := bm.DoUnaryCall(client, reqSize, respSize); err != nil {
logger.Fatalf("DoUnaryCall failed: %v", err) 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 { if err := bm.DoStreamingRoundTrip(stream, reqSize, respSize); err != nil {
logger.Fatalf("DoStreamingRoundTrip failed: %v", err) logger.Fatalf("DoStreamingRoundTrip failed: %v", err)
} }

View File

@ -31,9 +31,11 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/status" "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") var logger = grpclog.Component("benchmark")
@ -61,7 +63,7 @@ func NewPayload(t testpb.PayloadType, size int) *testpb.Payload {
} }
type testServer struct { type testServer struct {
testpb.UnimplementedBenchmarkServiceServer testgrpc.UnimplementedBenchmarkServiceServer
} }
func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { 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. // of ping-pong.
const UnconstrainedStreamingHeader = "unconstrained-streaming" 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 { if md, ok := metadata.FromIncomingContext(stream.Context()); ok && len(md[UnconstrainedStreamingHeader]) != 0 {
return s.UnconstrainedStreamingCall(stream) 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) in := new(testpb.SimpleRequest)
// Receive a message to learn response type and size. // Receive a message to learn response type and size.
err := stream.RecvMsg(in) 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. // byteBufServer is a gRPC server that sends and receives byte buffer.
// The purpose is to benchmark the gRPC performance without protobuf serialization/deserialization overhead. // The purpose is to benchmark the gRPC performance without protobuf serialization/deserialization overhead.
type byteBufServer struct { type byteBufServer struct {
testpb.UnimplementedBenchmarkServiceServer testgrpc.UnimplementedBenchmarkServiceServer
respSize int32 respSize int32
} }
@ -161,7 +163,7 @@ func (s *byteBufServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest)
return &testpb.SimpleResponse{}, nil return &testpb.SimpleResponse{}, nil
} }
func (s *byteBufServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error { func (s *byteBufServer) StreamingCall(stream testgrpc.BenchmarkService_StreamingCallServer) error {
for { for {
var in []byte var in []byte
err := stream.(grpc.ServerStream).RecvMsg(&in) err := stream.(grpc.ServerStream).RecvMsg(&in)
@ -201,13 +203,13 @@ func StartServer(info ServerInfo, opts ...grpc.ServerOption) func() {
s := grpc.NewServer(opts...) s := grpc.NewServer(opts...)
switch info.Type { switch info.Type {
case "protobuf": case "protobuf":
testpb.RegisterBenchmarkServiceServer(s, &testServer{}) testgrpc.RegisterBenchmarkServiceServer(s, &testServer{})
case "bytebuf": case "bytebuf":
respSize, ok := info.Metadata.(int32) respSize, ok := info.Metadata.(int32)
if !ok { if !ok {
logger.Fatalf("failed to StartServer, invalid metadata: %v, for Type: %v", info.Metadata, info.Type) 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: default:
logger.Fatalf("failed to StartServer, unknown Type: %v", info.Type) 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. // 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) pl := NewPayload(testpb.PayloadType_COMPRESSABLE, reqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: pl.Type, 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. // 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) pl := NewPayload(testpb.PayloadType_COMPRESSABLE, reqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: pl.Type, 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. // 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) out := make([]byte, reqSize)
if err := stream.(grpc.ClientStream).SendMsg(&out); err != nil { if err := stream.(grpc.ClientStream).SendMsg(&out); err != nil {
return fmt.Errorf("/BenchmarkService/StreamingCall.(ClientStream).SendMsg(_) = %v, want <nil>", err) return fmt.Errorf("/BenchmarkService/StreamingCall.(ClientStream).SendMsg(_) = %v, want <nil>", err)

View File

@ -53,6 +53,8 @@ import (
"google.golang.org/grpc/benchmark/stats" "google.golang.org/grpc/benchmark/stats"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/internal/syscall" "google.golang.org/grpc/internal/syscall"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "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() { func makeCaller(cc *grpc.ClientConn, req *testpb.SimpleRequest) func() {
client := testpb.NewBenchmarkServiceClient(cc) client := testgrpc.NewBenchmarkServiceClient(cc)
if *rpcType == "unary" { if *rpcType == "unary" {
return func() { return func() {
if _, err := client.UnaryCall(context.Background(), req); err != nil { if _, err := client.UnaryCall(context.Background(), req); err != nil {

View File

@ -32,9 +32,11 @@ import (
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/internal/syscall" "google.golang.org/grpc/internal/syscall"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"google.golang.org/grpc/testdata" "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") 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) { func (bc *benchmarkClient) doCloseLoopUnary(conns []*grpc.ClientConn, rpcCountPerConn int, reqSize int, respSize int) {
for ic, conn := range conns { for ic, conn := range conns {
client := testpb.NewBenchmarkServiceClient(conn) client := testgrpc.NewBenchmarkServiceClient(conn)
// For each connection, create rpcCountPerConn goroutines to do rpc. // For each connection, create rpcCountPerConn goroutines to do rpc.
for j := 0; j < rpcCountPerConn; j++ { for j := 0; j < rpcCountPerConn; j++ {
// Create histogram for each goroutine. // 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) { 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" { if payloadType == "bytebuf" {
doRPC = benchmark.DoByteBufStreamingRoundTrip doRPC = benchmark.DoByteBufStreamingRoundTrip
} else { } else {
@ -294,7 +296,7 @@ func (bc *benchmarkClient) doCloseLoopStreaming(conns []*grpc.ClientConn, rpcCou
for ic, conn := range conns { for ic, conn := range conns {
// For each connection, create rpcCountPerConn goroutines to do rpc. // For each connection, create rpcCountPerConn goroutines to do rpc.
for j := 0; j < rpcCountPerConn; j++ { for j := 0; j < rpcCountPerConn; j++ {
c := testpb.NewBenchmarkServiceClient(conn) c := testgrpc.NewBenchmarkServiceClient(conn)
stream, err := c.StreamingCall(context.Background()) stream, err := c.StreamingCall(context.Background())
if err != nil { if err != nil {
logger.Fatalf("%v.StreamingCall(_) = _, %v", c, err) logger.Fatalf("%v.StreamingCall(_) = _, %v", c, err)

View File

@ -35,8 +35,10 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "google.golang.org/grpc/interop/grpc_testing"
) )
var ( var (
@ -75,12 +77,12 @@ func (byteBufCodec) String() string {
// workerServer implements WorkerService rpc handlers. // workerServer implements WorkerService rpc handlers.
// It can create benchmarkServer or benchmarkClient on demand. // It can create benchmarkServer or benchmarkClient on demand.
type workerServer struct { type workerServer struct {
testpb.UnimplementedWorkerServiceServer testgrpc.UnimplementedWorkerServiceServer
stop chan<- bool stop chan<- bool
serverPort int serverPort int
} }
func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) error { func (s *workerServer) RunServer(stream testgrpc.WorkerService_RunServerServer) error {
var bs *benchmarkServer var bs *benchmarkServer
defer func() { defer func() {
// Close benchmark server when stream ends. // 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 var bc *benchmarkClient
defer func() { defer func() {
// Shut down benchmark client when stream ends. // Shut down benchmark client when stream ends.
@ -209,7 +211,7 @@ func main() {
s := grpc.NewServer() s := grpc.NewServer()
stop := make(chan bool) stop := make(chan bool)
testpb.RegisterWorkerServiceServer(s, &workerServer{ testgrpc.RegisterWorkerServiceServer(s, &workerServer{
stop: stop, stop: stop,
serverPort: *serverPort, serverPort: *serverPort,
}) })

View File

@ -31,13 +31,15 @@ import (
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/binarylog" "google.golang.org/grpc/binarylog"
pb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
iblog "google.golang.org/grpc/internal/binarylog" iblog "google.golang.org/grpc/internal/binarylog"
"google.golang.org/grpc/internal/grpctest" "google.golang.org/grpc/internal/grpctest"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/status" "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") var grpclogLogger = grpclog.Component("binarylog")
@ -126,7 +128,7 @@ func payloadToID(p *testpb.Payload) int32 {
} }
type testServer struct { type testServer struct {
testpb.UnimplementedTestServiceServer testgrpc.UnimplementedTestServiceServer
te *test te *test
} }
@ -148,7 +150,7 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*
return &testpb.SimpleResponse{Payload: in.Payload}, nil 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()) md, ok := metadata.FromIncomingContext(stream.Context())
if ok { if ok {
if err := stream.SendHeader(md); err != nil { 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()) md, ok := metadata.FromIncomingContext(stream.Context())
if ok { if ok {
if err := stream.SendHeader(md); err != nil { 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()) md, ok := metadata.FromIncomingContext(stream.Context())
if ok { if ok {
if err := stream.SendHeader(md); err != nil { if err := stream.SendHeader(md); err != nil {
@ -227,7 +229,7 @@ func (s *testServer) StreamingOutputCall(in *testpb.StreamingOutputCallRequest,
type test struct { type test struct {
t *testing.T 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 and srvAddr are set once startServer is called.
srv *grpc.Server srv *grpc.Server
srvAddr string // Server IP without port. 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 // startServer starts a gRPC server listening. Callers should defer a
// call to te.tearDown to clean up. // call to te.tearDown to clean up.
func (te *test) startServer(ts testpb.TestServiceServer) { func (te *test) startServer(ts testgrpc.TestServiceServer) {
te.testService = ts te.testService = ts
lis, err := net.Listen("tcp", "localhost:0") lis, err := net.Listen("tcp", "localhost:0")
@ -298,7 +300,7 @@ func (te *test) startServer(ts testpb.TestServiceServer) {
s := grpc.NewServer(opts...) s := grpc.NewServer(opts...)
te.srv = s te.srv = s
if te.testService != nil { if te.testService != nil {
testpb.RegisterTestServiceServer(s, te.testService) testgrpc.RegisterTestServiceServer(s, te.testService)
} }
go s.Serve(lis) go s.Serve(lis)
@ -343,7 +345,7 @@ func (te *test) doUnaryCall(c *rpcConfig) (*testpb.SimpleRequest, *testpb.Simple
req *testpb.SimpleRequest req *testpb.SimpleRequest
err error err error
) )
tc := testpb.NewTestServiceClient(te.clientConn()) tc := testgrpc.NewTestServiceClient(te.clientConn())
if c.success { if c.success {
req = &testpb.SimpleRequest{Payload: idToPayload(errorID + 1)} req = &testpb.SimpleRequest{Payload: idToPayload(errorID + 1)}
} else { } else {
@ -363,7 +365,7 @@ func (te *test) doFullDuplexCallRoundtrip(c *rpcConfig) ([]proto.Message, []prot
resps []proto.Message resps []proto.Message
err error err error
) )
tc := testpb.NewTestServiceClient(te.clientConn()) tc := testgrpc.NewTestServiceClient(te.clientConn())
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
ctx = metadata.NewOutgoingContext(ctx, testMetadata) ctx = metadata.NewOutgoingContext(ctx, testMetadata)
@ -412,7 +414,7 @@ func (te *test) doClientStreamCall(c *rpcConfig) ([]proto.Message, proto.Message
resp *testpb.StreamingInputCallResponse resp *testpb.StreamingInputCallResponse
err error err error
) )
tc := testpb.NewTestServiceClient(te.clientConn()) tc := testgrpc.NewTestServiceClient(te.clientConn())
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
ctx = metadata.NewOutgoingContext(ctx, testMetadata) ctx = metadata.NewOutgoingContext(ctx, testMetadata)
@ -445,7 +447,7 @@ func (te *test) doServerStreamCall(c *rpcConfig) (proto.Message, []proto.Message
err error err error
) )
tc := testpb.NewTestServiceClient(te.clientConn()) tc := testgrpc.NewTestServiceClient(te.clientConn())
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
ctx = metadata.NewOutgoingContext(ctx, testMetadata) ctx = metadata.NewOutgoingContext(ctx, testMetadata)

View File

@ -27,6 +27,8 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/credentials/alts"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "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) logger.Fatalf("gRPC Client: failed to dial the server at %v: %v", *serverAddr, err)
} }
defer conn.Close() defer conn.Close()
grpcClient := testpb.NewTestServiceClient(conn) grpcClient := testgrpc.NewTestServiceClient(conn)
// Call the EmptyCall API. // Call the EmptyCall API.
ctx := context.Background() ctx := context.Background()

View File

@ -29,8 +29,9 @@ import (
"google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/credentials/alts"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/interop" "google.golang.org/grpc/interop"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/tap" "google.golang.org/grpc/tap"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
) )
const ( const (
@ -64,7 +65,7 @@ func main() {
} }
altsTC := alts.NewServerCreds(opts) altsTC := alts.NewServerCreds(opts)
grpcServer := grpc.NewServer(grpc.Creds(altsTC), grpc.InTapHandle(authz)) grpcServer := grpc.NewServer(grpc.Creds(altsTC), grpc.InTapHandle(authz))
testpb.RegisterTestServiceServer(grpcServer, interop.NewTestServer()) testgrpc.RegisterTestServiceServer(grpcServer, interop.NewTestServer())
grpcServer.Serve(lis) grpcServer.Serve(lis)
} }

View File

@ -32,9 +32,10 @@ import (
"google.golang.org/grpc/credentials/oauth" "google.golang.org/grpc/credentials/oauth"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/interop" "google.golang.org/grpc/interop"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver"
"google.golang.org/grpc/testdata" "google.golang.org/grpc/testdata"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
) )
const ( const (
@ -188,7 +189,7 @@ func main() {
logger.Fatalf("Fail to dial: %v", err) logger.Fatalf("Fail to dial: %v", err)
} }
defer conn.Close() defer conn.Close()
tc := testpb.NewTestServiceClient(conn) tc := testgrpc.NewTestServiceClient(conn)
switch *testCase { switch *testCase {
case "empty_unary": case "empty_unary":
interop.DoEmptyUnaryCall(tc) interop.DoEmptyUnaryCall(tc)
@ -272,7 +273,7 @@ func main() {
interop.DoUnimplementedMethod(conn) interop.DoUnimplementedMethod(conn)
logger.Infoln("UnimplementedMethod done") logger.Infoln("UnimplementedMethod done")
case "unimplemented_service": case "unimplemented_service":
interop.DoUnimplementedService(testpb.NewUnimplementedServiceClient(conn)) interop.DoUnimplementedService(testgrpc.NewUnimplementedServiceClient(conn))
logger.Infoln("UnimplementedService done") logger.Infoln("UnimplementedService done")
case "pick_first_unary": case "pick_first_unary":
interop.DoPickFirstUnary(tc) interop.DoPickFirstUnary(tc)

View File

@ -37,6 +37,8 @@ import (
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/credentials/alts"
"google.golang.org/grpc/credentials/google" "google.golang.org/grpc/credentials/google"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "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) 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) infoLog.Printf("doRPCAndGetPath timeout:%v\n", timeout)
ctx, cancel := context.WithTimeout(context.Background(), timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel() 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 fallbackRetryCount := 0
fellBack := false fellBack := false
for time.Now().Before(fallbackDeadline) { for time.Now().Before(fallbackDeadline) {
@ -160,7 +162,7 @@ func doFastFallbackBeforeStartup() {
fallbackDeadline := time.Now().Add(5 * time.Second) fallbackDeadline := time.Now().Add(5 * time.Second)
conn := createTestConn() conn := createTestConn()
defer conn.Close() defer conn.Close()
client := testpb.NewTestServiceClient(conn) client := testgrpc.NewTestServiceClient(conn)
waitForFallbackAndDoRPCs(client, fallbackDeadline) waitForFallbackAndDoRPCs(client, fallbackDeadline)
} }
@ -169,14 +171,14 @@ func doSlowFallbackBeforeStartup() {
fallbackDeadline := time.Now().Add(20 * time.Second) fallbackDeadline := time.Now().Add(20 * time.Second)
conn := createTestConn() conn := createTestConn()
defer conn.Close() defer conn.Close()
client := testpb.NewTestServiceClient(conn) client := testgrpc.NewTestServiceClient(conn)
waitForFallbackAndDoRPCs(client, fallbackDeadline) waitForFallbackAndDoRPCs(client, fallbackDeadline)
} }
func doFastFallbackAfterStartup() { func doFastFallbackAfterStartup() {
conn := createTestConn() conn := createTestConn()
defer conn.Close() 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 { 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) errorLog.Fatalf("Expected RPC to take grpclb route type BACKEND. Got: %v", g)
} }
@ -188,7 +190,7 @@ func doFastFallbackAfterStartup() {
func doSlowFallbackAfterStartup() { func doSlowFallbackAfterStartup() {
conn := createTestConn() conn := createTestConn()
defer conn.Close() 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 { 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) errorLog.Fatalf("Expected RPC to take grpclb route type BACKEND. Got: %v", g)
} }

View File

@ -35,8 +35,10 @@ import (
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/interop" "google.golang.org/grpc/interop"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "google.golang.org/grpc/interop/grpc_testing"
) )
var ( var (
@ -66,7 +68,7 @@ func largeSimpleRequest() *testpb.SimpleRequest {
} }
// sends two unary calls. The server asserts that the calls use different connections. // 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) interop.DoLargeUnaryCall(tc)
// sleep to ensure that the client has time to recv the GOAWAY. // sleep to ensure that the client has time to recv the GOAWAY.
// TODO(ncteisen): make this less hacky. // TODO(ncteisen): make this less hacky.
@ -74,7 +76,7 @@ func goaway(tc testpb.TestServiceClient) {
interop.DoLargeUnaryCall(tc) interop.DoLargeUnaryCall(tc)
} }
func rstAfterHeader(tc testpb.TestServiceClient) { func rstAfterHeader(tc testgrpc.TestServiceClient) {
req := largeSimpleRequest() req := largeSimpleRequest()
reply, err := tc.UnaryCall(context.Background(), req) reply, err := tc.UnaryCall(context.Background(), req)
if reply != nil { if reply != nil {
@ -85,7 +87,7 @@ func rstAfterHeader(tc testpb.TestServiceClient) {
} }
} }
func rstDuringData(tc testpb.TestServiceClient) { func rstDuringData(tc testgrpc.TestServiceClient) {
req := largeSimpleRequest() req := largeSimpleRequest()
reply, err := tc.UnaryCall(context.Background(), req) reply, err := tc.UnaryCall(context.Background(), req)
if reply != nil { if reply != nil {
@ -96,7 +98,7 @@ func rstDuringData(tc testpb.TestServiceClient) {
} }
} }
func rstAfterData(tc testpb.TestServiceClient) { func rstAfterData(tc testgrpc.TestServiceClient) {
req := largeSimpleRequest() req := largeSimpleRequest()
reply, err := tc.UnaryCall(context.Background(), req) reply, err := tc.UnaryCall(context.Background(), req)
if reply != nil { 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. // The server will assert that every ping it sends was ACK-ed by the client.
interop.DoLargeUnaryCall(tc) interop.DoLargeUnaryCall(tc)
} }
func maxStreams(tc testpb.TestServiceClient) { func maxStreams(tc testgrpc.TestServiceClient) {
interop.DoLargeUnaryCall(tc) interop.DoLargeUnaryCall(tc)
var wg sync.WaitGroup var wg sync.WaitGroup
for i := 0; i < 15; i++ { for i := 0; i < 15; i++ {
@ -135,7 +137,7 @@ func main() {
logger.Fatalf("Fail to dial: %v", err) logger.Fatalf("Fail to dial: %v", err)
} }
defer conn.Close() defer conn.Close()
tc := testpb.NewTestServiceClient(conn) tc := testgrpc.NewTestServiceClient(conn)
switch *testCase { switch *testCase {
case "goaway": case "goaway":
goaway(tc) goaway(tc)

View File

@ -29,8 +29,9 @@ import (
"google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/credentials/alts"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/interop" "google.golang.org/grpc/interop"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/testdata" "google.golang.org/grpc/testdata"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
) )
var ( var (
@ -76,6 +77,6 @@ func main() {
opts = append(opts, grpc.Creds(altsTC)) opts = append(opts, grpc.Creds(altsTC))
} }
server := grpc.NewServer(opts...) server := grpc.NewServer(opts...)
testpb.RegisterTestServiceServer(server, interop.NewTestServer()) testgrpc.RegisterTestServiceServer(server, interop.NewTestServer())
server.Serve(lis) server.Serve(lis)
} }

View File

@ -33,9 +33,11 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "google.golang.org/grpc/interop/grpc_testing"
) )
var ( 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. // 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...) reply, err := tc.EmptyCall(context.Background(), &testpb.Empty{}, args...)
if err != nil { if err != nil {
logger.Fatal("/TestService/EmptyCall RPC failed: ", err) 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. // 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) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: testpb.PayloadType_COMPRESSABLE, ResponseType: testpb.PayloadType_COMPRESSABLE,
@ -97,7 +99,7 @@ func DoLargeUnaryCall(tc testpb.TestServiceClient, args ...grpc.CallOption) {
} }
// DoClientStreaming performs a client streaming RPC. // 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...) stream, err := tc.StreamingInputCall(context.Background(), args...)
if err != nil { if err != nil {
logger.Fatalf("%v.StreamingInputCall(_) = _, %v", tc, err) 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. // 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)) respParam := make([]*testpb.ResponseParameters, len(respSizes))
for i, s := range respSizes { for i, s := range respSizes {
respParam[i] = &testpb.ResponseParameters{ 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. // 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...) stream, err := tc.FullDuplexCall(context.Background(), args...)
if err != nil { if err != nil {
logger.Fatalf("%v.FullDuplexCall(_) = _, %v", tc, err) 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. // 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...) stream, err := tc.FullDuplexCall(context.Background(), args...)
if err != nil { if err != nil {
logger.Fatalf("%v.FullDuplexCall(_) = _, %v", tc, err) 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. // 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) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Millisecond)
defer cancel() defer cancel()
stream, err := tc.FullDuplexCall(ctx, args...) 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. // 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) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: testpb.PayloadType_COMPRESSABLE, ResponseType: testpb.PayloadType_COMPRESSABLE,
@ -281,7 +283,7 @@ func getServiceAccountJSONKey(keyFile string) []byte {
} }
// DoServiceAccountCreds performs a unary RPC with service account auth. // 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) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: testpb.PayloadType_COMPRESSABLE, ResponseType: testpb.PayloadType_COMPRESSABLE,
@ -306,7 +308,7 @@ func DoServiceAccountCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, o
} }
// DoJWTTokenCreds performs a unary RPC with JWT token auth. // 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) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: testpb.PayloadType_COMPRESSABLE, 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. // 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) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: testpb.PayloadType_COMPRESSABLE, 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. // 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) jsonKey := getServiceAccountJSONKey(serviceAccountKeyFile)
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
@ -393,7 +395,7 @@ func DoPerRPCCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oauthScop
} }
// DoGoogleDefaultCredentials performs an unary RPC with google default credentials // 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) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: testpb.PayloadType_COMPRESSABLE, ResponseType: testpb.PayloadType_COMPRESSABLE,
@ -412,7 +414,7 @@ func DoGoogleDefaultCredentials(tc testpb.TestServiceClient, defaultServiceAccou
} }
// DoComputeEngineChannelCredentials performs an unary RPC with compute engine channel credentials // 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) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
req := &testpb.SimpleRequest{ req := &testpb.SimpleRequest{
ResponseType: testpb.PayloadType_COMPRESSABLE, 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. // 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)) ctx, cancel := context.WithCancel(metadata.NewOutgoingContext(context.Background(), testMetadata))
stream, err := tc.StreamingInputCall(ctx, args...) stream, err := tc.StreamingInputCall(ctx, args...)
if err != nil { 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. // 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()) ctx, cancel := context.WithCancel(context.Background())
stream, err := tc.FullDuplexCall(ctx, args...) stream, err := tc.FullDuplexCall(ctx, args...)
if err != nil { if err != nil {
@ -504,7 +506,7 @@ func validateMetadata(header, trailer metadata.MD) {
} }
// DoCustomMetadata checks that metadata is echoed back to the client. // 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. // Testing with UnaryCall.
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, 1) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, 1)
req := &testpb.SimpleRequest{ 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. // 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 var code int32 = 2
msg := "test status message" msg := "test status message"
expectedErr := status.Error(codes.Code(code), msg) 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 // DoSpecialStatusMessage verifies Unicode and whitespace is correctly processed
// in status message. // in status message.
func DoSpecialStatusMessage(tc testpb.TestServiceClient, args ...grpc.CallOption) { func DoSpecialStatusMessage(tc testgrpc.TestServiceClient, args ...grpc.CallOption) {
const ( const (
code int32 = 2 code int32 = 2
msg string = "\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n" 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. // 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{}) _, err := tc.UnimplementedCall(context.Background(), &testpb.Empty{})
if status.Code(err) != codes.Unimplemented { if status.Code(err) != codes.Unimplemented {
logger.Fatalf("%v.UnimplementedCall() = _, %v, want _, %v", tc, 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 // DoPickFirstUnary runs multiple RPCs (rpcCount) and checks that all requests
// are sent to the same backend. // are sent to the same backend.
func DoPickFirstUnary(tc testpb.TestServiceClient) { func DoPickFirstUnary(tc testgrpc.TestServiceClient) {
const rpcCount = 100 const rpcCount = 100
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, 1) pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, 1)
@ -672,11 +674,11 @@ func DoPickFirstUnary(tc testpb.TestServiceClient) {
} }
type testServer struct { type testServer struct {
testpb.UnimplementedTestServiceServer testgrpc.UnimplementedTestServiceServer
} }
// NewTestServer creates a test server for test service. // NewTestServer creates a test server for test service.
func NewTestServer() testpb.TestServiceServer { func NewTestServer() testgrpc.TestServiceServer {
return &testServer{} return &testServer{}
} }
@ -724,7 +726,7 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*
}, nil }, 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() cs := args.GetResponseParameters()
for _, c := range cs { for _, c := range cs {
if us := c.GetIntervalUs(); us > 0 { if us := c.GetIntervalUs(); us > 0 {
@ -743,7 +745,7 @@ func (s *testServer) StreamingOutputCall(args *testpb.StreamingOutputCallRequest
return nil return nil
} }
func (s *testServer) StreamingInputCall(stream testpb.TestService_StreamingInputCallServer) error { func (s *testServer) StreamingInputCall(stream testgrpc.TestService_StreamingInputCallServer) error {
var sum int var sum int
for { for {
in, err := stream.Recv() 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 md, ok := metadata.FromIncomingContext(stream.Context()); ok {
if initialMetadata, ok := md[initialMetadataKey]; ok { if initialMetadata, ok := md[initialMetadataKey]; ok {
header := metadata.Pairs(initialMetadataKey, initialMetadata[0]) 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 var msgBuf []*testpb.StreamingOutputCallRequest
for { for {
in, err := stream.Recv() in, err := stream.Recv()

View File

@ -32,10 +32,12 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer" "google.golang.org/grpc/peer"
_ "google.golang.org/grpc/xds" _ "google.golang.org/grpc/xds"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "google.golang.org/grpc/interop/grpc_testing"
) )
func init() { func init() {
@ -163,7 +165,7 @@ var (
) )
type statsService struct { type statsService struct {
testpb.UnimplementedLoadBalancerStatsServiceServer testgrpc.UnimplementedLoadBalancerStatsServiceServer
} }
func hasRPCSucceeded() bool { func hasRPCSucceeded() bool {
@ -235,7 +237,7 @@ func (s *statsService) GetClientAccumulatedStats(ctx context.Context, in *testpb
} }
type configureService struct { type configureService struct {
testpb.UnimplementedXdsUpdateClientConfigureServiceServer testgrpc.UnimplementedXdsUpdateClientConfigureServiceServer
} }
func (s *configureService) Configure(ctx context.Context, in *testpb.ClientConfigureRequest) (*testpb.ClientConfigureResponse, error) { func (s *configureService) Configure(ctx context.Context, in *testpb.ClientConfigureRequest) (*testpb.ClientConfigureResponse, error) {
@ -334,25 +336,25 @@ func main() {
} }
s := grpc.NewServer() s := grpc.NewServer()
defer s.Stop() defer s.Stop()
testpb.RegisterLoadBalancerStatsServiceServer(s, &statsService{}) testgrpc.RegisterLoadBalancerStatsServiceServer(s, &statsService{})
testpb.RegisterXdsUpdateClientConfigureServiceServer(s, &configureService{}) testgrpc.RegisterXdsUpdateClientConfigureServiceServer(s, &configureService{})
go s.Serve(lis) go s.Serve(lis)
clients := make([]testpb.TestServiceClient, *numChannels) clients := make([]testgrpc.TestServiceClient, *numChannels)
for i := 0; i < *numChannels; i++ { for i := 0; i < *numChannels; i++ {
conn, err := grpc.DialContext(context.Background(), *server, grpc.WithInsecure()) conn, err := grpc.DialContext(context.Background(), *server, grpc.WithInsecure())
if err != nil { if err != nil {
logger.Fatalf("Fail to dial: %v", err) logger.Fatalf("Fail to dial: %v", err)
} }
defer conn.Close() defer conn.Close()
clients[i] = testpb.NewTestServiceClient(conn) clients[i] = testgrpc.NewTestServiceClient(conn)
} }
ticker := time.NewTicker(time.Second / time.Duration(*qps**numChannels)) ticker := time.NewTicker(time.Second / time.Duration(*qps**numChannels))
defer ticker.Stop() defer ticker.Stop()
sendRPCs(clients, ticker) 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) ctx, cancel := context.WithTimeout(context.Background(), *rpcTimeout)
defer cancel() defer cancel()
@ -392,7 +394,7 @@ func makeOneRPC(c testpb.TestServiceClient, cfg *rpcConfig) (*peer.Peer, *rpcInf
return &p, &info, err return &p, &info, err
} }
func sendRPCs(clients []testpb.TestServiceClient, ticker *time.Ticker) { func sendRPCs(clients []testgrpc.TestServiceClient, ticker *time.Ticker) {
var i int var i int
for range ticker.C { for range ticker.C {
// Get and increment request ID, and save a list of watchers that are // Get and increment request ID, and save a list of watchers that are

View File

@ -29,8 +29,10 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "google.golang.org/grpc/interop/grpc_testing"
) )
var ( var (
@ -50,7 +52,7 @@ func getHostname() string {
} }
type server struct { type server struct {
testpb.UnimplementedTestServiceServer testgrpc.UnimplementedTestServiceServer
} }
func (s *server) EmptyCall(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) { 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) logger.Fatalf("failed to listen: %v", err)
} }
s := grpc.NewServer() s := grpc.NewServer()
testpb.RegisterTestServiceServer(s, &server{}) testgrpc.RegisterTestServiceServer(s, &server{})
s.Serve(lis) s.Serve(lis)
} }

View File

@ -31,10 +31,12 @@ import (
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/internal/grpctest" "google.golang.org/grpc/internal/grpctest"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/stats" "google.golang.org/grpc/stats"
"google.golang.org/grpc/status" "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 const defaultTestTimeout = 10 * time.Second
@ -87,7 +89,7 @@ func payloadToID(p *testpb.Payload) int32 {
} }
type testServer struct { type testServer struct {
testpb.UnimplementedTestServiceServer testgrpc.UnimplementedTestServiceServer
} }
func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { 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 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 { if err := stream.SendHeader(testHeaderMetadata); err != nil {
return status.Errorf(status.Code(err), "%v.SendHeader(%v) = %v, want %v", stream, 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 { if err := stream.SendHeader(testHeaderMetadata); err != nil {
return status.Errorf(status.Code(err), "%v.SendHeader(%v) = %v, want %v", stream, 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 { if err := stream.SendHeader(testHeaderMetadata); err != nil {
return status.Errorf(status.Code(err), "%v.SendHeader(%v) = %v, want %v", stream, 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 clientStatsHandler stats.Handler
serverStatsHandler 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 and srvAddr are set once startServer is called.
srv *grpc.Server srv *grpc.Server
srvAddr string 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 // startServer starts a gRPC server listening. Callers should defer a
// call to te.tearDown to clean up. // call to te.tearDown to clean up.
func (te *test) startServer(ts testpb.TestServiceServer) { func (te *test) startServer(ts testgrpc.TestServiceServer) {
te.testServer = ts te.testServer = ts
lis, err := net.Listen("tcp", "localhost:0") lis, err := net.Listen("tcp", "localhost:0")
if err != nil { if err != nil {
@ -232,7 +234,7 @@ func (te *test) startServer(ts testpb.TestServiceServer) {
s := grpc.NewServer(opts...) s := grpc.NewServer(opts...)
te.srv = s te.srv = s
if te.testServer != nil { if te.testServer != nil {
testpb.RegisterTestServiceServer(s, te.testServer) testgrpc.RegisterTestServiceServer(s, te.testServer)
} }
go s.Serve(lis) go s.Serve(lis)
@ -288,7 +290,7 @@ func (te *test) doUnaryCall(c *rpcConfig) (*testpb.SimpleRequest, *testpb.Simple
req *testpb.SimpleRequest req *testpb.SimpleRequest
err error err error
) )
tc := testpb.NewTestServiceClient(te.clientConn()) tc := testgrpc.NewTestServiceClient(te.clientConn())
if c.success { if c.success {
req = &testpb.SimpleRequest{Payload: idToPayload(errorID + 1)} req = &testpb.SimpleRequest{Payload: idToPayload(errorID + 1)}
} else { } else {
@ -307,7 +309,7 @@ func (te *test) doFullDuplexCallRoundtrip(c *rpcConfig) ([]proto.Message, []prot
resps []proto.Message resps []proto.Message
err error err error
) )
tc := testpb.NewTestServiceClient(te.clientConn()) tc := testgrpc.NewTestServiceClient(te.clientConn())
tCtx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) tCtx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel() defer cancel()
stream, err := tc.FullDuplexCall(metadata.NewOutgoingContext(tCtx, testMetadata), grpc.WaitForReady(!c.failfast)) 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 resp *testpb.StreamingInputCallResponse
err error err error
) )
tc := testpb.NewTestServiceClient(te.clientConn()) tc := testgrpc.NewTestServiceClient(te.clientConn())
tCtx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) tCtx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel() defer cancel()
stream, err := tc.StreamingInputCall(metadata.NewOutgoingContext(tCtx, testMetadata), grpc.WaitForReady(!c.failfast)) 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 err error
) )
tc := testpb.NewTestServiceClient(te.clientConn()) tc := testgrpc.NewTestServiceClient(te.clientConn())
var startID int32 var startID int32
if !c.success { if !c.success {

View File

@ -35,10 +35,11 @@ import (
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/interop" "google.golang.org/grpc/interop"
testpb "google.golang.org/grpc/interop/grpc_testing"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
metricspb "google.golang.org/grpc/stress/grpc_testing"
"google.golang.org/grpc/testdata" "google.golang.org/grpc/testdata"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
metricspb "google.golang.org/grpc/stress/grpc_testing"
) )
var ( var (
@ -209,7 +210,7 @@ func startServer(server *server, port int) {
// performRPCs uses weightedRandomTestSelector to select test case and runs the tests. // performRPCs uses weightedRandomTestSelector to select test case and runs the tests.
func performRPCs(gauge *gauge, conn *grpc.ClientConn, selector *weightedRandomTestSelector, stop <-chan bool) { func performRPCs(gauge *gauge, conn *grpc.ClientConn, selector *weightedRandomTestSelector, stop <-chan bool) {
client := testpb.NewTestServiceClient(conn) client := testgrpc.NewTestServiceClient(conn)
var numCalls int64 var numCalls int64
startTime := time.Now() startTime := time.Now()
for { for {