diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | internal/middleware/cache/cache_test.go | 82 | ||||
-rw-r--r-- | internal/middleware/cache/testdata/stream.pb.go | 254 | ||||
-rw-r--r-- | internal/middleware/cache/testdata/stream.proto | 58 | ||||
-rw-r--r-- | internal/middleware/cache/testdata/stream_grpc.pb.go | 453 |
5 files changed, 33 insertions, 816 deletions
@@ -484,8 +484,6 @@ proto: ${PROTOC} ${PROTOC_GEN_GO} ${PROTOC_GEN_GO_GRPC} ${PROTOC_GEN_GITALY_PROT ${Q}rm -f ${SOURCE_DIR}/proto/go/gitalypb/*.pb.go ${PROTOC} ${SHARED_PROTOC_OPTS} -I ${SOURCE_DIR}/proto -I ${PROTOC_INSTALL_DIR}/include --go_out=${SOURCE_DIR}/proto/go/gitalypb --gitaly-protolist_out=proto_dir=${SOURCE_DIR}/proto,gitalypb_dir=${SOURCE_DIR}/proto/go/gitalypb:${SOURCE_DIR} --go-grpc_out=${SOURCE_DIR}/proto/go/gitalypb ${SOURCE_DIR}/proto/*.proto @ # this part is related to the generation of sources from testing proto files - ${PROTOC} ${SHARED_PROTOC_OPTS} -I ${SOURCE_DIR}/proto -I ${SOURCE_DIR}/internal -I ${PROTOC_INSTALL_DIR}/include --go_out=${SOURCE_DIR}/internal --go-grpc_out=${SOURCE_DIR}/internal \ - ${SOURCE_DIR}/internal/middleware/cache/testdata/stream.proto ${PROTOC} ${SHARED_PROTOC_OPTS} -I ${SOURCE_DIR}/proto -I ${SOURCE_DIR}/tools -I ${PROTOC_INSTALL_DIR}/include --go_out=${SOURCE_DIR}/tools --go-grpc_out=${SOURCE_DIR}/tools ${SOURCE_DIR}/tools/protoc-gen-gitaly-lint/testdata/*.proto .PHONY: check-proto diff --git a/internal/middleware/cache/cache_test.go b/internal/middleware/cache/cache_test.go index 1f8a2fb1f..c18f03b03 100644 --- a/internal/middleware/cache/cache_test.go +++ b/internal/middleware/cache/cache_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" diskcache "gitlab.com/gitlab-org/gitaly/v15/internal/cache" - "gitlab.com/gitlab-org/gitaly/v15/internal/middleware/cache/testdata" "gitlab.com/gitlab-org/gitaly/v15/internal/praefect/protoregistry" "gitlab.com/gitlab-org/gitaly/v15/internal/testhelper" "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" @@ -42,20 +41,8 @@ func TestInvalidators(t *testing.T) { { desc: "streaming accessor does not invalidate cache", invokeRPC: func(t *testing.T, conn *grpc.ClientConn) { - stream, err := testdata.NewTestServiceClient(conn).ClientStreamRepoAccessor(ctx, &testdata.Request{ - Destination: repo, - }) - require.NoError(t, err) - - _, err = stream.Recv() - require.Equal(t, err, io.EOF) - }, - }, - { - desc: "streaming maintainer does not invalidate cache", - invokeRPC: func(t *testing.T, conn *grpc.ClientConn) { - stream, err := testdata.NewTestServiceClient(conn).ClientStreamRepoMaintainer(ctx, &testdata.Request{ - Destination: repo, + stream, err := gitalypb.NewRepositoryServiceClient(conn).GetConfig(ctx, &gitalypb.GetConfigRequest{ + Repository: repo, }) require.NoError(t, err) @@ -66,10 +53,11 @@ func TestInvalidators(t *testing.T) { { desc: "streaming mutator invalidates cache", invokeRPC: func(t *testing.T, conn *grpc.ClientConn) { - stream, err := testdata.NewTestServiceClient(conn).ClientStreamRepoMutator(ctx, &testdata.Request{ - Destination: repo, - }) + stream, err := gitalypb.NewSSHServiceClient(conn).SSHReceivePack(ctx) require.NoError(t, err) + require.NoError(t, stream.Send(&gitalypb.SSHReceivePackRequest{ + Repository: repo, + })) _, err = stream.Recv() require.Equal(t, err, io.EOF) @@ -79,8 +67,8 @@ func TestInvalidators(t *testing.T) { { desc: "unary accessor does not invalidate cache", invokeRPC: func(t *testing.T, conn *grpc.ClientConn) { - _, err := testdata.NewTestServiceClient(conn).ClientUnaryRepoAccessor(ctx, &testdata.Request{ - Destination: repo, + _, err := gitalypb.NewRepositoryServiceClient(conn).RepositoryExists(ctx, &gitalypb.RepositoryExistsRequest{ + Repository: repo, }) require.NoError(t, err) }, @@ -88,8 +76,8 @@ func TestInvalidators(t *testing.T) { { desc: "unary maintainer does not invalidate cache", invokeRPC: func(t *testing.T, conn *grpc.ClientConn) { - _, err := testdata.NewTestServiceClient(conn).ClientUnaryRepoMaintainer(ctx, &testdata.Request{ - Destination: repo, + _, err := gitalypb.NewRepositoryServiceClient(conn).OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{ + Repository: repo, }) require.NoError(t, err) }, @@ -97,8 +85,8 @@ func TestInvalidators(t *testing.T) { { desc: "unary mutator invalidates cache", invokeRPC: func(t *testing.T, conn *grpc.ClientConn) { - _, err := testdata.NewTestServiceClient(conn).ClientUnaryRepoMutator(ctx, &testdata.Request{ - Destination: repo, + _, err := gitalypb.NewRepositoryServiceClient(conn).WriteRef(ctx, &gitalypb.WriteRefRequest{ + Repository: repo, }) require.NoError(t, err) }, @@ -116,26 +104,25 @@ func TestInvalidators(t *testing.T) { { desc: "intercepted method does not invalidate cache", invokeRPC: func(t *testing.T, conn *grpc.ClientConn) { - _, err := testdata.NewInterceptedServiceClient(conn).IgnoredMethod(ctx, &testdata.Request{}) + _, err := gitalypb.NewPraefectInfoServiceClient(conn).GetRepositoryMetadata(ctx, &gitalypb.GetRepositoryMetadataRequest{}) require.NoError(t, err) }, }, } { t.Run(tc.desc, func(t *testing.T) { mockCache := newMockCache() - registry, err := protoregistry.NewFromPaths("middleware/cache/testdata/stream.proto") - require.NoError(t, err) server := grpc.NewServer( - grpc.StreamInterceptor(StreamInvalidator(mockCache, registry)), - grpc.UnaryInterceptor(UnaryInvalidator(mockCache, registry)), + grpc.StreamInterceptor(StreamInvalidator(mockCache, protoregistry.GitalyProtoPreregistered)), + grpc.UnaryInterceptor(UnaryInvalidator(mockCache, protoregistry.GitalyProtoPreregistered)), ) service := &testService{ requestCh: make(chan bool, 1), } - testdata.RegisterTestServiceServer(server, service) - testdata.RegisterInterceptedServiceServer(server, service) + gitalypb.RegisterSSHServiceServer(server, service) + gitalypb.RegisterRepositoryServiceServer(server, service) + gitalypb.RegisterPraefectInfoServiceServer(server, service) grpc_health_v1.RegisterHealthServer(server, service) listener, err := net.Listen("tcp", ":0") @@ -200,40 +187,37 @@ func (mc *mockCache) StartLease(repo *gitalypb.Repository) (diskcache.LeaseEnder } type testService struct { - testdata.UnimplementedTestServiceServer - testdata.UnimplementedInterceptedServiceServer + gitalypb.UnimplementedSSHServiceServer + gitalypb.UnimplementedRepositoryServiceServer + gitalypb.UnimplementedPraefectInfoServiceServer grpc_health_v1.UnimplementedHealthServer requestCh chan bool } -func (ts *testService) ClientStreamRepoMutator(*testdata.Request, testdata.TestService_ClientStreamRepoMutatorServer) error { - ts.requestCh <- true - return nil -} - -func (ts *testService) ClientStreamRepoAccessor(*testdata.Request, testdata.TestService_ClientStreamRepoAccessorServer) error { +func (ts *testService) SSHReceivePack(server gitalypb.SSHService_SSHReceivePackServer) error { + _, err := server.Recv() ts.requestCh <- true - return nil + return err } -func (ts *testService) ClientStreamRepoMaintainer(*testdata.Request, testdata.TestService_ClientStreamRepoMaintainerServer) error { +func (ts *testService) GetConfig(*gitalypb.GetConfigRequest, gitalypb.RepositoryService_GetConfigServer) error { ts.requestCh <- true return nil } -func (ts *testService) ClientUnaryRepoMutator(context.Context, *testdata.Request) (*testdata.Response, error) { +func (ts *testService) WriteRef(context.Context, *gitalypb.WriteRefRequest) (*gitalypb.WriteRefResponse, error) { ts.requestCh <- true - return &testdata.Response{}, nil + return &gitalypb.WriteRefResponse{}, nil } -func (ts *testService) ClientUnaryRepoAccessor(context.Context, *testdata.Request) (*testdata.Response, error) { +func (ts *testService) RepositoryExists(context.Context, *gitalypb.RepositoryExistsRequest) (*gitalypb.RepositoryExistsResponse, error) { ts.requestCh <- true - return &testdata.Response{}, nil + return &gitalypb.RepositoryExistsResponse{}, nil } -func (ts *testService) ClientUnaryRepoMaintainer(context.Context, *testdata.Request) (*testdata.Response, error) { +func (ts *testService) OptimizeRepository(context.Context, *gitalypb.OptimizeRepositoryRequest) (*gitalypb.OptimizeRepositoryResponse, error) { ts.requestCh <- true - return &testdata.Response{}, nil + return &gitalypb.OptimizeRepositoryResponse{}, nil } func (ts *testService) Check(context.Context, *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) { @@ -241,7 +225,7 @@ func (ts *testService) Check(context.Context, *grpc_health_v1.HealthCheckRequest return &grpc_health_v1.HealthCheckResponse{}, nil } -func (ts *testService) IgnoredMethod(context.Context, *testdata.Request) (*testdata.Response, error) { +func (ts *testService) GetRepositoryMetadata(context.Context, *gitalypb.GetRepositoryMetadataRequest) (*gitalypb.GetRepositoryMetadataResponse, error) { ts.requestCh <- true - return &testdata.Response{}, nil + return &gitalypb.GetRepositoryMetadataResponse{}, nil } diff --git a/internal/middleware/cache/testdata/stream.pb.go b/internal/middleware/cache/testdata/stream.pb.go deleted file mode 100644 index 4d3102f25..000000000 --- a/internal/middleware/cache/testdata/stream.pb.go +++ /dev/null @@ -1,254 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.7 -// source: middleware/cache/testdata/stream.proto - -package testdata - -import ( - gitalypb "gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb" - 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 Request struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Destination *gitalypb.Repository `protobuf:"bytes,1,opt,name=destination,proto3" json:"destination,omitempty"` -} - -func (x *Request) Reset() { - *x = Request{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_cache_testdata_stream_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Request) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Request) ProtoMessage() {} - -func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_middleware_cache_testdata_stream_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 Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_middleware_cache_testdata_stream_proto_rawDescGZIP(), []int{0} -} - -func (x *Request) GetDestination() *gitalypb.Repository { - if x != nil { - return x.Destination - } - return nil -} - -type Response struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *Response) Reset() { - *x = Response{} - if protoimpl.UnsafeEnabled { - mi := &file_middleware_cache_testdata_stream_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Response) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Response) ProtoMessage() {} - -func (x *Response) ProtoReflect() protoreflect.Message { - mi := &file_middleware_cache_testdata_stream_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 Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_middleware_cache_testdata_stream_proto_rawDescGZIP(), []int{1} -} - -var File_middleware_cache_testdata_stream_proto protoreflect.FileDescriptor - -var file_middleware_cache_testdata_stream_proto_rawDesc = []byte{ - 0x0a, 0x26, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x63, 0x61, 0x63, - 0x68, 0x65, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x73, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, - 0x74, 0x61, 0x1a, 0x0a, 0x6c, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, - 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x07, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3a, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, - 0x69, 0x74, 0x61, 0x6c, 0x79, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x42, 0x04, 0x98, 0xc6, 0x2c, 0x01, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0x0a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, - 0x52, 0x0a, 0x12, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x36, 0x0a, 0x0d, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x64, - 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x11, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, - 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x74, 0x65, 0x73, 0x74, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x04, 0xf0, - 0x97, 0x28, 0x01, 0x32, 0xd4, 0x03, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x17, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x52, 0x65, 0x70, 0x6f, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x11, - 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x12, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x01, 0x30, 0x01, 0x12, - 0x4b, 0x0a, 0x18, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, - 0x65, 0x70, 0x6f, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x12, 0x11, 0x2e, 0x74, 0x65, - 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, - 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x30, 0x01, 0x12, 0x4d, 0x0a, 0x1a, - 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x70, 0x6f, - 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x11, 0x2e, 0x74, 0x65, 0x73, - 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, - 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x03, 0x30, 0x01, 0x12, 0x47, 0x0a, 0x16, 0x43, - 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x4d, 0x75, - 0x74, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x11, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, - 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, - 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, - 0x28, 0x02, 0x08, 0x01, 0x12, 0x48, 0x0a, 0x17, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x6e, - 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6f, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x12, - 0x11, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x02, 0x12, 0x4a, - 0x0a, 0x19, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, - 0x6f, 0x4d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x11, 0x2e, 0x74, 0x65, - 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, - 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x06, 0xfa, 0x97, 0x28, 0x02, 0x08, 0x03, 0x42, 0x45, 0x5a, 0x43, 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, 0x63, 0x61, 0x63, 0x68, 0x65, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, - 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_middleware_cache_testdata_stream_proto_rawDescOnce sync.Once - file_middleware_cache_testdata_stream_proto_rawDescData = file_middleware_cache_testdata_stream_proto_rawDesc -) - -func file_middleware_cache_testdata_stream_proto_rawDescGZIP() []byte { - file_middleware_cache_testdata_stream_proto_rawDescOnce.Do(func() { - file_middleware_cache_testdata_stream_proto_rawDescData = protoimpl.X.CompressGZIP(file_middleware_cache_testdata_stream_proto_rawDescData) - }) - return file_middleware_cache_testdata_stream_proto_rawDescData -} - -var file_middleware_cache_testdata_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_middleware_cache_testdata_stream_proto_goTypes = []interface{}{ - (*Request)(nil), // 0: testdata.Request - (*Response)(nil), // 1: testdata.Response - (*gitalypb.Repository)(nil), // 2: gitaly.Repository -} -var file_middleware_cache_testdata_stream_proto_depIdxs = []int32{ - 2, // 0: testdata.Request.destination:type_name -> gitaly.Repository - 0, // 1: testdata.InterceptedService.IgnoredMethod:input_type -> testdata.Request - 0, // 2: testdata.TestService.ClientStreamRepoMutator:input_type -> testdata.Request - 0, // 3: testdata.TestService.ClientStreamRepoAccessor:input_type -> testdata.Request - 0, // 4: testdata.TestService.ClientStreamRepoMaintainer:input_type -> testdata.Request - 0, // 5: testdata.TestService.ClientUnaryRepoMutator:input_type -> testdata.Request - 0, // 6: testdata.TestService.ClientUnaryRepoAccessor:input_type -> testdata.Request - 0, // 7: testdata.TestService.ClientUnaryRepoMaintainer:input_type -> testdata.Request - 1, // 8: testdata.InterceptedService.IgnoredMethod:output_type -> testdata.Response - 1, // 9: testdata.TestService.ClientStreamRepoMutator:output_type -> testdata.Response - 1, // 10: testdata.TestService.ClientStreamRepoAccessor:output_type -> testdata.Response - 1, // 11: testdata.TestService.ClientStreamRepoMaintainer:output_type -> testdata.Response - 1, // 12: testdata.TestService.ClientUnaryRepoMutator:output_type -> testdata.Response - 1, // 13: testdata.TestService.ClientUnaryRepoAccessor:output_type -> testdata.Response - 1, // 14: testdata.TestService.ClientUnaryRepoMaintainer:output_type -> testdata.Response - 8, // [8:15] is the sub-list for method output_type - 1, // [1:8] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_middleware_cache_testdata_stream_proto_init() } -func file_middleware_cache_testdata_stream_proto_init() { - if File_middleware_cache_testdata_stream_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_middleware_cache_testdata_stream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Request); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_middleware_cache_testdata_stream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Response); 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_cache_testdata_stream_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 2, - }, - GoTypes: file_middleware_cache_testdata_stream_proto_goTypes, - DependencyIndexes: file_middleware_cache_testdata_stream_proto_depIdxs, - MessageInfos: file_middleware_cache_testdata_stream_proto_msgTypes, - }.Build() - File_middleware_cache_testdata_stream_proto = out.File - file_middleware_cache_testdata_stream_proto_rawDesc = nil - file_middleware_cache_testdata_stream_proto_goTypes = nil - file_middleware_cache_testdata_stream_proto_depIdxs = nil -} diff --git a/internal/middleware/cache/testdata/stream.proto b/internal/middleware/cache/testdata/stream.proto deleted file mode 100644 index f9c7cb6ad..000000000 --- a/internal/middleware/cache/testdata/stream.proto +++ /dev/null @@ -1,58 +0,0 @@ -syntax = "proto3"; - -package testdata; - -option go_package = "gitlab.com/gitlab-org/gitaly/v15/internal/middleware/cache/testdata"; - -import "lint.proto"; -import "shared.proto"; - -message Request { - gitaly.Repository destination = 1 [(gitaly.target_repository)=true]; -} - -message Response{} - -service InterceptedService { - option (gitaly.intercepted) = true; - - rpc IgnoredMethod(Request) returns (Response); -} - -service TestService { - rpc ClientStreamRepoMutator(Request) returns (stream Response) { - option (gitaly.op_type) = { - op: MUTATOR - }; - } - - rpc ClientStreamRepoAccessor(Request) returns (stream Response) { - option (gitaly.op_type) = { - op: ACCESSOR - }; - } - - rpc ClientStreamRepoMaintainer(Request) returns (stream Response) { - option (gitaly.op_type) = { - op: MAINTENANCE - }; - } - - rpc ClientUnaryRepoMutator(Request) returns (Response) { - option (gitaly.op_type) = { - op: MUTATOR - }; - } - - rpc ClientUnaryRepoAccessor(Request) returns (Response) { - option (gitaly.op_type) = { - op: ACCESSOR - }; - } - - rpc ClientUnaryRepoMaintainer(Request) returns (Response) { - option (gitaly.op_type) = { - op: MAINTENANCE - }; - } -} diff --git a/internal/middleware/cache/testdata/stream_grpc.pb.go b/internal/middleware/cache/testdata/stream_grpc.pb.go deleted file mode 100644 index 1b2e8c88a..000000000 --- a/internal/middleware/cache/testdata/stream_grpc.pb.go +++ /dev/null @@ -1,453 +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/cache/testdata/stream.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 - -// InterceptedServiceClient is the client API for InterceptedService 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 InterceptedServiceClient interface { - IgnoredMethod(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) -} - -type interceptedServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewInterceptedServiceClient(cc grpc.ClientConnInterface) InterceptedServiceClient { - return &interceptedServiceClient{cc} -} - -func (c *interceptedServiceClient) IgnoredMethod(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := c.cc.Invoke(ctx, "/testdata.InterceptedService/IgnoredMethod", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// InterceptedServiceServer is the server API for InterceptedService service. -// All implementations must embed UnimplementedInterceptedServiceServer -// for forward compatibility -type InterceptedServiceServer interface { - IgnoredMethod(context.Context, *Request) (*Response, error) - mustEmbedUnimplementedInterceptedServiceServer() -} - -// UnimplementedInterceptedServiceServer must be embedded to have forward compatible implementations. -type UnimplementedInterceptedServiceServer struct { -} - -func (UnimplementedInterceptedServiceServer) IgnoredMethod(context.Context, *Request) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method IgnoredMethod not implemented") -} -func (UnimplementedInterceptedServiceServer) mustEmbedUnimplementedInterceptedServiceServer() {} - -// UnsafeInterceptedServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to InterceptedServiceServer will -// result in compilation errors. -type UnsafeInterceptedServiceServer interface { - mustEmbedUnimplementedInterceptedServiceServer() -} - -func RegisterInterceptedServiceServer(s grpc.ServiceRegistrar, srv InterceptedServiceServer) { - s.RegisterService(&InterceptedService_ServiceDesc, srv) -} - -func _InterceptedService_IgnoredMethod_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(InterceptedServiceServer).IgnoredMethod(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/testdata.InterceptedService/IgnoredMethod", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(InterceptedServiceServer).IgnoredMethod(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -// InterceptedService_ServiceDesc is the grpc.ServiceDesc for InterceptedService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var InterceptedService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "testdata.InterceptedService", - HandlerType: (*InterceptedServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "IgnoredMethod", - Handler: _InterceptedService_IgnoredMethod_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "middleware/cache/testdata/stream.proto", -} - -// TestServiceClient is the client API for TestService 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 TestServiceClient interface { - ClientStreamRepoMutator(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_ClientStreamRepoMutatorClient, error) - ClientStreamRepoAccessor(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_ClientStreamRepoAccessorClient, error) - ClientStreamRepoMaintainer(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_ClientStreamRepoMaintainerClient, error) - ClientUnaryRepoMutator(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) - ClientUnaryRepoAccessor(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) - ClientUnaryRepoMaintainer(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) -} - -type testServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient { - return &testServiceClient{cc} -} - -func (c *testServiceClient) ClientStreamRepoMutator(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_ClientStreamRepoMutatorClient, error) { - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[0], "/testdata.TestService/ClientStreamRepoMutator", opts...) - if err != nil { - return nil, err - } - x := &testServiceClientStreamRepoMutatorClient{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 TestService_ClientStreamRepoMutatorClient interface { - Recv() (*Response, error) - grpc.ClientStream -} - -type testServiceClientStreamRepoMutatorClient struct { - grpc.ClientStream -} - -func (x *testServiceClientStreamRepoMutatorClient) Recv() (*Response, error) { - m := new(Response) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *testServiceClient) ClientStreamRepoAccessor(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_ClientStreamRepoAccessorClient, error) { - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[1], "/testdata.TestService/ClientStreamRepoAccessor", opts...) - if err != nil { - return nil, err - } - x := &testServiceClientStreamRepoAccessorClient{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 TestService_ClientStreamRepoAccessorClient interface { - Recv() (*Response, error) - grpc.ClientStream -} - -type testServiceClientStreamRepoAccessorClient struct { - grpc.ClientStream -} - -func (x *testServiceClientStreamRepoAccessorClient) Recv() (*Response, error) { - m := new(Response) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *testServiceClient) ClientStreamRepoMaintainer(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_ClientStreamRepoMaintainerClient, error) { - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[2], "/testdata.TestService/ClientStreamRepoMaintainer", opts...) - if err != nil { - return nil, err - } - x := &testServiceClientStreamRepoMaintainerClient{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 TestService_ClientStreamRepoMaintainerClient interface { - Recv() (*Response, error) - grpc.ClientStream -} - -type testServiceClientStreamRepoMaintainerClient struct { - grpc.ClientStream -} - -func (x *testServiceClientStreamRepoMaintainerClient) Recv() (*Response, error) { - m := new(Response) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *testServiceClient) ClientUnaryRepoMutator(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := c.cc.Invoke(ctx, "/testdata.TestService/ClientUnaryRepoMutator", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *testServiceClient) ClientUnaryRepoAccessor(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := c.cc.Invoke(ctx, "/testdata.TestService/ClientUnaryRepoAccessor", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *testServiceClient) ClientUnaryRepoMaintainer(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := c.cc.Invoke(ctx, "/testdata.TestService/ClientUnaryRepoMaintainer", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// TestServiceServer is the server API for TestService service. -// All implementations must embed UnimplementedTestServiceServer -// for forward compatibility -type TestServiceServer interface { - ClientStreamRepoMutator(*Request, TestService_ClientStreamRepoMutatorServer) error - ClientStreamRepoAccessor(*Request, TestService_ClientStreamRepoAccessorServer) error - ClientStreamRepoMaintainer(*Request, TestService_ClientStreamRepoMaintainerServer) error - ClientUnaryRepoMutator(context.Context, *Request) (*Response, error) - ClientUnaryRepoAccessor(context.Context, *Request) (*Response, error) - ClientUnaryRepoMaintainer(context.Context, *Request) (*Response, error) - mustEmbedUnimplementedTestServiceServer() -} - -// UnimplementedTestServiceServer must be embedded to have forward compatible implementations. -type UnimplementedTestServiceServer struct { -} - -func (UnimplementedTestServiceServer) ClientStreamRepoMutator(*Request, TestService_ClientStreamRepoMutatorServer) error { - return status.Errorf(codes.Unimplemented, "method ClientStreamRepoMutator not implemented") -} -func (UnimplementedTestServiceServer) ClientStreamRepoAccessor(*Request, TestService_ClientStreamRepoAccessorServer) error { - return status.Errorf(codes.Unimplemented, "method ClientStreamRepoAccessor not implemented") -} -func (UnimplementedTestServiceServer) ClientStreamRepoMaintainer(*Request, TestService_ClientStreamRepoMaintainerServer) error { - return status.Errorf(codes.Unimplemented, "method ClientStreamRepoMaintainer not implemented") -} -func (UnimplementedTestServiceServer) ClientUnaryRepoMutator(context.Context, *Request) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method ClientUnaryRepoMutator not implemented") -} -func (UnimplementedTestServiceServer) ClientUnaryRepoAccessor(context.Context, *Request) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method ClientUnaryRepoAccessor not implemented") -} -func (UnimplementedTestServiceServer) ClientUnaryRepoMaintainer(context.Context, *Request) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method ClientUnaryRepoMaintainer not implemented") -} -func (UnimplementedTestServiceServer) mustEmbedUnimplementedTestServiceServer() {} - -// UnsafeTestServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to TestServiceServer will -// result in compilation errors. -type UnsafeTestServiceServer interface { - mustEmbedUnimplementedTestServiceServer() -} - -func RegisterTestServiceServer(s grpc.ServiceRegistrar, srv TestServiceServer) { - s.RegisterService(&TestService_ServiceDesc, srv) -} - -func _TestService_ClientStreamRepoMutator_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Request) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(TestServiceServer).ClientStreamRepoMutator(m, &testServiceClientStreamRepoMutatorServer{stream}) -} - -type TestService_ClientStreamRepoMutatorServer interface { - Send(*Response) error - grpc.ServerStream -} - -type testServiceClientStreamRepoMutatorServer struct { - grpc.ServerStream -} - -func (x *testServiceClientStreamRepoMutatorServer) Send(m *Response) error { - return x.ServerStream.SendMsg(m) -} - -func _TestService_ClientStreamRepoAccessor_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Request) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(TestServiceServer).ClientStreamRepoAccessor(m, &testServiceClientStreamRepoAccessorServer{stream}) -} - -type TestService_ClientStreamRepoAccessorServer interface { - Send(*Response) error - grpc.ServerStream -} - -type testServiceClientStreamRepoAccessorServer struct { - grpc.ServerStream -} - -func (x *testServiceClientStreamRepoAccessorServer) Send(m *Response) error { - return x.ServerStream.SendMsg(m) -} - -func _TestService_ClientStreamRepoMaintainer_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Request) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(TestServiceServer).ClientStreamRepoMaintainer(m, &testServiceClientStreamRepoMaintainerServer{stream}) -} - -type TestService_ClientStreamRepoMaintainerServer interface { - Send(*Response) error - grpc.ServerStream -} - -type testServiceClientStreamRepoMaintainerServer struct { - grpc.ServerStream -} - -func (x *testServiceClientStreamRepoMaintainerServer) Send(m *Response) error { - return x.ServerStream.SendMsg(m) -} - -func _TestService_ClientUnaryRepoMutator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServiceServer).ClientUnaryRepoMutator(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/testdata.TestService/ClientUnaryRepoMutator", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServiceServer).ClientUnaryRepoMutator(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -func _TestService_ClientUnaryRepoAccessor_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServiceServer).ClientUnaryRepoAccessor(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/testdata.TestService/ClientUnaryRepoAccessor", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServiceServer).ClientUnaryRepoAccessor(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -func _TestService_ClientUnaryRepoMaintainer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServiceServer).ClientUnaryRepoMaintainer(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/testdata.TestService/ClientUnaryRepoMaintainer", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServiceServer).ClientUnaryRepoMaintainer(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -// TestService_ServiceDesc is the grpc.ServiceDesc for TestService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var TestService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "testdata.TestService", - HandlerType: (*TestServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ClientUnaryRepoMutator", - Handler: _TestService_ClientUnaryRepoMutator_Handler, - }, - { - MethodName: "ClientUnaryRepoAccessor", - Handler: _TestService_ClientUnaryRepoAccessor_Handler, - }, - { - MethodName: "ClientUnaryRepoMaintainer", - Handler: _TestService_ClientUnaryRepoMaintainer_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "ClientStreamRepoMutator", - Handler: _TestService_ClientStreamRepoMutator_Handler, - ServerStreams: true, - }, - { - StreamName: "ClientStreamRepoAccessor", - Handler: _TestService_ClientStreamRepoAccessor_Handler, - ServerStreams: true, - }, - { - StreamName: "ClientStreamRepoMaintainer", - Handler: _TestService_ClientStreamRepoMaintainer_Handler, - ServerStreams: true, - }, - }, - Metadata: "middleware/cache/testdata/stream.proto", -} |