Skip to content

Commit

Permalink
interop: remove test.proto clones/variants and use grpc-proto repo in…
Browse files Browse the repository at this point in the history
…stead (#4129)
  • Loading branch information
dfawley committed Jan 7, 2021
1 parent 4f80d77 commit ecc9a99
Show file tree
Hide file tree
Showing 37 changed files with 7,268 additions and 7,493 deletions.
10 changes: 7 additions & 3 deletions benchmark/benchmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ import (
"time"

"google.golang.org/grpc"
"google.golang.org/grpc/benchmark"
bm "google.golang.org/grpc/benchmark"
"google.golang.org/grpc/benchmark/flags"
testpb "google.golang.org/grpc/benchmark/grpc_testing"
"google.golang.org/grpc/benchmark/latency"
"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"
)

Expand Down Expand Up @@ -404,10 +406,12 @@ func setupUnconstrainedStream(bf stats.Features) ([]testpb.BenchmarkService_Stre
tc, cleanup := makeClient(bf)

streams := make([]testpb.BenchmarkService_StreamingCallClient, bf.MaxConcurrentCalls)
md := metadata.Pairs(benchmark.UnconstrainedStreamingHeader, "1")
ctx := metadata.NewOutgoingContext(context.Background(), md)
for i := 0; i < bf.MaxConcurrentCalls; i++ {
stream, err := tc.UnconstrainedStreamingCall(context.Background())
stream, err := tc.StreamingCall(ctx)
if err != nil {
logger.Fatalf("%v.UnconstrainedStreamingCall(_) = _, %v", tc, err)
logger.Fatalf("%v.StreamingCall(_) = _, %v", tc, err)
}
streams[i] = stream
}
Expand Down
32 changes: 11 additions & 21 deletions benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ import (
"net"

"google.golang.org/grpc"
testpb "google.golang.org/grpc/benchmark/grpc_testing"
"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"
)

Expand All @@ -45,8 +46,6 @@ func setPayload(p *testpb.Payload, t testpb.PayloadType, size int) {
body := make([]byte, size)
switch t {
case testpb.PayloadType_COMPRESSABLE:
case testpb.PayloadType_UNCOMPRESSABLE:
logger.Fatalf("PayloadType UNCOMPRESSABLE is not supported")
default:
logger.Fatalf("Unsupported payload type: %d", t)
}
Expand All @@ -71,7 +70,15 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*
}, nil
}

// UnconstrainedStreamingHeader indicates to the StreamingCall handler that its
// behavior should be unconstrained (constant send/receive in parallel) instead
// of ping-pong.
const UnconstrainedStreamingHeader = "unconstrained-streaming"

func (s *testServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error {
if md, ok := metadata.FromIncomingContext(stream.Context()); ok && len(md[UnconstrainedStreamingHeader]) != 0 {
return s.UnconstrainedStreamingCall(stream)
}
response := &testpb.SimpleResponse{
Payload: new(testpb.Payload),
}
Expand All @@ -93,7 +100,7 @@ func (s *testServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallS
}
}

func (s *testServer) UnconstrainedStreamingCall(stream testpb.BenchmarkService_UnconstrainedStreamingCallServer) error {
func (s *testServer) UnconstrainedStreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error {
in := new(testpb.SimpleRequest)
// Receive a message to learn response type and size.
err := stream.RecvMsg(in)
Expand Down Expand Up @@ -171,23 +178,6 @@ func (s *byteBufServer) StreamingCall(stream testpb.BenchmarkService_StreamingCa
}
}

func (s *byteBufServer) UnconstrainedStreamingCall(stream testpb.BenchmarkService_UnconstrainedStreamingCallServer) error {
for {
var in []byte
err := stream.(grpc.ServerStream).RecvMsg(&in)
if err == io.EOF {
return nil
}
if err != nil {
return err
}
out := make([]byte, s.respSize)
if err := stream.(grpc.ServerStream).SendMsg(&out); err != nil {
return err
}
}
}

// ServerInfo contains the information to create a gRPC benchmark server.
type ServerInfo struct {
// Type is the type of the server.
Expand Down
2 changes: 1 addition & 1 deletion benchmark/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/benchmark"
testpb "google.golang.org/grpc/benchmark/grpc_testing"
"google.golang.org/grpc/benchmark/stats"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/internal/syscall"
testpb "google.golang.org/grpc/interop/grpc_testing"
)

var (
Expand Down

0 comments on commit ecc9a99

Please sign in to comment.