Skip to content

Commit ecc9a99

Browse files
authored
interop: remove test.proto clones/variants and use grpc-proto repo instead (#4129)
1 parent 4f80d77 commit ecc9a99

37 files changed

+7268
-7493
lines changed

benchmark/benchmain/main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ import (
5858
"time"
5959

6060
"google.golang.org/grpc"
61+
"google.golang.org/grpc/benchmark"
6162
bm "google.golang.org/grpc/benchmark"
6263
"google.golang.org/grpc/benchmark/flags"
63-
testpb "google.golang.org/grpc/benchmark/grpc_testing"
6464
"google.golang.org/grpc/benchmark/latency"
6565
"google.golang.org/grpc/benchmark/stats"
6666
"google.golang.org/grpc/grpclog"
6767
"google.golang.org/grpc/internal/channelz"
68+
testpb "google.golang.org/grpc/interop/grpc_testing"
6869
"google.golang.org/grpc/keepalive"
70+
"google.golang.org/grpc/metadata"
6971
"google.golang.org/grpc/test/bufconn"
7072
)
7173

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

406408
streams := make([]testpb.BenchmarkService_StreamingCallClient, bf.MaxConcurrentCalls)
409+
md := metadata.Pairs(benchmark.UnconstrainedStreamingHeader, "1")
410+
ctx := metadata.NewOutgoingContext(context.Background(), md)
407411
for i := 0; i < bf.MaxConcurrentCalls; i++ {
408-
stream, err := tc.UnconstrainedStreamingCall(context.Background())
412+
stream, err := tc.StreamingCall(ctx)
409413
if err != nil {
410-
logger.Fatalf("%v.UnconstrainedStreamingCall(_) = _, %v", tc, err)
414+
logger.Fatalf("%v.StreamingCall(_) = _, %v", tc, err)
411415
}
412416
streams[i] = stream
413417
}

benchmark/benchmark.go

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ import (
2929
"net"
3030

3131
"google.golang.org/grpc"
32-
testpb "google.golang.org/grpc/benchmark/grpc_testing"
3332
"google.golang.org/grpc/codes"
3433
"google.golang.org/grpc/grpclog"
34+
testpb "google.golang.org/grpc/interop/grpc_testing"
35+
"google.golang.org/grpc/metadata"
3536
"google.golang.org/grpc/status"
3637
)
3738

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

73+
// UnconstrainedStreamingHeader indicates to the StreamingCall handler that its
74+
// behavior should be unconstrained (constant send/receive in parallel) instead
75+
// of ping-pong.
76+
const UnconstrainedStreamingHeader = "unconstrained-streaming"
77+
7478
func (s *testServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error {
79+
if md, ok := metadata.FromIncomingContext(stream.Context()); ok && len(md[UnconstrainedStreamingHeader]) != 0 {
80+
return s.UnconstrainedStreamingCall(stream)
81+
}
7582
response := &testpb.SimpleResponse{
7683
Payload: new(testpb.Payload),
7784
}
@@ -93,7 +100,7 @@ func (s *testServer) StreamingCall(stream testpb.BenchmarkService_StreamingCallS
93100
}
94101
}
95102

96-
func (s *testServer) UnconstrainedStreamingCall(stream testpb.BenchmarkService_UnconstrainedStreamingCallServer) error {
103+
func (s *testServer) UnconstrainedStreamingCall(stream testpb.BenchmarkService_StreamingCallServer) error {
97104
in := new(testpb.SimpleRequest)
98105
// Receive a message to learn response type and size.
99106
err := stream.RecvMsg(in)
@@ -171,23 +178,6 @@ func (s *byteBufServer) StreamingCall(stream testpb.BenchmarkService_StreamingCa
171178
}
172179
}
173180

174-
func (s *byteBufServer) UnconstrainedStreamingCall(stream testpb.BenchmarkService_UnconstrainedStreamingCallServer) error {
175-
for {
176-
var in []byte
177-
err := stream.(grpc.ServerStream).RecvMsg(&in)
178-
if err == io.EOF {
179-
return nil
180-
}
181-
if err != nil {
182-
return err
183-
}
184-
out := make([]byte, s.respSize)
185-
if err := stream.(grpc.ServerStream).SendMsg(&out); err != nil {
186-
return err
187-
}
188-
}
189-
}
190-
191181
// ServerInfo contains the information to create a gRPC benchmark server.
192182
type ServerInfo struct {
193183
// Type is the type of the server.

benchmark/client/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ import (
5050

5151
"google.golang.org/grpc"
5252
"google.golang.org/grpc/benchmark"
53-
testpb "google.golang.org/grpc/benchmark/grpc_testing"
5453
"google.golang.org/grpc/benchmark/stats"
5554
"google.golang.org/grpc/grpclog"
5655
"google.golang.org/grpc/internal/syscall"
56+
testpb "google.golang.org/grpc/interop/grpc_testing"
5757
)
5858

5959
var (

0 commit comments

Comments
 (0)