diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-11-09 19:11:02 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-11-14 11:07:31 +0300 |
commit | c2655af544aadbf8da425144239e494251e2aa55 (patch) | |
tree | b850462f5d5956b257804a880a378e89b53eea79 /internal/middleware | |
parent | a415ff702cfd0755db5d1a09c63c13ce13b54f58 (diff) |
limithandler: Refactor tests to use `grpc_testing` gRPC service
The tests for our `limithandler` middleware use a custom gRPC service
definition to assert its behaviour. This is not necessary though as
`grpc-go` already provides a `grpc_testing` package that contains a gRPC
service that is designed for testing gRPC-specific behaviour.
Refactor the test to use this package and get rid of our own Protobuf
definitions.
Diffstat (limited to 'internal/middleware')
-rw-r--r-- | internal/middleware/limithandler/middleware_test.go | 149 | ||||
-rw-r--r-- | internal/middleware/limithandler/testdata/test.pb.go | 577 | ||||
-rw-r--r-- | internal/middleware/limithandler/testdata/test.proto | 29 | ||||
-rw-r--r-- | internal/middleware/limithandler/testdata/test_grpc.pb.go | 307 | ||||
-rw-r--r-- | internal/middleware/limithandler/testhelper_test.go | 40 |
5 files changed, 112 insertions, 990 deletions
diff --git a/internal/middleware/limithandler/middleware_test.go b/internal/middleware/limithandler/middleware_test.go index 08c3f0cca..b081fd803 100644 --- a/internal/middleware/limithandler/middleware_test.go +++ b/internal/middleware/limithandler/middleware_test.go @@ -18,13 +18,13 @@ import ( "gitlab.com/gitlab-org/gitaly/v15/internal/helper" "gitlab.com/gitlab-org/gitaly/v15/internal/helper/duration" "gitlab.com/gitlab-org/gitaly/v15/internal/middleware/limithandler" - pb "gitlab.com/gitlab-org/gitaly/v15/internal/middleware/limithandler/testdata" "gitlab.com/gitlab-org/gitaly/v15/internal/testhelper" "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/status" + "google.golang.org/grpc/test/grpc_testing" "google.golang.org/protobuf/types/known/durationpb" ) @@ -43,7 +43,7 @@ func TestUnaryLimitHandler(t *testing.T) { cfg := config.Cfg{ Concurrency: []config.Concurrency{ - {RPC: "/test.limithandler.Test/Unary", MaxPerRepo: 2}, + {RPC: "/grpc.testing.TestService/UnaryCall", MaxPerRepo: 2}, }, } @@ -56,20 +56,17 @@ func TestUnaryLimitHandler(t *testing.T) { defer conn.Close() ctx := testhelper.Context(t) - wg := &sync.WaitGroup{} + var wg sync.WaitGroup for i := 0; i < 10; i++ { wg.Add(1) go func() { defer wg.Done() - resp, err := client.Unary(ctx, &pb.UnaryRequest{}) - if !assert.NoError(t, err) { - return - } - if !assert.NotNil(t, resp) { - return - } - assert.True(t, resp.Ok) + response, err := client.UnaryCall(ctx, &grpc_testing.SimpleRequest{}) + require.NoError(t, err) + testhelper.ProtoEqual(t, grpc_testing.SimpleResponse{ + Payload: &grpc_testing.Payload{Body: []byte("success")}, + }, response) }() } @@ -87,7 +84,7 @@ func TestStreamLimitHandler(t *testing.T) { testCases := []struct { desc string fullname string - f func(*testing.T, context.Context, pb.TestClient, chan interface{}, chan error) + f func(*testing.T, context.Context, grpc_testing.TestServiceClient, chan interface{}, chan error) maxConcurrency int expectedRequestCount int expectedResponseCount int @@ -100,9 +97,9 @@ func TestStreamLimitHandler(t *testing.T) { // processed once we close the blockCh. { desc: "Single request, multiple responses", - fullname: "/test.limithandler.Test/StreamOutput", - f: func(t *testing.T, ctx context.Context, client pb.TestClient, respCh chan interface{}, errCh chan error) { - stream, err := client.StreamOutput(ctx, &pb.StreamOutputRequest{}) + fullname: "/grpc.testing.TestService/StreamOutputCall", + f: func(t *testing.T, ctx context.Context, client grpc_testing.TestServiceClient, respCh chan interface{}, errCh chan error) { + stream, err := client.StreamingOutputCall(ctx, &grpc_testing.StreamingOutputCallRequest{}) require.NoError(t, err) require.NotNil(t, stream) @@ -111,8 +108,10 @@ func TestStreamLimitHandler(t *testing.T) { errCh <- err return } - require.NotNil(t, r) - require.True(t, r.Ok) + + testhelper.ProtoEqual(t, &grpc_testing.StreamingOutputCallResponse{ + Payload: &grpc_testing.Payload{Body: []byte("success")}, + }, r) respCh <- r }, maxConcurrency: 3, @@ -121,20 +120,22 @@ func TestStreamLimitHandler(t *testing.T) { }, { desc: "Multiple requests, single response", - fullname: "/test.limithandler.Test/StreamInput", - f: func(t *testing.T, ctx context.Context, client pb.TestClient, respCh chan interface{}, errCh chan error) { - stream, err := client.StreamInput(ctx) + fullname: "/grpc.testing.TestService/StreamInputCall", + f: func(t *testing.T, ctx context.Context, client grpc_testing.TestServiceClient, respCh chan interface{}, errCh chan error) { + stream, err := client.StreamingInputCall(ctx) require.NoError(t, err) require.NotNil(t, stream) - require.NoError(t, stream.Send(&pb.StreamInputRequest{})) + require.NoError(t, stream.Send(&grpc_testing.StreamingInputCallRequest{})) r, err := stream.CloseAndRecv() if err != nil { errCh <- err return } - require.NotNil(t, r) - require.True(t, r.Ok) + + testhelper.ProtoEqual(t, &grpc_testing.StreamingOutputCallResponse{ + Payload: &grpc_testing.Payload{Body: []byte("success")}, + }, r) respCh <- r }, maxConcurrency: 3, @@ -143,13 +144,13 @@ func TestStreamLimitHandler(t *testing.T) { }, { desc: "Multiple requests, multiple responses", - fullname: "/test.limithandler.Test/Bidirectional", - f: func(t *testing.T, ctx context.Context, client pb.TestClient, respCh chan interface{}, errCh chan error) { - stream, err := client.Bidirectional(ctx) + fullname: "/grpc.testing.TestService/FullDuplexCall", + f: func(t *testing.T, ctx context.Context, client grpc_testing.TestServiceClient, respCh chan interface{}, errCh chan error) { + stream, err := client.FullDuplexCall(ctx) require.NoError(t, err) require.NotNil(t, stream) - require.NoError(t, stream.Send(&pb.BidirectionalRequest{})) + require.NoError(t, stream.Send(&grpc_testing.StreamingOutputCallRequest{})) require.NoError(t, stream.CloseSend()) r, err := stream.Recv() @@ -157,8 +158,10 @@ func TestStreamLimitHandler(t *testing.T) { errCh <- err return } - require.NotNil(t, r) - require.True(t, r.Ok) + + testhelper.ProtoEqual(t, &grpc_testing.StreamingOutputCallResponse{ + Payload: &grpc_testing.Payload{Body: []byte("success")}, + }, r) respCh <- r }, maxConcurrency: 3, @@ -169,9 +172,9 @@ func TestStreamLimitHandler(t *testing.T) { // Make sure that _streams_ are limited but that _requests_ on each // allowed stream are not limited. desc: "Multiple requests with same id, multiple responses", - fullname: "/test.limithandler.Test/Bidirectional", - f: func(t *testing.T, ctx context.Context, client pb.TestClient, respCh chan interface{}, errCh chan error) { - stream, err := client.Bidirectional(ctx) + fullname: "/grpc.testing.TestService/FullDuplexCall", + f: func(t *testing.T, ctx context.Context, client grpc_testing.TestServiceClient, respCh chan interface{}, errCh chan error) { + stream, err := client.FullDuplexCall(ctx) require.NoError(t, err) require.NotNil(t, stream) @@ -179,7 +182,7 @@ func TestStreamLimitHandler(t *testing.T) { // id, but subsequent requests in a stream, even with the same // id, should bypass the concurrency limiter for i := 0; i < 10; i++ { - require.NoError(t, stream.Send(&pb.BidirectionalRequest{})) + require.NoError(t, stream.Send(&grpc_testing.StreamingOutputCallRequest{})) } require.NoError(t, stream.CloseSend()) @@ -188,8 +191,10 @@ func TestStreamLimitHandler(t *testing.T) { errCh <- err return } - require.NotNil(t, r) - require.True(t, r.Ok) + + testhelper.ProtoEqual(t, &grpc_testing.StreamingOutputCallResponse{ + Payload: &grpc_testing.Payload{Body: []byte("success")}, + }, r) respCh <- r }, maxConcurrency: 3, @@ -200,9 +205,9 @@ func TestStreamLimitHandler(t *testing.T) { }, { desc: "With a max concurrency of 0", - fullname: "/test.limithandler.Test/StreamOutput", - f: func(t *testing.T, ctx context.Context, client pb.TestClient, respCh chan interface{}, errCh chan error) { - stream, err := client.StreamOutput(ctx, &pb.StreamOutputRequest{}) + fullname: "/grpc.testing.TestService/StreamingOutputCall", + f: func(t *testing.T, ctx context.Context, client grpc_testing.TestServiceClient, respCh chan interface{}, errCh chan error) { + stream, err := client.StreamingOutputCall(ctx, &grpc_testing.StreamingOutputCallRequest{}) require.NoError(t, err) require.NotNil(t, stream) @@ -211,8 +216,10 @@ func TestStreamLimitHandler(t *testing.T) { errCh <- err return } - require.NotNil(t, r) - require.True(t, r.Ok) + + testhelper.ProtoEqual(t, &grpc_testing.StreamingOutputCallResponse{ + Payload: &grpc_testing.Payload{Body: []byte("success")}, + }, r) respCh <- r }, maxConcurrency: 0, @@ -287,7 +294,7 @@ func TestStreamLimitHandler_error(t *testing.T) { cfg := config.Cfg{ Concurrency: []config.Concurrency{ - {RPC: "/test.limithandler.Test/Bidirectional", MaxPerRepo: 1, MaxQueueSize: 1}, + {RPC: "/grpc.testing.TestService/FullDuplexCall", MaxPerRepo: 1, MaxQueueSize: 1}, }, } @@ -301,11 +308,11 @@ func TestStreamLimitHandler_error(t *testing.T) { ctx := testhelper.Context(t) - respChan := make(chan *pb.BidirectionalResponse) + respChan := make(chan *grpc_testing.StreamingOutputCallResponse) go func() { - stream, err := client.Bidirectional(ctx) + stream, err := client.FullDuplexCall(ctx) require.NoError(t, err) - require.NoError(t, stream.Send(&pb.BidirectionalRequest{})) + require.NoError(t, stream.Send(&grpc_testing.StreamingOutputCallRequest{})) require.NoError(t, stream.CloseSend()) resp, err := stream.Recv() require.NoError(t, err) @@ -320,10 +327,10 @@ func TestStreamLimitHandler_error(t *testing.T) { errChan := make(chan error) for i := 0; i < 2; i++ { go func() { - stream, err := client.Bidirectional(ctx) + stream, err := client.FullDuplexCall(ctx) require.NoError(t, err) require.NotNil(t, stream) - require.NoError(t, stream.Send(&pb.BidirectionalRequest{})) + require.NoError(t, stream.Send(&grpc_testing.StreamingOutputCallRequest{})) require.NoError(t, stream.CloseSend()) resp, err := stream.Recv() @@ -364,16 +371,20 @@ type queueTestServer struct { reqArrivedCh chan struct{} } -func (q *queueTestServer) Unary(ctx context.Context, in *pb.UnaryRequest) (*pb.UnaryResponse, error) { +func (q *queueTestServer) UnaryCall(ctx context.Context, in *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) { q.registerRequest() q.reqArrivedCh <- struct{}{} // We need a way to know when a request got to the middleware <-q.blockCh // Block to ensure concurrency - return &pb.UnaryResponse{Ok: true}, nil + return &grpc_testing.SimpleResponse{ + Payload: &grpc_testing.Payload{ + Body: []byte("success"), + }, + }, nil } -func (q *queueTestServer) Bidirectional(stream pb.Test_BidirectionalServer) error { +func (q *queueTestServer) FullDuplexCall(stream grpc_testing.TestService_FullDuplexCallServer) error { // Read all the input for { if _, err := stream.Recv(); err != nil { @@ -389,14 +400,18 @@ func (q *queueTestServer) Bidirectional(stream pb.Test_BidirectionalServer) erro } <-q.blockCh // Block to ensure concurrency - return stream.Send(&pb.BidirectionalResponse{Ok: true}) + return stream.Send(&grpc_testing.StreamingOutputCallResponse{ + Payload: &grpc_testing.Payload{ + Body: []byte("success"), + }, + }) } func TestConcurrencyLimitHandlerMetrics(t *testing.T) { s := &queueTestServer{reqArrivedCh: make(chan struct{})} s.blockCh = make(chan struct{}) - methodName := "/test.limithandler.Test/Unary" + methodName := "/grpc.testing.TestService/UnaryCall" cfg := config.Cfg{ Concurrency: []config.Concurrency{ {RPC: methodName, MaxPerRepo: 1, MaxQueueSize: 1}, @@ -413,9 +428,9 @@ func TestConcurrencyLimitHandlerMetrics(t *testing.T) { ctx := testhelper.Context(t) - respCh := make(chan *pb.UnaryResponse) + respCh := make(chan *grpc_testing.SimpleResponse) go func() { - resp, err := client.Unary(ctx, &pb.UnaryRequest{}) + resp, err := client.UnaryCall(ctx, &grpc_testing.SimpleRequest{}) respCh <- resp require.NoError(t, err) }() @@ -427,7 +442,7 @@ func TestConcurrencyLimitHandlerMetrics(t *testing.T) { // an error for i := 0; i < 10; i++ { go func() { - resp, err := client.Unary(ctx, &pb.UnaryRequest{}) + resp, err := client.UnaryCall(ctx, &grpc_testing.SimpleRequest{}) if err != nil { errChan <- err } else { @@ -458,14 +473,14 @@ func TestConcurrencyLimitHandlerMetrics(t *testing.T) { expectedMetrics := `# HELP gitaly_concurrency_limiting_in_progress Gauge of number of concurrent in-progress calls # TYPE gitaly_concurrency_limiting_in_progress gauge gitaly_concurrency_limiting_in_progress{grpc_method="ReplicateRepository",grpc_service="gitaly.RepositoryService",system="gitaly"} 0 -gitaly_concurrency_limiting_in_progress{grpc_method="Unary",grpc_service="test.limithandler.Test",system="gitaly"} 1 +gitaly_concurrency_limiting_in_progress{grpc_method="UnaryCall",grpc_service="grpc.testing.TestService",system="gitaly"} 1 # HELP gitaly_concurrency_limiting_queued Gauge of number of queued calls # TYPE gitaly_concurrency_limiting_queued gauge gitaly_concurrency_limiting_queued{grpc_method="ReplicateRepository",grpc_service="gitaly.RepositoryService",system="gitaly"} 0 -gitaly_concurrency_limiting_queued{grpc_method="Unary",grpc_service="test.limithandler.Test",system="gitaly"} 1 +gitaly_concurrency_limiting_queued{grpc_method="UnaryCall",grpc_service="grpc.testing.TestService",system="gitaly"} 1 # HELP gitaly_requests_dropped_total Number of requests dropped from the queue # TYPE gitaly_requests_dropped_total counter -gitaly_requests_dropped_total{grpc_method="Unary",grpc_service="test.limithandler.Test",reason="max_size",system="gitaly"} 9 +gitaly_requests_dropped_total{grpc_method="UnaryCall",grpc_service="grpc.testing.TestService",reason="max_size",system="gitaly"} 9 ` assert.NoError(t, promtest.CollectAndCompare(lh, bytes.NewBufferString(expectedMetrics), "gitaly_concurrency_limiting_queued", @@ -485,7 +500,7 @@ func TestRateLimitHandler(t *testing.T) { ctx := testhelper.Context(t) - methodName := "/test.limithandler.Test/Unary" + methodName := "/grpc.testing.TestService/UnaryCall" cfg := config.Cfg{ RateLimiting: []config.RateLimiting{ {RPC: methodName, Interval: duration.Duration(1 * time.Hour), Burst: 1}, @@ -507,7 +522,7 @@ func TestRateLimitHandler(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - _, err := client.Unary(ctx, &pb.UnaryRequest{}) + _, err := client.UnaryCall(ctx, &grpc_testing.SimpleRequest{}) require.NoError(t, err) }() // wait until the first request is being processed so we know the rate @@ -516,7 +531,7 @@ func TestRateLimitHandler(t *testing.T) { close(s.blockCh) for i := 0; i < 10; i++ { - _, err := client.Unary(ctx, &pb.UnaryRequest{}) + _, err := client.UnaryCall(ctx, &grpc_testing.SimpleRequest{}) s, ok := status.FromError(err) require.True(t, ok) @@ -532,7 +547,7 @@ func TestRateLimitHandler(t *testing.T) { expectedMetrics := `# HELP gitaly_requests_dropped_total Number of requests dropped from the queue # TYPE gitaly_requests_dropped_total counter -gitaly_requests_dropped_total{grpc_method="Unary",grpc_service="test.limithandler.Test",reason="rate",system="gitaly"} 10 +gitaly_requests_dropped_total{grpc_method="UnaryCall",grpc_service="grpc.testing.TestService",reason="rate",system="gitaly"} 10 ` assert.NoError(t, promtest.CollectAndCompare(lh, bytes.NewBufferString(expectedMetrics), "gitaly_requests_dropped_total")) @@ -552,22 +567,22 @@ gitaly_requests_dropped_total{grpc_method="Unary",grpc_service="test.limithandle defer testhelper.MustClose(t, conn) close(s.blockCh) - _, err := client.Unary(ctx, &pb.UnaryRequest{}) + _, err := client.UnaryCall(ctx, &grpc_testing.SimpleRequest{}) require.NoError(t, err) expectedMetrics := `# HELP gitaly_requests_dropped_total Number of requests dropped from the queue # TYPE gitaly_requests_dropped_total counter -gitaly_requests_dropped_total{grpc_method="Unary",grpc_service="test.limithandler.Test",reason="rate",system="gitaly"} 0 +gitaly_requests_dropped_total{grpc_method="UnaryCall",grpc_service="grpc.testing.TestService",reason="rate",system="gitaly"} 0 ` assert.NoError(t, promtest.CollectAndCompare(lh, bytes.NewBufferString(expectedMetrics), "gitaly_requests_dropped_total")) }) } -func runServer(t *testing.T, s pb.TestServer, opt ...grpc.ServerOption) (*grpc.Server, string) { +func runServer(t *testing.T, s grpc_testing.TestServiceServer, opt ...grpc.ServerOption) (*grpc.Server, string) { serverSocketPath := testhelper.GetTemporaryGitalySocketFileName(t) grpcServer := grpc.NewServer(opt...) - pb.RegisterTestServer(grpcServer, s) + grpc_testing.RegisterTestServiceServer(grpcServer, s) lis, err := net.Listen("unix", serverSocketPath) require.NoError(t, err) @@ -577,7 +592,7 @@ func runServer(t *testing.T, s pb.TestServer, opt ...grpc.ServerOption) (*grpc.S return grpcServer, "unix://" + serverSocketPath } -func newClient(t *testing.T, serverSocketPath string) (pb.TestClient, *grpc.ClientConn) { +func newClient(t *testing.T, serverSocketPath string) (grpc_testing.TestServiceClient, *grpc.ClientConn) { connOpts := []grpc.DialOption{ grpc.WithTransportCredentials(insecure.NewCredentials()), } @@ -586,5 +601,5 @@ func newClient(t *testing.T, serverSocketPath string) (pb.TestClient, *grpc.Clie t.Fatal(err) } - return pb.NewTestClient(conn), conn + return grpc_testing.NewTestServiceClient(conn), conn } diff --git a/internal/middleware/limithandler/testdata/test.pb.go b/internal/middleware/limithandler/testdata/test.pb.go deleted file mode 100644 index dece98010..000000000 --- a/internal/middleware/limithandler/testdata/test.pb.go +++ /dev/null @@ -1,577 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.7 -// source: middleware/limithandler/testdata/test.proto - -package testdata - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type UnaryRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *UnaryRequest) Reset() { - *x = UnaryRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UnaryRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UnaryRequest) ProtoMessage() {} - -func (x *UnaryRequest) ProtoReflect() protoreflect.Message { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UnaryRequest.ProtoReflect.Descriptor instead. -func (*UnaryRequest) Descriptor() ([]byte, []int) { - return file_middleware_limithandler_testdata_test_proto_rawDescGZIP(), []int{0} -} - -type UnaryResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Ok bool `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"` -} - -func (x *UnaryResponse) Reset() { - *x = UnaryResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UnaryResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UnaryResponse) ProtoMessage() {} - -func (x *UnaryResponse) ProtoReflect() protoreflect.Message { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UnaryResponse.ProtoReflect.Descriptor instead. -func (*UnaryResponse) Descriptor() ([]byte, []int) { - return file_middleware_limithandler_testdata_test_proto_rawDescGZIP(), []int{1} -} - -func (x *UnaryResponse) GetOk() bool { - if x != nil { - return x.Ok - } - return false -} - -type StreamInputRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *StreamInputRequest) Reset() { - *x = StreamInputRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StreamInputRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StreamInputRequest) ProtoMessage() {} - -func (x *StreamInputRequest) ProtoReflect() protoreflect.Message { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StreamInputRequest.ProtoReflect.Descriptor instead. -func (*StreamInputRequest) Descriptor() ([]byte, []int) { - return file_middleware_limithandler_testdata_test_proto_rawDescGZIP(), []int{2} -} - -type StreamInputResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Ok bool `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"` -} - -func (x *StreamInputResponse) Reset() { - *x = StreamInputResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StreamInputResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StreamInputResponse) ProtoMessage() {} - -func (x *StreamInputResponse) ProtoReflect() protoreflect.Message { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StreamInputResponse.ProtoReflect.Descriptor instead. -func (*StreamInputResponse) Descriptor() ([]byte, []int) { - return file_middleware_limithandler_testdata_test_proto_rawDescGZIP(), []int{3} -} - -func (x *StreamInputResponse) GetOk() bool { - if x != nil { - return x.Ok - } - return false -} - -type StreamOutputRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *StreamOutputRequest) Reset() { - *x = StreamOutputRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StreamOutputRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StreamOutputRequest) ProtoMessage() {} - -func (x *StreamOutputRequest) ProtoReflect() protoreflect.Message { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StreamOutputRequest.ProtoReflect.Descriptor instead. -func (*StreamOutputRequest) Descriptor() ([]byte, []int) { - return file_middleware_limithandler_testdata_test_proto_rawDescGZIP(), []int{4} -} - -type StreamOutputResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Ok bool `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"` -} - -func (x *StreamOutputResponse) Reset() { - *x = StreamOutputResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StreamOutputResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StreamOutputResponse) ProtoMessage() {} - -func (x *StreamOutputResponse) ProtoReflect() protoreflect.Message { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StreamOutputResponse.ProtoReflect.Descriptor instead. -func (*StreamOutputResponse) Descriptor() ([]byte, []int) { - return file_middleware_limithandler_testdata_test_proto_rawDescGZIP(), []int{5} -} - -func (x *StreamOutputResponse) GetOk() bool { - if x != nil { - return x.Ok - } - return false -} - -type BidirectionalRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *BidirectionalRequest) Reset() { - *x = BidirectionalRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BidirectionalRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BidirectionalRequest) ProtoMessage() {} - -func (x *BidirectionalRequest) ProtoReflect() protoreflect.Message { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BidirectionalRequest.ProtoReflect.Descriptor instead. -func (*BidirectionalRequest) Descriptor() ([]byte, []int) { - return file_middleware_limithandler_testdata_test_proto_rawDescGZIP(), []int{6} -} - -type BidirectionalResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Ok bool `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"` -} - -func (x *BidirectionalResponse) Reset() { - *x = BidirectionalResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BidirectionalResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BidirectionalResponse) ProtoMessage() {} - -func (x *BidirectionalResponse) ProtoReflect() protoreflect.Message { - mi := &file_middleware_limithandler_testdata_test_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BidirectionalResponse.ProtoReflect.Descriptor instead. -func (*BidirectionalResponse) Descriptor() ([]byte, []int) { - return file_middleware_limithandler_testdata_test_proto_rawDescGZIP(), []int{7} -} - -func (x *BidirectionalResponse) GetOk() bool { - if x != nil { - return x.Ok - } - return false -} - -var File_middleware_limithandler_testdata_test_proto protoreflect.FileDescriptor - -var file_middleware_limithandler_testdata_test_proto_rawDesc = []byte{ - 0x0a, 0x2b, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x6c, 0x69, 0x6d, - 0x69, 0x74, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, - 0x74, 0x61, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x74, - 0x65, 0x73, 0x74, 0x2e, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, - 0x22, 0x0e, 0x0a, 0x0c, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x22, 0x1f, 0x0a, 0x0d, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, - 0x6b, 0x22, 0x14, 0x0a, 0x12, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x6e, 0x70, 0x75, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x25, 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, - 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x15, - 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x26, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x4f, - 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, - 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x16, 0x0a, - 0x14, 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x27, 0x0a, 0x15, 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, - 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x32, 0x85, - 0x03, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x4c, 0x0a, 0x05, 0x55, 0x6e, 0x61, 0x72, 0x79, - 0x12, 0x1f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x68, 0x61, 0x6e, - 0x64, 0x6c, 0x65, 0x72, 0x2e, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x20, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x68, 0x61, - 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x2e, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x60, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, - 0x6e, 0x70, 0x75, 0x74, 0x12, 0x25, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x6c, 0x69, 0x6d, 0x69, - 0x74, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, - 0x6e, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x74, 0x65, - 0x73, 0x74, 0x2e, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x2e, - 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x63, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x26, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x6c, - 0x69, 0x6d, 0x69, 0x74, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x27, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x68, 0x61, 0x6e, 0x64, - 0x6c, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x68, 0x0a, 0x0d, - 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x12, 0x27, 0x2e, - 0x74, 0x65, 0x73, 0x74, 0x2e, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, - 0x72, 0x2e, 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x6c, 0x69, - 0x6d, 0x69, 0x74, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x2e, 0x42, 0x69, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2d, 0x6f, 0x72, 0x67, 0x2f, - 0x67, 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2f, 0x76, 0x31, 0x35, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x6c, - 0x69, 0x6d, 0x69, 0x74, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x2f, 0x74, 0x65, 0x73, 0x74, - 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_middleware_limithandler_testdata_test_proto_rawDescOnce sync.Once - file_middleware_limithandler_testdata_test_proto_rawDescData = file_middleware_limithandler_testdata_test_proto_rawDesc -) - -func file_middleware_limithandler_testdata_test_proto_rawDescGZIP() []byte { - file_middleware_limithandler_testdata_test_proto_rawDescOnce.Do(func() { - file_middleware_limithandler_testdata_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_middleware_limithandler_testdata_test_proto_rawDescData) - }) - return file_middleware_limithandler_testdata_test_proto_rawDescData -} - -var file_middleware_limithandler_testdata_test_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_middleware_limithandler_testdata_test_proto_goTypes = []interface{}{ - (*UnaryRequest)(nil), // 0: test.limithandler.UnaryRequest - (*UnaryResponse)(nil), // 1: test.limithandler.UnaryResponse - (*StreamInputRequest)(nil), // 2: test.limithandler.StreamInputRequest - (*StreamInputResponse)(nil), // 3: test.limithandler.StreamInputResponse - (*StreamOutputRequest)(nil), // 4: test.limithandler.StreamOutputRequest - (*StreamOutputResponse)(nil), // 5: test.limithandler.StreamOutputResponse - (*BidirectionalRequest)(nil), // 6: test.limithandler.BidirectionalRequest - (*BidirectionalResponse)(nil), // 7: test.limithandler.BidirectionalResponse -} -var file_middleware_limithandler_testdata_test_proto_depIdxs = []int32{ - 0, // 0: test.limithandler.Test.Unary:input_type -> test.limithandler.UnaryRequest - 2, // 1: test.limithandler.Test.StreamInput:input_type -> test.limithandler.StreamInputRequest - 4, // 2: test.limithandler.Test.StreamOutput:input_type -> test.limithandler.StreamOutputRequest - 6, // 3: test.limithandler.Test.Bidirectional:input_type -> test.limithandler.BidirectionalRequest - 1, // 4: test.limithandler.Test.Unary:output_type -> test.limithandler.UnaryResponse - 3, // 5: test.limithandler.Test.StreamInput:output_type -> test.limithandler.StreamInputResponse - 5, // 6: test.limithandler.Test.StreamOutput:output_type -> test.limithandler.StreamOutputResponse - 7, // 7: test.limithandler.Test.Bidirectional:output_type -> test.limithandler.BidirectionalResponse - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_middleware_limithandler_testdata_test_proto_init() } -func file_middleware_limithandler_testdata_test_proto_init() { - if File_middleware_limithandler_testdata_test_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_middleware_limithandler_testdata_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UnaryRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_middleware_limithandler_testdata_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UnaryResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_middleware_limithandler_testdata_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StreamInputRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_middleware_limithandler_testdata_test_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StreamInputResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_middleware_limithandler_testdata_test_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StreamOutputRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_middleware_limithandler_testdata_test_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StreamOutputResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_middleware_limithandler_testdata_test_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BidirectionalRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_middleware_limithandler_testdata_test_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BidirectionalResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_middleware_limithandler_testdata_test_proto_rawDesc, - NumEnums: 0, - NumMessages: 8, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_middleware_limithandler_testdata_test_proto_goTypes, - DependencyIndexes: file_middleware_limithandler_testdata_test_proto_depIdxs, - MessageInfos: file_middleware_limithandler_testdata_test_proto_msgTypes, - }.Build() - File_middleware_limithandler_testdata_test_proto = out.File - file_middleware_limithandler_testdata_test_proto_rawDesc = nil - file_middleware_limithandler_testdata_test_proto_goTypes = nil - file_middleware_limithandler_testdata_test_proto_depIdxs = nil -} diff --git a/internal/middleware/limithandler/testdata/test.proto b/internal/middleware/limithandler/testdata/test.proto deleted file mode 100644 index 68627d93a..000000000 --- a/internal/middleware/limithandler/testdata/test.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; - -package test.limithandler; - -option go_package = "gitlab.com/gitlab-org/gitaly/v15/internal/middleware/limithandler/testdata"; - -service Test { - rpc Unary(UnaryRequest) returns (UnaryResponse) {} - rpc StreamInput(stream StreamInputRequest) returns (StreamInputResponse) {} - rpc StreamOutput(StreamOutputRequest) returns (stream StreamOutputResponse) {} - rpc Bidirectional(stream BidirectionalRequest) returns (stream BidirectionalResponse) {} -} - -message UnaryRequest {} -message UnaryResponse { - bool ok = 1; -} -message StreamInputRequest {} -message StreamInputResponse { - bool ok = 1; -} -message StreamOutputRequest {} -message StreamOutputResponse { - bool ok = 1; -} -message BidirectionalRequest {} -message BidirectionalResponse { - bool ok = 1; -} diff --git a/internal/middleware/limithandler/testdata/test_grpc.pb.go b/internal/middleware/limithandler/testdata/test_grpc.pb.go deleted file mode 100644 index 66a864f58..000000000 --- a/internal/middleware/limithandler/testdata/test_grpc.pb.go +++ /dev/null @@ -1,307 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.7 -// source: middleware/limithandler/testdata/test.proto - -package testdata - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// TestClient is the client API for Test service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type TestClient interface { - Unary(ctx context.Context, in *UnaryRequest, opts ...grpc.CallOption) (*UnaryResponse, error) - StreamInput(ctx context.Context, opts ...grpc.CallOption) (Test_StreamInputClient, error) - StreamOutput(ctx context.Context, in *StreamOutputRequest, opts ...grpc.CallOption) (Test_StreamOutputClient, error) - Bidirectional(ctx context.Context, opts ...grpc.CallOption) (Test_BidirectionalClient, error) -} - -type testClient struct { - cc grpc.ClientConnInterface -} - -func NewTestClient(cc grpc.ClientConnInterface) TestClient { - return &testClient{cc} -} - -func (c *testClient) Unary(ctx context.Context, in *UnaryRequest, opts ...grpc.CallOption) (*UnaryResponse, error) { - out := new(UnaryResponse) - err := c.cc.Invoke(ctx, "/test.limithandler.Test/Unary", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *testClient) StreamInput(ctx context.Context, opts ...grpc.CallOption) (Test_StreamInputClient, error) { - stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[0], "/test.limithandler.Test/StreamInput", opts...) - if err != nil { - return nil, err - } - x := &testStreamInputClient{stream} - return x, nil -} - -type Test_StreamInputClient interface { - Send(*StreamInputRequest) error - CloseAndRecv() (*StreamInputResponse, error) - grpc.ClientStream -} - -type testStreamInputClient struct { - grpc.ClientStream -} - -func (x *testStreamInputClient) Send(m *StreamInputRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *testStreamInputClient) CloseAndRecv() (*StreamInputResponse, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(StreamInputResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *testClient) StreamOutput(ctx context.Context, in *StreamOutputRequest, opts ...grpc.CallOption) (Test_StreamOutputClient, error) { - stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[1], "/test.limithandler.Test/StreamOutput", opts...) - if err != nil { - return nil, err - } - x := &testStreamOutputClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Test_StreamOutputClient interface { - Recv() (*StreamOutputResponse, error) - grpc.ClientStream -} - -type testStreamOutputClient struct { - grpc.ClientStream -} - -func (x *testStreamOutputClient) Recv() (*StreamOutputResponse, error) { - m := new(StreamOutputResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *testClient) Bidirectional(ctx context.Context, opts ...grpc.CallOption) (Test_BidirectionalClient, error) { - stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[2], "/test.limithandler.Test/Bidirectional", opts...) - if err != nil { - return nil, err - } - x := &testBidirectionalClient{stream} - return x, nil -} - -type Test_BidirectionalClient interface { - Send(*BidirectionalRequest) error - Recv() (*BidirectionalResponse, error) - grpc.ClientStream -} - -type testBidirectionalClient struct { - grpc.ClientStream -} - -func (x *testBidirectionalClient) Send(m *BidirectionalRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *testBidirectionalClient) Recv() (*BidirectionalResponse, error) { - m := new(BidirectionalResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// TestServer is the server API for Test service. -// All implementations must embed UnimplementedTestServer -// for forward compatibility -type TestServer interface { - Unary(context.Context, *UnaryRequest) (*UnaryResponse, error) - StreamInput(Test_StreamInputServer) error - StreamOutput(*StreamOutputRequest, Test_StreamOutputServer) error - Bidirectional(Test_BidirectionalServer) error - mustEmbedUnimplementedTestServer() -} - -// UnimplementedTestServer must be embedded to have forward compatible implementations. -type UnimplementedTestServer struct { -} - -func (UnimplementedTestServer) Unary(context.Context, *UnaryRequest) (*UnaryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Unary not implemented") -} -func (UnimplementedTestServer) StreamInput(Test_StreamInputServer) error { - return status.Errorf(codes.Unimplemented, "method StreamInput not implemented") -} -func (UnimplementedTestServer) StreamOutput(*StreamOutputRequest, Test_StreamOutputServer) error { - return status.Errorf(codes.Unimplemented, "method StreamOutput not implemented") -} -func (UnimplementedTestServer) Bidirectional(Test_BidirectionalServer) error { - return status.Errorf(codes.Unimplemented, "method Bidirectional not implemented") -} -func (UnimplementedTestServer) mustEmbedUnimplementedTestServer() {} - -// UnsafeTestServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to TestServer will -// result in compilation errors. -type UnsafeTestServer interface { - mustEmbedUnimplementedTestServer() -} - -func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer) { - s.RegisterService(&Test_ServiceDesc, srv) -} - -func _Test_Unary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UnaryRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServer).Unary(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/test.limithandler.Test/Unary", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServer).Unary(ctx, req.(*UnaryRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Test_StreamInput_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(TestServer).StreamInput(&testStreamInputServer{stream}) -} - -type Test_StreamInputServer interface { - SendAndClose(*StreamInputResponse) error - Recv() (*StreamInputRequest, error) - grpc.ServerStream -} - -type testStreamInputServer struct { - grpc.ServerStream -} - -func (x *testStreamInputServer) SendAndClose(m *StreamInputResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *testStreamInputServer) Recv() (*StreamInputRequest, error) { - m := new(StreamInputRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func _Test_StreamOutput_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(StreamOutputRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(TestServer).StreamOutput(m, &testStreamOutputServer{stream}) -} - -type Test_StreamOutputServer interface { - Send(*StreamOutputResponse) error - grpc.ServerStream -} - -type testStreamOutputServer struct { - grpc.ServerStream -} - -func (x *testStreamOutputServer) Send(m *StreamOutputResponse) error { - return x.ServerStream.SendMsg(m) -} - -func _Test_Bidirectional_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(TestServer).Bidirectional(&testBidirectionalServer{stream}) -} - -type Test_BidirectionalServer interface { - Send(*BidirectionalResponse) error - Recv() (*BidirectionalRequest, error) - grpc.ServerStream -} - -type testBidirectionalServer struct { - grpc.ServerStream -} - -func (x *testBidirectionalServer) Send(m *BidirectionalResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *testBidirectionalServer) Recv() (*BidirectionalRequest, error) { - m := new(BidirectionalRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// Test_ServiceDesc is the grpc.ServiceDesc for Test service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Test_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "test.limithandler.Test", - HandlerType: (*TestServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Unary", - Handler: _Test_Unary_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "StreamInput", - Handler: _Test_StreamInput_Handler, - ClientStreams: true, - }, - { - StreamName: "StreamOutput", - Handler: _Test_StreamOutput_Handler, - ServerStreams: true, - }, - { - StreamName: "Bidirectional", - Handler: _Test_Bidirectional_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "middleware/limithandler/testdata/test.proto", -} diff --git a/internal/middleware/limithandler/testhelper_test.go b/internal/middleware/limithandler/testhelper_test.go index 5c5a54b68..1fc996f4c 100644 --- a/internal/middleware/limithandler/testhelper_test.go +++ b/internal/middleware/limithandler/testhelper_test.go @@ -7,11 +7,11 @@ import ( "io" "sync/atomic" - pb "gitlab.com/gitlab-org/gitaly/v15/internal/middleware/limithandler/testdata" + "google.golang.org/grpc/test/grpc_testing" ) type server struct { - pb.UnimplementedTestServer + grpc_testing.UnimplementedTestServiceServer requestCount uint64 blockCh chan struct{} } @@ -24,23 +24,37 @@ func (s *server) getRequestCount() int { return int(atomic.LoadUint64(&s.requestCount)) } -func (s *server) Unary(ctx context.Context, in *pb.UnaryRequest) (*pb.UnaryResponse, error) { +func (s *server) UnaryCall( + ctx context.Context, + in *grpc_testing.SimpleRequest, +) (*grpc_testing.SimpleResponse, error) { s.registerRequest() <-s.blockCh // Block to ensure concurrency - return &pb.UnaryResponse{Ok: true}, nil + return &grpc_testing.SimpleResponse{ + Payload: &grpc_testing.Payload{ + Body: []byte("success"), + }, + }, nil } -func (s *server) StreamOutput(in *pb.StreamOutputRequest, stream pb.Test_StreamOutputServer) error { +func (s *server) StreamingOutputCall( + in *grpc_testing.StreamingOutputCallRequest, + stream grpc_testing.TestService_StreamingOutputCallServer, +) error { s.registerRequest() <-s.blockCh // Block to ensure concurrency - return stream.Send(&pb.StreamOutputResponse{Ok: true}) + return stream.Send(&grpc_testing.StreamingOutputCallResponse{ + Payload: &grpc_testing.Payload{ + Body: []byte("success"), + }, + }) } -func (s *server) StreamInput(stream pb.Test_StreamInputServer) error { +func (s *server) StreamingInputCall(stream grpc_testing.TestService_StreamingInputCallServer) error { // Read all the input for { if _, err := stream.Recv(); err != nil { @@ -55,10 +69,12 @@ func (s *server) StreamInput(stream pb.Test_StreamInputServer) error { <-s.blockCh // Block to ensure concurrency - return stream.SendAndClose(&pb.StreamInputResponse{Ok: true}) + return stream.SendAndClose(&grpc_testing.StreamingInputCallResponse{ + AggregatedPayloadSize: 9000, + }) } -func (s *server) Bidirectional(stream pb.Test_BidirectionalServer) error { +func (s *server) FullDuplexCall(stream grpc_testing.TestService_FullDuplexCallServer) error { // Read all the input for { if _, err := stream.Recv(); err != nil { @@ -73,5 +89,9 @@ func (s *server) Bidirectional(stream pb.Test_BidirectionalServer) error { <-s.blockCh // Block to ensure concurrency - return stream.Send(&pb.BidirectionalResponse{Ok: true}) + return stream.Send(&grpc_testing.StreamingOutputCallResponse{ + Payload: &grpc_testing.Payload{ + Body: []byte("success"), + }, + }) } |