From c5292a34519639791c8284437ec27d09ec5f39bf Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 12 Jul 2018 15:32:25 +0200 Subject: [PATCH 1/2] Remove implementation of Notifications::PostReceive --- .../service/notifications/post_receive.go | 19 ----- .../notifications/post_receive_test.go | 81 ------------------- internal/service/notifications/server.go | 10 --- internal/service/register.go | 2 - 4 files changed, 112 deletions(-) delete mode 100644 internal/service/notifications/post_receive.go delete mode 100644 internal/service/notifications/post_receive_test.go delete mode 100644 internal/service/notifications/server.go diff --git a/internal/service/notifications/post_receive.go b/internal/service/notifications/post_receive.go deleted file mode 100644 index dbda7492c9..0000000000 --- a/internal/service/notifications/post_receive.go +++ /dev/null @@ -1,19 +0,0 @@ -package notifications - -import ( - "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "gitlab.com/gitlab-org/gitaly/internal/helper" - "golang.org/x/net/context" -) - -func (s *server) PostReceive(ctx context.Context, in *pb.PostReceiveRequest) (*pb.PostReceiveResponse, error) { - _, err := helper.GetRepoPath(in.GetRepository()) - if err != nil { - return nil, err - } - - grpc_logrus.Extract(ctx).Debug("PostReceive") - - return &pb.PostReceiveResponse{}, nil -} diff --git a/internal/service/notifications/post_receive_test.go b/internal/service/notifications/post_receive_test.go deleted file mode 100644 index 5e77f9f208..0000000000 --- a/internal/service/notifications/post_receive_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package notifications - -import ( - "context" - "net" - "testing" - "time" - - "gitlab.com/gitlab-org/gitaly/internal/testhelper" - - pb "gitlab.com/gitlab-org/gitaly-proto/go" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/reflection" -) - -func TestSuccessfulPostReceive(t *testing.T) { - server, serverSocketPath := runNotificationsServer(t) - defer server.Stop() - - client, conn := newNotificationsClient(t, serverSocketPath) - defer conn.Close() - - testRepo, _, cleanupFn := testhelper.NewTestRepo(t) - defer cleanupFn() - - rpcRequest := &pb.PostReceiveRequest{Repository: testRepo} - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - _, err := client.PostReceive(ctx, rpcRequest) - if err != nil { - t.Fatal(err) - } -} - -func TestEmptyPostReceiveRequest(t *testing.T) { - server, serverSocketPath := runNotificationsServer(t) - defer server.Stop() - - client, conn := newNotificationsClient(t, serverSocketPath) - defer conn.Close() - rpcRequest := &pb.PostReceiveRequest{} - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - _, err := client.PostReceive(ctx, rpcRequest) - testhelper.RequireGrpcError(t, err, codes.InvalidArgument) -} - -func runNotificationsServer(t *testing.T) (*grpc.Server, string) { - server := testhelper.NewTestGrpcServer(t, nil, nil) - - serverSocketPath := testhelper.GetTemporaryGitalySocketFileName() - listener, err := net.Listen("unix", serverSocketPath) - if err != nil { - t.Fatal(err) - } - - pb.RegisterNotificationsServer(server, NewServer()) - reflection.Register(server) - - go server.Serve(listener) - - return server, serverSocketPath -} - -func newNotificationsClient(t *testing.T, serverSocketPath string) (pb.NotificationsClient, *grpc.ClientConn) { - connOpts := []grpc.DialOption{ - grpc.WithInsecure(), - grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { - return net.DialTimeout("unix", addr, timeout) - }), - } - conn, err := grpc.Dial(serverSocketPath, connOpts...) - if err != nil { - t.Fatal(err) - } - - return pb.NewNotificationsClient(conn), conn -} diff --git a/internal/service/notifications/server.go b/internal/service/notifications/server.go deleted file mode 100644 index ace7cdd079..0000000000 --- a/internal/service/notifications/server.go +++ /dev/null @@ -1,10 +0,0 @@ -package notifications - -import pb "gitlab.com/gitlab-org/gitaly-proto/go" - -type server struct{} - -// NewServer creates a new instance of a grpc NotificationsServer -func NewServer() pb.NotificationServiceServer { - return &server{} -} diff --git a/internal/service/register.go b/internal/service/register.go index 35db56c2ef..2e5bba4ceb 100644 --- a/internal/service/register.go +++ b/internal/service/register.go @@ -8,7 +8,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/service/conflicts" "gitlab.com/gitlab-org/gitaly/internal/service/diff" "gitlab.com/gitlab-org/gitaly/internal/service/namespace" - "gitlab.com/gitlab-org/gitaly/internal/service/notifications" "gitlab.com/gitlab-org/gitaly/internal/service/operations" "gitlab.com/gitlab-org/gitaly/internal/service/ref" "gitlab.com/gitlab-org/gitaly/internal/service/remote" @@ -31,7 +30,6 @@ func RegisterAll(grpcServer *grpc.Server, rubyServer *rubyserver.Server) { pb.RegisterCommitServiceServer(grpcServer, commit.NewServer(rubyServer)) pb.RegisterDiffServiceServer(grpcServer, diff.NewServer(rubyServer)) pb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer()) - pb.RegisterNotificationServiceServer(grpcServer, notifications.NewServer()) pb.RegisterOperationServiceServer(grpcServer, operations.NewServer(rubyServer)) pb.RegisterRefServiceServer(grpcServer, ref.NewServer(rubyServer)) pb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(rubyServer)) -- GitLab From 1c0add2dd07337adb9ccdf8f4af40d6f657ea50b Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 12 Jul 2018 15:33:39 +0200 Subject: [PATCH 2/2] changelog --- changelogs/unreleased/remove-postreceive.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/remove-postreceive.yml diff --git a/changelogs/unreleased/remove-postreceive.yml b/changelogs/unreleased/remove-postreceive.yml new file mode 100644 index 0000000000..dbd64daa39 --- /dev/null +++ b/changelogs/unreleased/remove-postreceive.yml @@ -0,0 +1,5 @@ +--- +title: Remove implementation of Notifications::PostReceive +merge_request: 806 +author: +type: removed -- GitLab