Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2020-03-20 17:26:18 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-03-20 17:26:18 +0300
commite5a36f23ce83b498ae4f125f49c9539fcf776ede (patch)
tree04b04c2164a25f719a38956c858c4057c7b3710a
parent7c9923ff9202b3ad8f5629169748955a73c24145 (diff)
parent06b7b615a063867b26eed503553233e47aa6faad (diff)
Merge branch 'jc-praefect-test-some-services' into 'master'
Praefect test some services See merge request gitlab-org/gitaly!1932
-rw-r--r--internal/praefect/coordinator.go13
-rw-r--r--internal/service/cleanup/apply_bfg_object_map_stream_test.go8
-rw-r--r--internal/service/cleanup/testhelper_test.go20
-rw-r--r--internal/service/conflicts/list_conflict_files_test.go12
-rw-r--r--internal/service/conflicts/testhelper_test.go20
-rw-r--r--internal/service/hooks/post_receive_test.go8
-rw-r--r--internal/service/hooks/pre_receive_test.go8
-rw-r--r--internal/service/hooks/testhelper_test.go24
-rw-r--r--internal/service/hooks/update_test.go8
-rw-r--r--internal/service/operations/branches_test.go32
-rw-r--r--internal/service/operations/merge_test.go40
-rw-r--r--internal/service/operations/squash_test.go24
-rw-r--r--internal/service/operations/submodules_test.go24
-rw-r--r--internal/service/operations/tags_test.go36
-rw-r--r--internal/service/operations/testhelper_test.go20
-rw-r--r--internal/service/operations/update_branches_test.go16
-rw-r--r--internal/service/ref/branches_test.go8
-rw-r--r--internal/service/ref/delete_refs_test.go12
-rw-r--r--internal/service/ref/list_new_blobs_test.go4
-rw-r--r--internal/service/ref/list_new_commits_test.go4
-rw-r--r--internal/service/ref/pack_refs_test.go4
-rw-r--r--internal/service/ref/refexists_test.go4
-rw-r--r--internal/service/ref/refname_test.go20
-rw-r--r--internal/service/ref/refs_test.go96
-rw-r--r--internal/service/ref/remote_branches_test.go8
-rw-r--r--internal/service/ref/tag_messages_test.go8
-rw-r--r--internal/service/ref/testhelper_test.go19
-rw-r--r--internal/service/remote/find_remote_root_ref_test.go12
-rw-r--r--internal/service/remote/remotes_test.go32
-rw-r--r--internal/service/remote/testhelper_test.go20
-rw-r--r--internal/service/remote/update_remote_mirror_test.go16
-rw-r--r--internal/service/smarthttp/inforefs_test.go36
-rw-r--r--internal/service/smarthttp/receive_pack_test.go24
-rw-r--r--internal/service/smarthttp/testhelper_test.go20
-rw-r--r--internal/service/smarthttp/upload_pack_test.go24
-rw-r--r--internal/service/ssh/receive_pack_test.go28
-rw-r--r--internal/service/ssh/testhelper_test.go20
-rw-r--r--internal/service/ssh/upload_archive_test.go12
-rw-r--r--internal/service/ssh/upload_pack_test.go29
-rw-r--r--internal/service/wiki/delete_page_test.go8
-rw-r--r--internal/service/wiki/find_file_test.go8
-rw-r--r--internal/service/wiki/find_page_test.go16
-rw-r--r--internal/service/wiki/get_all_pages_test.go12
-rw-r--r--internal/service/wiki/get_page_versions_test.go8
-rw-r--r--internal/service/wiki/list_pages_test.go8
-rw-r--r--internal/service/wiki/testhelper_test.go19
-rw-r--r--internal/service/wiki/update_page_test.go8
-rw-r--r--internal/service/wiki/write_page_test.go16
48 files changed, 404 insertions, 472 deletions
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index 92633c7ff..8c97df7a6 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -59,10 +59,7 @@ func NewCoordinator(l logrus.FieldLogger, ds datastore.Datastore, nodeMgr nodes.
func (c *Coordinator) directRepositoryScopedMessage(ctx context.Context, mi protoregistry.MethodInfo, peeker proxy.StreamModifier, fullMethodName string, m proto.Message) (*proxy.StreamParameters, error) {
targetRepo, err := mi.TargetRepo(m)
if err != nil {
- if err == protoregistry.ErrTargetRepoMissing {
- return nil, helper.ErrInvalidArgument(err)
- }
- return nil, err
+ return nil, helper.ErrInvalidArgument(err)
}
if targetRepo.StorageName == "" || targetRepo.RelativePath == "" {
@@ -83,10 +80,6 @@ func (c *Coordinator) directRepositoryScopedMessage(ctx context.Context, mi prot
}
if err = c.rewriteStorageForRepositoryMessage(mi, m, peeker, primary.GetStorage()); err != nil {
- if err == protoregistry.ErrTargetRepoMissing {
- return nil, helper.ErrInvalidArgument(err)
- }
-
return nil, err
}
@@ -153,7 +146,7 @@ func (c *Coordinator) StreamDirector(ctx context.Context, fullMethodName string,
func (c *Coordinator) rewriteStorageForRepositoryMessage(mi protoregistry.MethodInfo, m proto.Message, peeker proxy.StreamModifier, primaryStorage string) error {
targetRepo, err := mi.TargetRepo(m)
if err != nil {
- return err
+ return helper.ErrInvalidArgument(err)
}
// rewrite storage name
@@ -161,7 +154,7 @@ func (c *Coordinator) rewriteStorageForRepositoryMessage(mi protoregistry.Method
additionalRepo, ok, err := mi.AdditionalRepo(m)
if err != nil {
- return err
+ return helper.ErrInvalidArgument(err)
}
if ok {
diff --git a/internal/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/service/cleanup/apply_bfg_object_map_stream_test.go
index 9eb19da78..2a004b905 100644
--- a/internal/service/cleanup/apply_bfg_object_map_stream_test.go
+++ b/internal/service/cleanup/apply_bfg_object_map_stream_test.go
@@ -17,8 +17,8 @@ import (
)
func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
- server, serverSocketPath := runCleanupServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runCleanupServiceServer(t)
+ defer stop()
client, conn := newCleanupServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -81,8 +81,8 @@ func requireEntry(t *testing.T, entry *gitalypb.ApplyBfgObjectMapStreamResponse_
}
func TestApplyBfgObjectMapStreamFailsOnInvalidInput(t *testing.T) {
- server, serverSocketPath := runCleanupServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runCleanupServiceServer(t)
+ defer stop()
client, conn := newCleanupServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/cleanup/testhelper_test.go b/internal/service/cleanup/testhelper_test.go
index 1ad6230f2..112153ab8 100644
--- a/internal/service/cleanup/testhelper_test.go
+++ b/internal/service/cleanup/testhelper_test.go
@@ -1,30 +1,24 @@
package cleanup
import (
- "net"
"testing"
+ "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
-func runCleanupServiceServer(t *testing.T) (*grpc.Server, string) {
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
- grpcServer := testhelper.NewTestGrpcServer(t, nil, nil)
+func runCleanupServiceServer(t *testing.T) (string, func()) {
+ srv := testhelper.NewServer(t, nil, nil)
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterCleanupServiceServer(grpcServer, NewServer())
- reflection.Register(grpcServer)
+ gitalypb.RegisterCleanupServiceServer(srv.GrpcServer(), NewServer())
+ reflection.Register(srv.GrpcServer())
- go grpcServer.Serve(listener)
+ require.NoError(t, srv.Start())
- return grpcServer, "unix://" + serverSocketPath
+ return "unix://" + srv.Socket(), srv.Stop
}
func newCleanupServiceClient(t *testing.T, serverSocketPath string) (gitalypb.CleanupServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/conflicts/list_conflict_files_test.go b/internal/service/conflicts/list_conflict_files_test.go
index 074234caa..b384f8b8c 100644
--- a/internal/service/conflicts/list_conflict_files_test.go
+++ b/internal/service/conflicts/list_conflict_files_test.go
@@ -17,8 +17,8 @@ type conflictFile struct {
}
func TestSuccessfulListConflictFilesRequest(t *testing.T) {
- server, serverSocketPath := runConflictsServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runConflictsServer(t)
+ defer stop()
client, conn := NewConflictsClient(t, serverSocketPath)
defer conn.Close()
@@ -93,8 +93,8 @@ end
}
func TestListConflictFilesFailedPrecondition(t *testing.T) {
- server, serverSocketPath := runConflictsServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runConflictsServer(t)
+ defer stop()
client, conn := NewConflictsClient(t, serverSocketPath)
defer conn.Close()
@@ -158,8 +158,8 @@ func TestListConflictFilesFailedPrecondition(t *testing.T) {
}
func TestFailedListConflictFilesRequestDueToValidation(t *testing.T) {
- server, serverSocketPath := runConflictsServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runConflictsServer(t)
+ defer stop()
client, conn := NewConflictsClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/conflicts/testhelper_test.go b/internal/service/conflicts/testhelper_test.go
index f2a05721d..2b956b0fb 100644
--- a/internal/service/conflicts/testhelper_test.go
+++ b/internal/service/conflicts/testhelper_test.go
@@ -2,11 +2,11 @@ package conflicts
import (
"io/ioutil"
- "net"
"os"
"testing"
log "github.com/sirupsen/logrus"
+ "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git/hooks"
"gitlab.com/gitlab-org/gitaly/internal/rubyserver"
@@ -42,21 +42,15 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func runConflictsServer(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, nil, nil)
+func runConflictsServer(t *testing.T) (string, func()) {
+ srv := testhelper.NewServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterConflictsServiceServer(server, NewServer(RubyServer))
- reflection.Register(server)
+ gitalypb.RegisterConflictsServiceServer(srv.GrpcServer(), NewServer(RubyServer))
+ reflection.Register(srv.GrpcServer())
- go server.Serve(listener)
+ require.NoError(t, srv.Start())
- return server, "unix://" + serverSocketPath
+ return "unix://" + srv.Socket(), srv.Stop
}
func NewConflictsClient(t *testing.T, serverSocketPath string) (gitalypb.ConflictsServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/hooks/post_receive_test.go b/internal/service/hooks/post_receive_test.go
index 1dfee6948..a85128967 100644
--- a/internal/service/hooks/post_receive_test.go
+++ b/internal/service/hooks/post_receive_test.go
@@ -18,8 +18,8 @@ import (
)
func TestPostReceiveInvalidArgument(t *testing.T) {
- server, serverSocketPath := runHooksServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runHooksServer(t)
+ defer stop()
client, conn := newHooksClient(t, serverSocketPath)
defer conn.Close()
@@ -45,8 +45,8 @@ func TestPostReceive(t *testing.T) {
require.NoError(t, err)
config.Config.Ruby.Dir = filepath.Join(cwd, "testdata")
- server, serverSocketPath := runHooksServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runHooksServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
diff --git a/internal/service/hooks/pre_receive_test.go b/internal/service/hooks/pre_receive_test.go
index 08af19aee..8b2d5c943 100644
--- a/internal/service/hooks/pre_receive_test.go
+++ b/internal/service/hooks/pre_receive_test.go
@@ -18,8 +18,8 @@ import (
)
func TestPreReceiveInvalidArgument(t *testing.T) {
- server, serverSocketPath := runHooksServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runHooksServer(t)
+ defer stop()
client, conn := newHooksClient(t, serverSocketPath)
defer conn.Close()
@@ -45,8 +45,8 @@ func TestPreReceive(t *testing.T) {
require.NoError(t, err)
config.Config.Ruby.Dir = filepath.Join(cwd, "testdata")
- server, serverSocketPath := runHooksServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runHooksServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
diff --git a/internal/service/hooks/testhelper_test.go b/internal/service/hooks/testhelper_test.go
index 72367ac75..2d72ba16c 100644
--- a/internal/service/hooks/testhelper_test.go
+++ b/internal/service/hooks/testhelper_test.go
@@ -1,12 +1,11 @@
package hook
import (
- "net"
"testing"
+ "github.com/stretchr/testify/require"
gitalyauth "gitlab.com/gitlab-org/gitaly/auth"
"gitlab.com/gitlab-org/gitaly/internal/config"
- "gitlab.com/gitlab-org/gitaly/internal/server/auth"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -26,22 +25,13 @@ func newHooksClient(t *testing.T, serverSocketPath string) (gitalypb.HookService
return gitalypb.NewHookServiceClient(conn), conn
}
-func runHooksServer(t *testing.T) (*grpc.Server, string) {
- streamInt := []grpc.StreamServerInterceptor{auth.StreamServerInterceptor(config.Config.Auth)}
- unaryInt := []grpc.UnaryServerInterceptor{auth.UnaryServerInterceptor(config.Config.Auth)}
+func runHooksServer(t *testing.T) (string, func()) {
+ srv := testhelper.NewServer(t, nil, nil)
- server := testhelper.NewTestGrpcServer(t, streamInt, unaryInt)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
+ gitalypb.RegisterHookServiceServer(srv.GrpcServer(), NewServer())
+ reflection.Register(srv.GrpcServer())
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterHookServiceServer(server, NewServer())
- reflection.Register(server)
-
- go server.Serve(listener)
+ require.NoError(t, srv.Start())
- return server, "unix://" + serverSocketPath
+ return "unix://" + srv.Socket(), srv.Stop
}
diff --git a/internal/service/hooks/update_test.go b/internal/service/hooks/update_test.go
index 7319be1b6..0a581f4fe 100644
--- a/internal/service/hooks/update_test.go
+++ b/internal/service/hooks/update_test.go
@@ -17,8 +17,8 @@ import (
)
func TestUpdateInvalidArgument(t *testing.T) {
- server, serverSocketPath := runHooksServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runHooksServer(t)
+ defer stop()
client, conn := newHooksClient(t, serverSocketPath)
defer conn.Close()
@@ -43,8 +43,8 @@ func TestUpdate(t *testing.T) {
require.NoError(t, err)
config.Config.Ruby.Dir = filepath.Join(cwd, "testdata")
- server, serverSocketPath := runHooksServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runHooksServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
diff --git a/internal/service/operations/branches_test.go b/internal/service/operations/branches_test.go
index c377d4a09..28f7c1524 100644
--- a/internal/service/operations/branches_test.go
+++ b/internal/service/operations/branches_test.go
@@ -19,8 +19,8 @@ func TestSuccessfulUserCreateBranchRequest(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -84,8 +84,8 @@ func TestSuccessfulGitHooksForUserCreateBranchRequest(t *testing.T) {
cleanupSrv := SetupAndStartGitlabServer(t, user.GlId, testRepo.GlRepository)
defer cleanupSrv()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -125,8 +125,8 @@ func TestFailedUserCreateBranchDueToHooks(t *testing.T) {
cleanupSrv := SetupAndStartGitlabServer(t, user.GlId, testRepo.GlRepository)
defer cleanupSrv()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -156,8 +156,8 @@ func TestFailedUserCreateBranchDueToHooks(t *testing.T) {
}
func TestFailedUserCreateBranchRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -231,8 +231,8 @@ func TestSuccessfulUserDeleteBranchRequest(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -269,8 +269,8 @@ func TestSuccessfulGitHooksForUserDeleteBranchRequest(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -314,8 +314,8 @@ func TestSuccessfulGitHooksForUserDeleteBranchRequest(t *testing.T) {
}
func TestFailedUserDeleteBranchDueToValidation(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -376,8 +376,8 @@ func TestFailedUserDeleteBranchDueToHooks(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/operations/merge_test.go b/internal/service/operations/merge_test.go
index 51d9e0709..52da5d0b5 100644
--- a/internal/service/operations/merge_test.go
+++ b/internal/service/operations/merge_test.go
@@ -35,8 +35,8 @@ func TestSuccessfulMerge(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -111,8 +111,8 @@ func TestAbortedMerge(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -182,8 +182,8 @@ func TestFailedMergeConcurrentUpdate(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -226,8 +226,8 @@ func TestFailedMergeDueToHooks(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -288,8 +288,8 @@ func TestSuccessfulUserFFBranchRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -327,8 +327,8 @@ func TestSuccessfulUserFFBranchRequest(t *testing.T) {
}
func TestFailedUserFFBranchRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -422,8 +422,8 @@ func TestFailedUserFFBranchRequest(t *testing.T) {
}
func TestFailedUserFFBranchDueToHooks(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -465,8 +465,8 @@ func TestFailedUserFFBranchDueToHooks(t *testing.T) {
}
func TestSuccessfulUserMergeToRefRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -574,8 +574,8 @@ func TestSuccessfulUserMergeToRefRequest(t *testing.T) {
}
func TestFailedUserMergeToRefRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -676,8 +676,8 @@ func TestFailedUserMergeToRefRequest(t *testing.T) {
}
func TestUserMergeToRefIgnoreHooksRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/operations/squash_test.go b/internal/service/operations/squash_test.go
index 7115f7977..a7ca7752d 100644
--- a/internal/service/operations/squash_test.go
+++ b/internal/service/operations/squash_test.go
@@ -30,8 +30,8 @@ func TestSuccessfulUserSquashRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -80,8 +80,8 @@ func TestSuccessfulUserSquashRequestWith3wayMerge(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -128,8 +128,8 @@ func TestSplitIndex(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -159,8 +159,8 @@ func TestSquashRequestWithRenamedFiles(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -221,8 +221,8 @@ func TestSuccessfulUserSquashRequestWithMissingFileOnTargetBranch(t *testing.T)
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -248,8 +248,8 @@ func TestSuccessfulUserSquashRequestWithMissingFileOnTargetBranch(t *testing.T)
}
func TestFailedUserSquashRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/operations/submodules_test.go b/internal/service/operations/submodules_test.go
index 71e81b13f..d85632567 100644
--- a/internal/service/operations/submodules_test.go
+++ b/internal/service/operations/submodules_test.go
@@ -14,8 +14,8 @@ import (
)
func TestSuccessfulUserUpdateSubmoduleRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -84,8 +84,8 @@ func TestSuccessfulUserUpdateSubmoduleRequest(t *testing.T) {
}
func TestFailedUserUpdateSubmoduleRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -212,8 +212,8 @@ func TestFailedUserUpdateSubmoduleRequestDueToInvalidBranch(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -239,8 +239,8 @@ func TestFailedUserUpdateSubmoduleRequestDueToInvalidSubmodule(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -266,8 +266,8 @@ func TestFailedUserUpdateSubmoduleRequestDueToSameReference(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -299,8 +299,8 @@ func TestFailedUserUpdateSubmoduleRequestDueToRepositoryEmpty(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := NewOperationClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/operations/tags_test.go b/internal/service/operations/tags_test.go
index ec47dad02..fdc469233 100644
--- a/internal/service/operations/tags_test.go
+++ b/internal/service/operations/tags_test.go
@@ -16,8 +16,8 @@ func TestSuccessfulUserDeleteTagRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -54,8 +54,8 @@ func TestSuccessfulUserDeleteTagRequest(t *testing.T) {
}
func TestSuccessfulGitHooksForUserDeleteTagRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -105,8 +105,8 @@ func TestSuccessfulUserCreateTagRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -188,8 +188,8 @@ func TestSuccessfulUserCreateTagRequest(t *testing.T) {
}
func TestSuccessfulGitHooksForUserCreateTagRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -236,8 +236,8 @@ func TestSuccessfulGitHooksForUserCreateTagRequest(t *testing.T) {
}
func TestFailedUserDeleteTagRequestDueToValidation(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -295,8 +295,8 @@ func TestFailedUserDeleteTagRequestDueToValidation(t *testing.T) {
}
func TestFailedUserDeleteTagDueToHooks(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -345,8 +345,8 @@ func TestFailedUserDeleteTagDueToHooks(t *testing.T) {
}
func TestFailedUserCreateTagDueToHooks(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -388,8 +388,8 @@ func TestFailedUserCreateTagDueToHooks(t *testing.T) {
}
func TestFailedUserCreateTagRequestDueToTagExistence(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -432,8 +432,8 @@ func TestFailedUserCreateTagRequestDueToTagExistence(t *testing.T) {
}
func TestFailedUserCreateTagRequestDueToValidation(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/operations/testhelper_test.go b/internal/service/operations/testhelper_test.go
index 56d48ab56..07e23662c 100644
--- a/internal/service/operations/testhelper_test.go
+++ b/internal/service/operations/testhelper_test.go
@@ -1,12 +1,12 @@
package operations
import (
- "net"
"os"
"path/filepath"
"testing"
log "github.com/sirupsen/logrus"
+ "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/rubyserver"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -64,21 +64,15 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func runOperationServiceServer(t *testing.T) (*grpc.Server, string) {
- grpcServer := testhelper.NewTestGrpcServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
+func runOperationServiceServer(t *testing.T) (string, func()) {
+ srv := testhelper.NewServer(t, nil, nil)
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterOperationServiceServer(grpcServer, &server{ruby: RubyServer})
- reflection.Register(grpcServer)
+ gitalypb.RegisterOperationServiceServer(srv.GrpcServer(), &server{ruby: RubyServer})
+ reflection.Register(srv.GrpcServer())
- go grpcServer.Serve(listener)
+ require.NoError(t, srv.Start())
- return grpcServer, "unix://" + serverSocketPath
+ return "unix://" + srv.Socket(), srv.Stop
}
func newOperationClient(t *testing.T, serverSocketPath string) (gitalypb.OperationServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/operations/update_branches_test.go b/internal/service/operations/update_branches_test.go
index 44f9427de..04a41af45 100644
--- a/internal/service/operations/update_branches_test.go
+++ b/internal/service/operations/update_branches_test.go
@@ -29,8 +29,8 @@ func TestSuccessfulUserUpdateBranchRequest(t *testing.T) {
cleanupSrv := SetupAndStartGitlabServer(t, user.GlId, testRepo.GlRepository)
defer cleanupSrv()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -55,8 +55,8 @@ func TestSuccessfulUserUpdateBranchRequest(t *testing.T) {
}
func TestSuccessfulGitHooksForUserUpdateBranchRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -100,8 +100,8 @@ func TestFailedUserUpdateBranchDueToHooks(t *testing.T) {
cleanupSrv := SetupAndStartGitlabServer(t, user.GlId, testRepo.GlRepository)
defer cleanupSrv()
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
@@ -133,8 +133,8 @@ func TestFailedUserUpdateBranchDueToHooks(t *testing.T) {
}
func TestFailedUserUpdateBranchRequest(t *testing.T) {
- server, serverSocketPath := runOperationServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runOperationServiceServer(t)
+ defer stop()
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/branches_test.go b/internal/service/ref/branches_test.go
index b0f6147af..354cbdf14 100644
--- a/internal/service/ref/branches_test.go
+++ b/internal/service/ref/branches_test.go
@@ -15,8 +15,8 @@ func TestSuccessfulFindBranchRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -78,8 +78,8 @@ func TestSuccessfulFindBranchRequest(t *testing.T) {
}
func TestFailedFindBranchRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/delete_refs_test.go b/internal/service/ref/delete_refs_test.go
index 3c4faab6f..73a88f7fc 100644
--- a/internal/service/ref/delete_refs_test.go
+++ b/internal/service/ref/delete_refs_test.go
@@ -11,8 +11,8 @@ import (
)
func TestSuccessfulDeleteRefs(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -64,8 +64,8 @@ func TestSuccessfulDeleteRefs(t *testing.T) {
}
func TestFailedDeleteRefsRequestDueToGitError(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -88,8 +88,8 @@ func TestFailedDeleteRefsRequestDueToGitError(t *testing.T) {
}
func TestFailedDeleteRefsDueToValidation(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/list_new_blobs_test.go b/internal/service/ref/list_new_blobs_test.go
index 568053862..6e16e8c5d 100644
--- a/internal/service/ref/list_new_blobs_test.go
+++ b/internal/service/ref/list_new_blobs_test.go
@@ -15,8 +15,8 @@ func TestListNewBlobs(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/list_new_commits_test.go b/internal/service/ref/list_new_commits_test.go
index f0b5cdffc..a75ed8c68 100644
--- a/internal/service/ref/list_new_commits_test.go
+++ b/internal/service/ref/list_new_commits_test.go
@@ -15,8 +15,8 @@ func TestListNewCommits(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/pack_refs_test.go b/internal/service/ref/pack_refs_test.go
index ad479415e..6eff598fe 100644
--- a/internal/service/ref/pack_refs_test.go
+++ b/internal/service/ref/pack_refs_test.go
@@ -19,8 +19,8 @@ func TestPackRefsSuccessfulRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/refexists_test.go b/internal/service/ref/refexists_test.go
index 2998461f8..557699fda 100644
--- a/internal/service/ref/refexists_test.go
+++ b/internal/service/ref/refexists_test.go
@@ -41,8 +41,8 @@ func TestRefExists(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/refname_test.go b/internal/service/ref/refname_test.go
index cdc5a61a9..d69df4b9d 100644
--- a/internal/service/ref/refname_test.go
+++ b/internal/service/ref/refname_test.go
@@ -13,8 +13,8 @@ import (
)
func TestFindRefNameSuccess(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -43,8 +43,8 @@ func TestFindRefNameSuccess(t *testing.T) {
}
func TestFindRefNameEmptyCommit(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -75,8 +75,8 @@ func TestFindRefNameEmptyCommit(t *testing.T) {
}
func TestFindRefNameInvalidRepo(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -104,8 +104,8 @@ func TestFindRefNameInvalidRepo(t *testing.T) {
}
func TestFindRefNameInvalidPrefix(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -131,8 +131,8 @@ func TestFindRefNameInvalidPrefix(t *testing.T) {
}
func TestFindRefNameInvalidObject(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/refs_test.go b/internal/service/ref/refs_test.go
index ae14a2054..c71efba88 100644
--- a/internal/service/ref/refs_test.go
+++ b/internal/service/ref/refs_test.go
@@ -32,8 +32,8 @@ func containsRef(refs [][]byte, ref string) bool {
}
func TestSuccessfulFindAllBranchNames(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -68,8 +68,8 @@ func TestSuccessfulFindAllBranchNames(t *testing.T) {
}
func TestFindAllBranchNamesVeryLargeResponse(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -124,8 +124,8 @@ func TestFindAllBranchNamesVeryLargeResponse(t *testing.T) {
}
func TestEmptyFindAllBranchNamesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -149,8 +149,8 @@ func TestEmptyFindAllBranchNamesRequest(t *testing.T) {
}
func TestInvalidRepoFindAllBranchNamesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -175,8 +175,8 @@ func TestInvalidRepoFindAllBranchNamesRequest(t *testing.T) {
}
func TestSuccessfulFindAllTagNames(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -213,8 +213,8 @@ func TestSuccessfulFindAllTagNames(t *testing.T) {
}
func TestEmptyFindAllTagNamesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -238,8 +238,8 @@ func TestEmptyFindAllTagNamesRequest(t *testing.T) {
}
func TestInvalidRepoFindAllTagNamesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -374,8 +374,8 @@ func TestDefaultBranchName(t *testing.T) {
}
func TestSuccessfulFindDefaultBranchName(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -398,8 +398,8 @@ func TestSuccessfulFindDefaultBranchName(t *testing.T) {
}
func TestEmptyFindDefaultBranchNameRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -415,8 +415,8 @@ func TestEmptyFindDefaultBranchNameRequest(t *testing.T) {
}
func TestInvalidRepoFindDefaultBranchNameRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -433,8 +433,8 @@ func TestInvalidRepoFindDefaultBranchNameRequest(t *testing.T) {
}
func TestSuccessfulFindAllTagsRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
testRepoCopy, testRepoCopyPath, cleanupFn := testhelper.NewTestRepoWithWorktree(t)
defer cleanupFn()
@@ -671,8 +671,8 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) {
}
func TestFindAllTagNestedTags(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
testRepoCopy, testRepoCopyPath, cleanupFn := testhelper.NewTestRepoWithWorktree(t)
defer cleanupFn()
@@ -779,8 +779,8 @@ func TestFindAllTagNestedTags(t *testing.T) {
}
func TestInvalidFindAllTagsRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -823,8 +823,8 @@ func TestInvalidFindAllTagsRequest(t *testing.T) {
}
func TestSuccessfulFindLocalBranches(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -916,8 +916,8 @@ func TestFindLocalBranchesSort(t *testing.T) {
},
}
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -958,8 +958,8 @@ func TestFindLocalBranchesSort(t *testing.T) {
}
func TestEmptyFindLocalBranchesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -983,8 +983,8 @@ func TestEmptyFindLocalBranchesRequest(t *testing.T) {
}
func TestSuccessfulFindAllBranchesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
remoteBranch := &gitalypb.FindAllBranchesResponse_Branch{
Name: []byte("refs/remotes/origin/fake-remote-branch"),
@@ -1042,8 +1042,8 @@ func TestSuccessfulFindAllBranchesRequest(t *testing.T) {
}
func TestSuccessfulFindAllBranchesRequestWithMergedBranches(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
@@ -1135,8 +1135,8 @@ func TestSuccessfulFindAllBranchesRequestWithMergedBranches(t *testing.T) {
}
func TestInvalidFindAllBranchesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -1193,8 +1193,8 @@ func readFindAllBranchesResponsesFromClient(t *testing.T, c gitalypb.RefService_
}
func TestListTagNamesContainingCommit(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -1270,8 +1270,8 @@ func TestListTagNamesContainingCommit(t *testing.T) {
}
func TestListBranchNamesContainingCommit(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -1364,8 +1364,8 @@ func TestListBranchNamesContainingCommit(t *testing.T) {
}
func TestSuccessfulFindTagRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
testRepoCopy, testRepoCopyPath, cleanupFn := testhelper.NewTestRepoWithWorktree(t)
defer cleanupFn()
@@ -1591,8 +1591,8 @@ func TestSuccessfulFindTagRequest(t *testing.T) {
}
func TestFindTagNestedTag(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
testRepoCopy, testRepoCopyPath, cleanupFn := testhelper.NewTestRepoWithWorktree(t)
defer cleanupFn()
@@ -1680,8 +1680,8 @@ func TestFindTagNestedTag(t *testing.T) {
}
func TestInvalidFindTagRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/remote_branches_test.go b/internal/service/ref/remote_branches_test.go
index 2fd0c78ab..f62a5f5bb 100644
--- a/internal/service/ref/remote_branches_test.go
+++ b/internal/service/ref/remote_branches_test.go
@@ -16,8 +16,8 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -79,8 +79,8 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) {
}
func TestInvalidFindAllRemoteBranchesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/tag_messages_test.go b/internal/service/ref/tag_messages_test.go
index fbd8ebac0..8c512c912 100644
--- a/internal/service/ref/tag_messages_test.go
+++ b/internal/service/ref/tag_messages_test.go
@@ -13,8 +13,8 @@ import (
)
func TestSuccessfulGetTagMessagesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -55,8 +55,8 @@ func TestSuccessfulGetTagMessagesRequest(t *testing.T) {
}
func TestFailedGetTagMessagesRequest(t *testing.T) {
- server, serverSocketPath := runRefServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRefServiceServer(t)
+ defer stop()
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/ref/testhelper_test.go b/internal/service/ref/testhelper_test.go
index 2faeb3d0e..0dd3b9018 100644
--- a/internal/service/ref/testhelper_test.go
+++ b/internal/service/ref/testhelper_test.go
@@ -2,7 +2,6 @@ package ref
import (
"bytes"
- "net"
"os"
"testing"
@@ -92,21 +91,15 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func runRefServiceServer(t *testing.T) (*grpc.Server, string) {
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
- grpcServer := testhelper.NewTestGrpcServer(t, nil, nil)
+func runRefServiceServer(t *testing.T) (func(), string) {
+ srv := testhelper.NewServer(t, nil, nil)
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterRefServiceServer(grpcServer, &server{})
- reflection.Register(grpcServer)
+ gitalypb.RegisterRefServiceServer(srv.GrpcServer(), &server{})
+ reflection.Register(srv.GrpcServer())
- go grpcServer.Serve(listener)
+ require.NoError(t, srv.Start())
- return grpcServer, "unix://" + serverSocketPath
+ return srv.Stop, "unix://" + srv.Socket()
}
func newRefServiceClient(t *testing.T, serverSocketPath string) (gitalypb.RefServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/remote/find_remote_root_ref_test.go b/internal/service/remote/find_remote_root_ref_test.go
index a8c418abb..b26037ea5 100644
--- a/internal/service/remote/find_remote_root_ref_test.go
+++ b/internal/service/remote/find_remote_root_ref_test.go
@@ -10,8 +10,8 @@ import (
)
func TestFindRemoteRootRefSuccess(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -29,8 +29,8 @@ func TestFindRemoteRootRefSuccess(t *testing.T) {
}
func TestFindRemoteRootRefFailedDueToValidation(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -77,8 +77,8 @@ func TestFindRemoteRootRefFailedDueToValidation(t *testing.T) {
}
func TestFindRemoteRootRefFailedDueToInvalidRemote(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/remote/remotes_test.go b/internal/service/remote/remotes_test.go
index 763be1211..da16e0759 100644
--- a/internal/service/remote/remotes_test.go
+++ b/internal/service/remote/remotes_test.go
@@ -16,8 +16,8 @@ import (
)
func TestSuccessfulAddRemote(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -100,8 +100,8 @@ func TestSuccessfulAddRemote(t *testing.T) {
}
func TestFailedAddRemoteDueToValidation(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -147,8 +147,8 @@ func TestFailedAddRemoteDueToValidation(t *testing.T) {
}
func TestSuccessfulRemoveRemote(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -197,8 +197,8 @@ func TestSuccessfulRemoveRemote(t *testing.T) {
}
func TestFailedRemoveRemoteDueToValidation(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -216,8 +216,8 @@ func TestFailedRemoveRemoteDueToValidation(t *testing.T) {
}
func TestFindRemoteRepository(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -239,8 +239,8 @@ func TestFindRemoteRepository(t *testing.T) {
}
func TestFailedFindRemoteRepository(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -272,8 +272,8 @@ func TestFailedFindRemoteRepository(t *testing.T) {
}
func TestListDifferentPushUrlRemote(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -319,8 +319,8 @@ func TestListDifferentPushUrlRemote(t *testing.T) {
}
func TestListRemotes(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/remote/testhelper_test.go b/internal/service/remote/testhelper_test.go
index 481be3f97..36601f71c 100644
--- a/internal/service/remote/testhelper_test.go
+++ b/internal/service/remote/testhelper_test.go
@@ -2,10 +2,10 @@ package remote
import (
"log"
- "net"
"os"
"testing"
+ "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/rubyserver"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -32,21 +32,15 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func runRemoteServiceServer(t *testing.T) (*grpc.Server, string) {
- grpcServer := testhelper.NewTestGrpcServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
+func runRemoteServiceServer(t *testing.T) (string, func()) {
+ srv := testhelper.NewServer(t, nil, nil)
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterRemoteServiceServer(grpcServer, &server{ruby: RubyServer})
- reflection.Register(grpcServer)
+ gitalypb.RegisterRemoteServiceServer(srv.GrpcServer(), &server{ruby: RubyServer})
+ reflection.Register(srv.GrpcServer())
- go grpcServer.Serve(listener)
+ require.NoError(t, srv.Start())
- return grpcServer, "unix://" + serverSocketPath
+ return "unix://" + srv.Socket(), srv.Stop
}
func NewRemoteClient(t *testing.T, serverSocketPath string) (gitalypb.RemoteServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/remote/update_remote_mirror_test.go b/internal/service/remote/update_remote_mirror_test.go
index 0cb8524a9..499c40b13 100644
--- a/internal/service/remote/update_remote_mirror_test.go
+++ b/internal/service/remote/update_remote_mirror_test.go
@@ -12,8 +12,8 @@ import (
)
func TestSuccessfulUpdateRemoteMirrorRequest(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -96,8 +96,8 @@ func TestSuccessfulUpdateRemoteMirrorRequest(t *testing.T) {
}
func TestSuccessfulUpdateRemoteMirrorRequestWithWildcards(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -173,8 +173,8 @@ func TestSuccessfulUpdateRemoteMirrorRequestWithWildcards(t *testing.T) {
}
func TestSuccessfulUpdateRemoteMirrorRequestWithKeepDivergentRefs(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -255,8 +255,8 @@ func TestSuccessfulUpdateRemoteMirrorRequestWithKeepDivergentRefs(t *testing.T)
}
func TestFailedUpdateRemoteMirrorRequestDueToValidation(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/smarthttp/inforefs_test.go b/internal/service/smarthttp/inforefs_test.go
index 46935e9ee..899a39d3e 100644
--- a/internal/service/smarthttp/inforefs_test.go
+++ b/internal/service/smarthttp/inforefs_test.go
@@ -28,8 +28,8 @@ import (
)
func TestSuccessfulInfoRefsUploadPack(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
@@ -45,8 +45,8 @@ func TestSuccessfulInfoRefsUploadPack(t *testing.T) {
}
func TestSuccessfulInfoRefsUploadWithPartialClone(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
ctx, cancel := testhelper.Context()
defer cancel()
@@ -80,8 +80,8 @@ func TestSuccessfulInfoRefsUploadWithPartialClone(t *testing.T) {
}
func TestSuccessfulInfoRefsUploadPackWithGitConfigOptions(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
@@ -102,8 +102,8 @@ func TestSuccessfulInfoRefsUploadPackWithGitProtocol(t *testing.T) {
restore := testhelper.EnableGitProtocolV2Support()
defer restore()
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
@@ -153,8 +153,8 @@ func makeInfoRefsUploadPackRequest(ctx context.Context, t *testing.T, serverSock
}
func TestSuccessfulInfoRefsReceivePack(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -186,8 +186,8 @@ func TestSuccessfulInfoRefsReceivePack(t *testing.T) {
}
func TestObjectPoolRefAdvertisementHiding(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -223,8 +223,8 @@ func TestObjectPoolRefAdvertisementHiding(t *testing.T) {
}
func TestFailureRepoNotFoundInfoRefsReceivePack(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -245,8 +245,8 @@ func TestFailureRepoNotFoundInfoRefsReceivePack(t *testing.T) {
}
func TestFailureRepoNotSetInfoRefsReceivePack(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -287,8 +287,8 @@ func assertGitRefAdvertisement(t *testing.T, rpc, responseBody string, firstLine
func TestCacheInfoRefsUploadPack(t *testing.T) {
clearCache(t)
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
diff --git a/internal/service/smarthttp/receive_pack_test.go b/internal/service/smarthttp/receive_pack_test.go
index f1074ef06..bd34823fe 100644
--- a/internal/service/smarthttp/receive_pack_test.go
+++ b/internal/service/smarthttp/receive_pack_test.go
@@ -31,8 +31,8 @@ func TestSuccessfulReceivePackRequest(t *testing.T) {
hookOutputFile, cleanup := testhelper.CaptureHookEnv(t)
defer cleanup()
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
repo, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -73,8 +73,8 @@ func TestSuccessfulReceivePackRequestWithGitProtocol(t *testing.T) {
restore := testhelper.EnableGitProtocolV2Support()
defer restore()
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
repo, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -102,8 +102,8 @@ func TestSuccessfulReceivePackRequestWithGitProtocol(t *testing.T) {
}
func TestFailedReceivePackRequestWithGitOpts(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
repo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -138,8 +138,8 @@ func TestFailedReceivePackRequestDueToHooksFailure(t *testing.T) {
hookContent := []byte("#!/bin/sh\nexit 1")
ioutil.WriteFile(path.Join(hooks.Path(), "pre-receive"), hookContent, 0755)
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
repo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -244,8 +244,8 @@ func createCommit(t *testing.T, repoPath string, fileContents []byte) (oldHead s
}
func TestFailedReceivePackRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -278,8 +278,8 @@ func TestPostReceivePackToHooks(t *testing.T) {
glRepository := "some_repo"
glID := "key-123"
- server, socket := runSmartHTTPServer(t)
- defer server.Stop()
+ socket, stop := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, "unix://"+socket)
defer conn.Close()
diff --git a/internal/service/smarthttp/testhelper_test.go b/internal/service/smarthttp/testhelper_test.go
index ed5eff8d3..aef5803ce 100644
--- a/internal/service/smarthttp/testhelper_test.go
+++ b/internal/service/smarthttp/testhelper_test.go
@@ -1,10 +1,10 @@
package smarthttp
import (
- "net"
"os"
"testing"
+ "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git/hooks"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -28,21 +28,15 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func runSmartHTTPServer(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, nil, nil)
+func runSmartHTTPServer(t *testing.T) (string, func()) {
+ srv := testhelper.NewServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterSmartHTTPServiceServer(server, NewServer())
- reflection.Register(server)
+ gitalypb.RegisterSmartHTTPServiceServer(srv.GrpcServer(), NewServer())
+ reflection.Register(srv.GrpcServer())
- go server.Serve(listener)
+ require.NoError(t, srv.Start())
- return server, "unix://" + serverSocketPath
+ return "unix://" + srv.Socket(), srv.Stop
}
func newSmartHTTPClient(t *testing.T, serverSocketPath string) (gitalypb.SmartHTTPServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/smarthttp/upload_pack_test.go b/internal/service/smarthttp/upload_pack_test.go
index 808ace220..aa1282e67 100644
--- a/internal/service/smarthttp/upload_pack_test.go
+++ b/internal/service/smarthttp/upload_pack_test.go
@@ -29,8 +29,8 @@ const (
)
func TestSuccessfulUploadPackRequest(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
ctx, cancel := testhelper.Context()
defer cancel()
@@ -95,8 +95,8 @@ func TestSuccessfulUploadPackRequest(t *testing.T) {
}
func TestUploadPackRequestWithGitConfigOptions(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
ctx, cancel := testhelper.Context()
defer cancel()
@@ -167,8 +167,8 @@ func TestUploadPackRequestWithGitProtocol(t *testing.T) {
restore := testhelper.EnableGitProtocolV2Support()
defer restore()
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
ctx, cancel := testhelper.Context()
defer cancel()
@@ -213,8 +213,8 @@ func TestUploadPackRequestWithGitProtocol(t *testing.T) {
// on 'deepen' requests even though the request is being handled just
// fine from the client perspective.
func TestSuccessfulUploadPackDeepenRequest(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
ctx, cancel := testhelper.Context()
defer cancel()
@@ -235,8 +235,8 @@ func TestSuccessfulUploadPackDeepenRequest(t *testing.T) {
}
func TestFailedUploadPackRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
rpcRequests := []gitalypb.PostUploadPackRequest{
{Repository: &gitalypb.Repository{StorageName: "fake", RelativePath: "path"}}, // Repository doesn't exist
@@ -324,8 +324,8 @@ func extractPackDataFromResponse(t *testing.T, buf *bytes.Buffer) ([]byte, int,
}
func TestUploadPackRequestForPartialCloneSuccess(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSmartHTTPServer(t)
+ defer stop()
testRepo := testhelper.TestRepository()
testRepoPath, err := helper.GetRepoPath(testRepo)
diff --git a/internal/service/ssh/receive_pack_test.go b/internal/service/ssh/receive_pack_test.go
index 7e4ad6fb3..2506c4620 100644
--- a/internal/service/ssh/receive_pack_test.go
+++ b/internal/service/ssh/receive_pack_test.go
@@ -27,8 +27,8 @@ import (
)
func TestFailedReceivePackRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -84,8 +84,8 @@ func TestReceivePackPushSuccess(t *testing.T) {
hookOutputFile, cleanup := testhelper.CaptureHookEnv(t)
defer cleanup()
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
glRepository := "project-456"
@@ -112,8 +112,8 @@ func TestReceivePackPushSuccessWithGitProtocol(t *testing.T) {
restore := testhelper.EnableGitProtocolV2Support()
defer restore()
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
lHead, rHead, err := testCloneAndPush(t, serverSocketPath, pushParams{storageName: testRepo.GetStorageName(), glID: "1", gitProtocol: git.ProtocolV2})
if err != nil {
@@ -129,8 +129,8 @@ func TestReceivePackPushSuccessWithGitProtocol(t *testing.T) {
}
func TestReceivePackPushFailure(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
_, _, err := testCloneAndPush(t, serverSocketPath, pushParams{storageName: "foobar", glID: "1"})
require.Error(t, err, "local and remote head equal. push did not fail")
@@ -140,8 +140,8 @@ func TestReceivePackPushFailure(t *testing.T) {
}
func TestReceivePackPushHookFailure(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
hookDir, err := ioutil.TempDir("", "gitaly-tmp-hooks")
require.NoError(t, err)
@@ -161,8 +161,8 @@ func TestReceivePackPushHookFailure(t *testing.T) {
}
func TestObjectPoolRefAdvertisementHidingSSH(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -213,8 +213,8 @@ func TestSSHReceivePackToHooks(t *testing.T) {
restore := testhelper.EnableGitProtocolV2Support()
defer restore()
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
tempGitlabShellDir, cleanup := testhelper.CreateTemporaryGitlabShellDir(t)
defer cleanup()
diff --git a/internal/service/ssh/testhelper_test.go b/internal/service/ssh/testhelper_test.go
index e368ba877..c6af60b20 100644
--- a/internal/service/ssh/testhelper_test.go
+++ b/internal/service/ssh/testhelper_test.go
@@ -1,12 +1,12 @@
package ssh
import (
- "net"
"os"
"path"
"testing"
log "github.com/sirupsen/logrus"
+ "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/config"
"gitlab.com/gitlab-org/gitaly/internal/git/hooks"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -58,21 +58,15 @@ func mustGetCwd() string {
return wd
}
-func runSSHServer(t *testing.T, serverOpts ...ServerOpt) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, nil, nil)
+func runSSHServer(t *testing.T, serverOpts ...ServerOpt) (string, func()) {
+ srv := testhelper.NewServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterSSHServiceServer(server, NewServer(serverOpts...))
- reflection.Register(server)
+ gitalypb.RegisterSSHServiceServer(srv.GrpcServer(), NewServer(serverOpts...))
+ reflection.Register(srv.GrpcServer())
- go server.Serve(listener)
+ require.NoError(t, srv.Start())
- return server, "unix://" + serverSocketPath
+ return "unix://" + srv.Socket(), srv.Stop
}
func newSSHClient(t *testing.T, serverSocketPath string) (gitalypb.SSHServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/ssh/upload_archive_test.go b/internal/service/ssh/upload_archive_test.go
index 7a512bc3f..160e6ee87 100644
--- a/internal/service/ssh/upload_archive_test.go
+++ b/internal/service/ssh/upload_archive_test.go
@@ -16,8 +16,8 @@ import (
)
func TestFailedUploadArchiveRequestDueToTimeout(t *testing.T) {
- server, serverSocketPath := runSSHServer(t, WithArchiveRequestTimeout(100*time.Microsecond))
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t, WithArchiveRequestTimeout(100*time.Microsecond))
+ defer stop()
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -50,8 +50,8 @@ func TestFailedUploadArchiveRequestDueToTimeout(t *testing.T) {
}
func TestFailedUploadArchiveRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -99,8 +99,8 @@ func TestFailedUploadArchiveRequestDueToValidationError(t *testing.T) {
}
func TestUploadArchiveSuccess(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
cmd := exec.Command("git", "archive", "master", "--remote=git@localhost:test/test.git")
diff --git a/internal/service/ssh/upload_pack_test.go b/internal/service/ssh/upload_pack_test.go
index 30ef62590..04a53b357 100644
--- a/internal/service/ssh/upload_pack_test.go
+++ b/internal/service/ssh/upload_pack_test.go
@@ -81,9 +81,8 @@ func (cmd cloneCommand) test(t *testing.T, localRepoPath string) (string, string
}
func TestFailedUploadPackRequestDueToTimeout(t *testing.T) {
- server, serverSocketPath := runSSHServer(t, WithUploadPackRequestTimeout(10*time.Microsecond))
-
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t, WithUploadPackRequestTimeout(10*time.Microsecond))
+ defer stop()
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -137,8 +136,8 @@ func requireFailedSSHStream(t *testing.T, recv func() (int32, error)) {
}
func TestFailedUploadPackRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -186,8 +185,8 @@ func TestFailedUploadPackRequestDueToValidationError(t *testing.T) {
}
func TestUploadPackCloneSuccess(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
localRepoPath := path.Join(testRepoRoot, "gitlab-test-upload-pack-local")
@@ -219,8 +218,8 @@ func TestUploadPackCloneSuccess(t *testing.T) {
}
func TestUploadPackCloneWithPartialCloneFilter(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
// Ruby file which is ~1kB in size and not present in HEAD
blobLessThanLimit := "6ee41e85cc9bf33c10b690df09ca735b22f3790f"
@@ -273,8 +272,8 @@ func TestUploadPackCloneSuccessWithGitProtocol(t *testing.T) {
restore := testhelper.EnableGitProtocolV2Support()
defer restore()
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
localRepoPath := path.Join(testRepoRoot, "gitlab-test-upload-pack-local")
@@ -313,8 +312,8 @@ func TestUploadPackCloneSuccessWithGitProtocol(t *testing.T) {
}
func TestUploadPackCloneHideTags(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
localRepoPath := path.Join(testRepoRoot, "gitlab-test-upload-pack-local-hide-tags")
@@ -335,8 +334,8 @@ func TestUploadPackCloneHideTags(t *testing.T) {
}
func TestUploadPackCloneFailure(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ serverSocketPath, stop := runSSHServer(t)
+ defer stop()
localRepoPath := path.Join(testRepoRoot, "gitlab-test-upload-pack-local-failure")
diff --git a/internal/service/wiki/delete_page_test.go b/internal/service/wiki/delete_page_test.go
index 0ffac0eb0..428ba4b7d 100644
--- a/internal/service/wiki/delete_page_test.go
+++ b/internal/service/wiki/delete_page_test.go
@@ -17,8 +17,8 @@ func TestSuccessfulWikiDeletePageRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -85,8 +85,8 @@ func TestFailedWikiDeletePageDueToValidations(t *testing.T) {
wikiRepo, _, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/wiki/find_file_test.go b/internal/service/wiki/find_file_test.go
index 9908686a0..1ff13871f 100644
--- a/internal/service/wiki/find_file_test.go
+++ b/internal/service/wiki/find_file_test.go
@@ -18,8 +18,8 @@ func TestSuccessfulWikiFindFileRequest(t *testing.T) {
_, wikiRepoPath, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -156,8 +156,8 @@ func TestFailedWikiFindFileDueToValidation(t *testing.T) {
wikiRepo, _, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/wiki/find_page_test.go b/internal/service/wiki/find_page_test.go
index fd7e262f6..4d5ab7249 100644
--- a/internal/service/wiki/find_page_test.go
+++ b/internal/service/wiki/find_page_test.go
@@ -14,8 +14,8 @@ func TestSuccessfulWikiFindPageRequest(t *testing.T) {
wikiRepo, _, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -190,8 +190,8 @@ func TestSuccessfulWikiFindPageSameTitleDifferentPathRequest(t *testing.T) {
wikiRepo, _, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -306,8 +306,8 @@ func TestFailedWikiFindPageDueToValidation(t *testing.T) {
wikiRepo, _, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -372,8 +372,8 @@ func readFullWikiPageFromWikiFindPageClient(t *testing.T, c gitalypb.WikiService
}
func TestInvalidWikiFindPageRequestRevision(t *testing.T) {
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/wiki/get_all_pages_test.go b/internal/service/wiki/get_all_pages_test.go
index c14acbd46..7952915c2 100644
--- a/internal/service/wiki/get_all_pages_test.go
+++ b/internal/service/wiki/get_all_pages_test.go
@@ -14,8 +14,8 @@ func TestSuccessfulWikiGetAllPagesRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -69,8 +69,8 @@ func TestWikiGetAllPagesSorting(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -177,8 +177,8 @@ func TestWikiGetAllPagesSorting(t *testing.T) {
}
func TestFailedWikiGetAllPagesDueToValidation(t *testing.T) {
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/wiki/get_page_versions_test.go b/internal/service/wiki/get_page_versions_test.go
index 6456146d3..09a8ad15a 100644
--- a/internal/service/wiki/get_page_versions_test.go
+++ b/internal/service/wiki/get_page_versions_test.go
@@ -19,8 +19,8 @@ func TestWikiGetPageVersionsRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -109,8 +109,8 @@ func TestWikiGetPageVersionsPaginationParams(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/wiki/list_pages_test.go b/internal/service/wiki/list_pages_test.go
index 4bb9d6995..b2e0f164b 100644
--- a/internal/service/wiki/list_pages_test.go
+++ b/internal/service/wiki/list_pages_test.go
@@ -13,8 +13,8 @@ func TestSuccessfulWikiListPagesRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -70,8 +70,8 @@ func TestWikiListPagesSorting(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/wiki/testhelper_test.go b/internal/service/wiki/testhelper_test.go
index 5de3ac199..efad55063 100644
--- a/internal/service/wiki/testhelper_test.go
+++ b/internal/service/wiki/testhelper_test.go
@@ -3,7 +3,6 @@ package wiki
import (
"bytes"
"io/ioutil"
- "net"
"os"
"path"
"strings"
@@ -58,21 +57,15 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func runWikiServiceServer(t *testing.T) (*grpc.Server, string) {
- grpcServer := testhelper.NewTestGrpcServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
+func runWikiServiceServer(t *testing.T) (func(), string) {
+ srv := testhelper.NewServer(t, nil, nil)
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterWikiServiceServer(grpcServer, &server{ruby: rubyServer})
- reflection.Register(grpcServer)
+ gitalypb.RegisterWikiServiceServer(srv.GrpcServer(), &server{ruby: rubyServer})
+ reflection.Register(srv.GrpcServer())
- go grpcServer.Serve(listener)
+ require.NoError(t, srv.Start())
- return grpcServer, "unix://" + serverSocketPath
+ return srv.Stop, "unix://" + srv.Socket()
}
func newWikiClient(t *testing.T, serverSocketPath string) (gitalypb.WikiServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/wiki/update_page_test.go b/internal/service/wiki/update_page_test.go
index f4bbbbc78..094628826 100644
--- a/internal/service/wiki/update_page_test.go
+++ b/internal/service/wiki/update_page_test.go
@@ -18,8 +18,8 @@ func TestSuccessfulWikiUpdatePageRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -114,8 +114,8 @@ func TestFailedWikiUpdatePageDueToValidations(t *testing.T) {
wikiRepo, _, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/wiki/write_page_test.go b/internal/service/wiki/write_page_test.go
index 53577ebc7..37b1ce86d 100644
--- a/internal/service/wiki/write_page_test.go
+++ b/internal/service/wiki/write_page_test.go
@@ -18,8 +18,8 @@ func TestSuccessfulWikiWritePageRequest(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -117,8 +117,8 @@ func TestFailedWikiWritePageDueToDuplicatePage(t *testing.T) {
wikiRepo, _, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -162,8 +162,8 @@ func TestFailedWikiWritePageInPathDueToDuplicatePage(t *testing.T) {
wikiRepo, _, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()
@@ -206,8 +206,8 @@ func TestFailedWikiWritePageInPathDueToDuplicatePage(t *testing.T) {
func TestFailedWikiWritePageDueToValidations(t *testing.T) {
wikiRepo := &gitalypb.Repository{}
- server, serverSocketPath := runWikiServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runWikiServiceServer(t)
+ defer stop()
client, conn := newWikiClient(t, serverSocketPath)
defer conn.Close()