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:
authorJohn Cai <jcai@gitlab.com>2020-01-08 05:10:22 +0300
committerJohn Cai <jcai@gitlab.com>2020-03-12 04:18:36 +0300
commitf4a96a3992a0eb8efb427d17430c97585ea91739 (patch)
tree6e52ddab7a0d61c440b71c6a2bbac5fddcb785dc
parentf414810c76834bfb3370af0b4b0f46e1f00b58d7 (diff)
Add test server to automatically start praefectjc-praefect-test-rollout
-rw-r--r--changelogs/unreleased/jc-praefect-test.yml5
-rw-r--r--internal/praefect/coordinator.go9
-rw-r--r--internal/praefect/nodes/manager.go4
-rw-r--r--internal/praefect/protoregistry/find_oid.go58
-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/commit/between_test.go8
-rw-r--r--internal/service/commit/commit_messages_test.go8
-rw-r--r--internal/service/commit/commit_signatures_test.go8
-rw-r--r--internal/service/commit/commits_by_message_test.go8
-rw-r--r--internal/service/commit/count_commits_test.go8
-rw-r--r--internal/service/commit/count_diverging_commits_test.go12
-rw-r--r--internal/service/commit/filter_shas_with_signatures.go4
-rw-r--r--internal/service/commit/filter_shas_with_signatures_test.go6
-rw-r--r--internal/service/commit/find_all_commits_test.go8
-rw-r--r--internal/service/commit/find_commit_test.go16
-rw-r--r--internal/service/commit/find_commits_test.go24
-rw-r--r--internal/service/commit/isancestor_test.go12
-rw-r--r--internal/service/commit/languages_test.go20
-rw-r--r--internal/service/commit/last_commit_for_path_test.go8
-rw-r--r--internal/service/commit/list_commits_by_oid_test.go8
-rw-r--r--internal/service/commit/list_commits_by_ref_name_test.go8
-rw-r--r--internal/service/commit/list_files_test.go12
-rw-r--r--internal/service/commit/list_last_commits_for_tree_test.go12
-rw-r--r--internal/service/commit/raw_blame_test.go8
-rw-r--r--internal/service/commit/stats_test.go8
-rw-r--r--internal/service/commit/testhelper_test.go21
-rw-r--r--internal/service/commit/tree_entries_test.go16
-rw-r--r--internal/service/commit/tree_entry_test.go8
-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/diff/commit_test.go44
-rw-r--r--internal/service/diff/numstat_test.go8
-rw-r--r--internal/service/diff/raw_test.go16
-rw-r--r--internal/service/diff/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/objectpool/alternates_test.go12
-rw-r--r--internal/service/objectpool/create_test.go12
-rw-r--r--internal/service/objectpool/fetch_into_object_pool_test.go33
-rw-r--r--internal/service/objectpool/get_test.go12
-rw-r--r--internal/service/objectpool/link_test.go24
-rw-r--r--internal/service/objectpool/reduplicate_test.go4
-rw-r--r--internal/service/objectpool/testhelper_test.go28
-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.go19
-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/repository/apply_gitattributes_test.go8
-rw-r--r--internal/service/repository/archive_test.go12
-rw-r--r--internal/service/repository/backup_custom_hooks_test.go12
-rw-r--r--internal/service/repository/calculate_checksum_test.go20
-rw-r--r--internal/service/repository/cleanup_test.go20
-rw-r--r--internal/service/repository/config_test.go8
-rw-r--r--internal/service/repository/create_bundle_test.go8
-rw-r--r--internal/service/repository/create_from_bundle_test.go8
-rw-r--r--internal/service/repository/create_from_snapshot_test.go4
-rw-r--r--internal/service/repository/create_from_url_test.go12
-rw-r--r--internal/service/repository/create_test.go16
-rw-r--r--internal/service/repository/fetch_remote_test.go19
-rw-r--r--internal/service/repository/fsck_test.go12
-rw-r--r--internal/service/repository/gc_test.go28
-rw-r--r--internal/service/repository/info_attributes_test.go8
-rw-r--r--internal/service/repository/license_test.go8
-rw-r--r--internal/service/repository/merge_base_test.go8
-rw-r--r--internal/service/repository/raw_changes_test.go24
-rw-r--r--internal/service/repository/rebase_in_progress_test.go8
-rw-r--r--internal/service/repository/remove_test.go8
-rw-r--r--internal/service/repository/rename_test.go12
-rw-r--r--internal/service/repository/repack_test.go32
-rw-r--r--internal/service/repository/replicate_test.go4
-rw-r--r--internal/service/repository/repository_test.go12
-rw-r--r--internal/service/repository/restore_custom_hooks_test.go12
-rw-r--r--internal/service/repository/search_files_test.go27
-rw-r--r--internal/service/repository/size_test.go12
-rw-r--r--internal/service/repository/snapshot_test.go4
-rw-r--r--internal/service/repository/squash_in_progress_test.go8
-rw-r--r--internal/service/repository/testhelper_test.go32
-rw-r--r--internal/service/repository/write_ref_test.go8
-rw-r--r--internal/service/smarthttp/inforefs_test.go32
-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.go24
-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
-rw-r--r--internal/testhelper/testserver.go98
117 files changed, 965 insertions, 940 deletions
diff --git a/changelogs/unreleased/jc-praefect-test.yml b/changelogs/unreleased/jc-praefect-test.yml
new file mode 100644
index 000000000..94149b755
--- /dev/null
+++ b/changelogs/unreleased/jc-praefect-test.yml
@@ -0,0 +1,5 @@
+---
+title: Add praefect as a transparent pass through for tests
+merge_request: 1736
+author:
+type: other
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index ae4ebcb61..c0b95b75a 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -62,9 +62,15 @@ func (c *Coordinator) directRepositoryScopedMessage(ctx context.Context, mi prot
}
return nil, err
}
+ if targetRepo.StorageName == "" || targetRepo.RelativePath == "" {
+ return nil, status.Error(codes.InvalidArgument, "target repo is invalid")
+ }
shard, err := c.nodeMgr.GetShard(targetRepo.GetStorageName())
if err != nil {
+ if err == nodes.ErrVirtualStorageNotExist {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
return nil, err
}
@@ -127,6 +133,9 @@ func (c *Coordinator) StreamDirector(ctx context.Context, fullMethodName string,
// any RPC that gets proxied through praefect must be repository scoped.
shard, err := c.nodeMgr.GetShard(c.conf.VirtualStorages[0].Name)
if err != nil {
+ if err == nodes.ErrVirtualStorageNotExist {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
return nil, err
}
diff --git a/internal/praefect/nodes/manager.go b/internal/praefect/nodes/manager.go
index e9f2de58a..e091286d3 100644
--- a/internal/praefect/nodes/manager.go
+++ b/internal/praefect/nodes/manager.go
@@ -156,11 +156,13 @@ func (n *Mgr) Start(bootstrapInterval, monitorInterval time.Duration) {
}
}
+var ErrVirtualStorageNotExist = errors.New("virtual storage does not exist")
+
// GetShard retrieves a shard for a virtual storage name
func (n *Mgr) GetShard(virtualStorageName string) (Shard, error) {
shard, ok := n.shards[virtualStorageName]
if !ok {
- return nil, errors.New("virtual storage does not exist")
+ return nil, ErrVirtualStorageNotExist
}
if n.failoverEnabled {
diff --git a/internal/praefect/protoregistry/find_oid.go b/internal/praefect/protoregistry/find_oid.go
index 8b73d4943..961c862d8 100644
--- a/internal/praefect/protoregistry/find_oid.go
+++ b/internal/praefect/protoregistry/find_oid.go
@@ -3,6 +3,7 @@ package protoregistry
import (
"errors"
"fmt"
+ "math"
"reflect"
"regexp"
"strconv"
@@ -22,6 +23,9 @@ var ErrTargetRepoMissing = errors.New("empty Repository")
func reflectFindRepoTarget(pbMsg proto.Message, targetOID []int) (*gitalypb.Repository, error) {
msgV, e := reflectFindOID(pbMsg, targetOID)
if e != nil {
+ if e == ErrProtoFieldEmpty {
+ return nil, ErrTargetRepoMissing
+ }
return nil, e
}
@@ -47,6 +51,9 @@ func reflectFindStorage(pbMsg proto.Message, targetOID []int) (string, error) {
return targetRepo, nil
}
+// ErrProtoFieldEmpty indicates the protobuf field is empty
+var ErrProtoFieldEmpty = errors.New("proto field is empty")
+
// reflectFindOID finds the target repository by using the OID to
// navigate the struct tags
// Warning: this reflection filled function is full of forbidden dark elf magic
@@ -57,10 +64,7 @@ func reflectFindOID(pbMsg proto.Message, targetOID []int) (reflect.Value, error)
msgV, err = findProtoField(msgV, fieldNo)
if err != nil {
- return reflect.Value{}, fmt.Errorf(
- "unable to descend OID %+v into message %s: %v",
- targetOID, proto.MessageName(pbMsg), err,
- )
+ return reflect.Value{}, err
}
}
return msgV, nil
@@ -74,7 +78,49 @@ const (
protobufTagRegexFieldGroup = 2
)
+func isZero(v reflect.Value) bool {
+ switch v.Kind() {
+ case reflect.Bool:
+ return !v.Bool()
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return v.Int() == 0
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return v.Uint() == 0
+ case reflect.Float32, reflect.Float64:
+ return math.Float64bits(v.Float()) == 0
+ case reflect.Complex64, reflect.Complex128:
+ c := v.Complex()
+ return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0
+ case reflect.Array:
+ for i := 0; i < v.Len(); i++ {
+ if !isZero(v.Index(i)) {
+ return false
+ }
+ }
+ return true
+ case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
+ return v.IsNil()
+ case reflect.String:
+ return v.Len() == 0
+ case reflect.Struct:
+ for i := 0; i < v.NumField(); i++ {
+ if !isZero(v.Field(i)) {
+ return false
+ }
+ }
+ return true
+ default:
+ // This should never happens, but will act as a safeguard for
+ // later, as a default value doesn't makes sense here.
+ panic(&reflect.ValueError{"reflect.Value.IsZero", v.Kind()})
+ }
+}
+
func findProtoField(msgV reflect.Value, protoField int) (reflect.Value, error) {
+ if isZero(msgV) {
+ return reflect.Value{}, ErrProtoFieldEmpty
+ }
+
msgV = reflect.Indirect(msgV)
for i := 0; i < msgV.NumField(); i++ {
field := msgV.Type().Field(i)
@@ -115,6 +161,10 @@ func tryNumberedField(field reflect.StructField, protoField int) (bool, error) {
}
func tryOneOfField(msgV reflect.Value, field reflect.StructField, protoField int) (reflect.Value, bool) {
+ if isZero(msgV) {
+ return reflect.Value{}, false
+ }
+
oneOfTag := field.Tag.Get(protobufOneOfTag)
if oneOfTag == "" {
return reflect.Value{}, false // empty tag means this is not a oneOf field
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..a613f75b2 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..3d12b9af8 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) (func(), string) {
+ 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 srv.Stop, "unix://" + srv.Socket()
}
func newCleanupServiceClient(t *testing.T, serverSocketPath string) (gitalypb.CleanupServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/commit/between_test.go b/internal/service/commit/between_test.go
index 78f678aaf..9ac2240f3 100644
--- a/internal/service/commit/between_test.go
+++ b/internal/service/commit/between_test.go
@@ -13,8 +13,8 @@ import (
)
func TestSuccessfulCommitsBetween(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -198,8 +198,8 @@ func TestSuccessfulCommitsBetween(t *testing.T) {
}
func TestFailedCommitsBetweenRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/commit_messages_test.go b/internal/service/commit/commit_messages_test.go
index 7d6b97e0c..89c9891f7 100644
--- a/internal/service/commit/commit_messages_test.go
+++ b/internal/service/commit/commit_messages_test.go
@@ -13,8 +13,8 @@ import (
)
func TestSuccessfulGetCommitMessagesRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -55,8 +55,8 @@ func TestSuccessfulGetCommitMessagesRequest(t *testing.T) {
}
func TestFailedGetCommitMessagesRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/commit_signatures_test.go b/internal/service/commit/commit_signatures_test.go
index 09493afa1..1f07d7bcb 100644
--- a/internal/service/commit/commit_signatures_test.go
+++ b/internal/service/commit/commit_signatures_test.go
@@ -11,8 +11,8 @@ import (
)
func TestSuccessfulGetCommitSignaturesRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -61,8 +61,8 @@ func TestSuccessfulGetCommitSignaturesRequest(t *testing.T) {
}
func TestFailedGetCommitSignaturesRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/commits_by_message_test.go b/internal/service/commit/commits_by_message_test.go
index ad08176ad..bcaedc32f 100644
--- a/internal/service/commit/commits_by_message_test.go
+++ b/internal/service/commit/commits_by_message_test.go
@@ -13,8 +13,8 @@ import (
)
func TestSuccessfulCommitsByMessageRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -155,8 +155,8 @@ func TestSuccessfulCommitsByMessageRequest(t *testing.T) {
}
func TestFailedCommitsByMessageRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/count_commits_test.go b/internal/service/commit/count_commits_test.go
index b609366fb..6313d5654 100644
--- a/internal/service/commit/count_commits_test.go
+++ b/internal/service/commit/count_commits_test.go
@@ -14,8 +14,8 @@ import (
)
func TestSuccessfulCountCommitsRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -163,8 +163,8 @@ func TestSuccessfulCountCommitsRequest(t *testing.T) {
}
func TestFailedCountCommitsRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/count_diverging_commits_test.go b/internal/service/commit/count_diverging_commits_test.go
index 928a9143a..a4c844e1d 100644
--- a/internal/service/commit/count_diverging_commits_test.go
+++ b/internal/service/commit/count_diverging_commits_test.go
@@ -59,8 +59,8 @@ func createRepoWithDivergentBranches(t *testing.T, leftCommits, rightCommits int
}
func TestSuccessfulCountDivergentCommitsRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -137,8 +137,8 @@ func TestSuccessfulCountDivergentCommitsRequest(t *testing.T) {
}
func TestSuccessfulCountDivergentCommitsRequestWithMaxCount(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -186,8 +186,8 @@ func TestSuccessfulCountDivergentCommitsRequestWithMaxCount(t *testing.T) {
}
func TestFailedCountDivergentCommitsRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/filter_shas_with_signatures.go b/internal/service/commit/filter_shas_with_signatures.go
index 8cd2f24fc..d02519630 100644
--- a/internal/service/commit/filter_shas_with_signatures.go
+++ b/internal/service/commit/filter_shas_with_signatures.go
@@ -1,9 +1,9 @@
package commit
import (
- "errors"
"io"
+ "gitlab.com/gitlab-org/gitaly/internal/errors"
"gitlab.com/gitlab-org/gitaly/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
"gitlab.com/gitlab-org/gitaly/internal/helper"
@@ -28,7 +28,7 @@ func (s *server) FilterShasWithSignatures(bidi gitalypb.CommitService_FilterShas
func validateFirstFilterShasWithSignaturesRequest(in *gitalypb.FilterShasWithSignaturesRequest) error {
if in.Repository == nil {
- return errors.New("no repository given")
+ return errors.ErrEmptyRepository
}
return nil
}
diff --git a/internal/service/commit/filter_shas_with_signatures_test.go b/internal/service/commit/filter_shas_with_signatures_test.go
index 877a58f5b..3589fa6e1 100644
--- a/internal/service/commit/filter_shas_with_signatures_test.go
+++ b/internal/service/commit/filter_shas_with_signatures_test.go
@@ -13,8 +13,8 @@ func TestFilterShasWithSignaturesSuccessful(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -66,7 +66,7 @@ func TestFilterShasWithSignaturesSuccessful(t *testing.T) {
func TestFilterShasWithSignaturesValidationError(t *testing.T) {
err := validateFirstFilterShasWithSignaturesRequest(&gitalypb.FilterShasWithSignaturesRequest{})
- require.Contains(t, err.Error(), "no repository given")
+ require.Contains(t, err.Error(), "empty Repository")
}
func recvFSWS(stream gitalypb.CommitService_FilterShasWithSignaturesClient) ([][]byte, error) {
diff --git a/internal/service/commit/find_all_commits_test.go b/internal/service/commit/find_all_commits_test.go
index e79b1ae45..bdaa44261 100644
--- a/internal/service/commit/find_all_commits_test.go
+++ b/internal/service/commit/find_all_commits_test.go
@@ -25,8 +25,8 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) {
}, nil
}
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -285,8 +285,8 @@ func TestSuccessfulFindAllCommitsRequest(t *testing.T) {
}
func TestFailedFindAllCommitsRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/find_commit_test.go b/internal/service/commit/find_commit_test.go
index 96367f559..bbef71e36 100644
--- a/internal/service/commit/find_commit_test.go
+++ b/internal/service/commit/find_commit_test.go
@@ -24,8 +24,8 @@ func TestSuccessfulFindCommitRequest(t *testing.T) {
windows1251Message, err := ioutil.ReadFile("testdata/commit-c809470461118b7bcab850f6e9a7ca97ac42f8ea-message.txt")
require.NoError(t, err)
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -270,8 +270,8 @@ func TestSuccessfulFindCommitRequest(t *testing.T) {
}
func TestFailedFindCommitRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -320,8 +320,8 @@ func benchmarkFindCommit(withCache bool, b *testing.B) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := startTestServices(b)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(b)
+ defer stop()
client, conn := newCommitServiceClient(b, serverSocketPath)
defer conn.Close()
@@ -367,8 +367,8 @@ func TestFindCommitWithCache(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/find_commits_test.go b/internal/service/commit/find_commits_test.go
index 29a7eee95..a22fbf91a 100644
--- a/internal/service/commit/find_commits_test.go
+++ b/internal/service/commit/find_commits_test.go
@@ -20,8 +20,8 @@ func TestFindCommitsFields(t *testing.T) {
windows1251Message, err := ioutil.ReadFile("testdata/commit-c809470461118b7bcab850f6e9a7ca97ac42f8ea-message.txt")
require.NoError(t, err)
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -179,8 +179,8 @@ func TestFindCommitsFields(t *testing.T) {
}
func TestSuccessfulFindCommitsRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -422,8 +422,8 @@ func TestSuccessfulFindCommitsRequest(t *testing.T) {
}
func TestSuccessfulFindCommitsRequestWithAltGitObjectDirs(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -492,8 +492,8 @@ func TestSuccessfulFindCommitsRequestWithAltGitObjectDirs(t *testing.T) {
}
func TestSuccessfulFindCommitsRequestWithAmbiguousRef(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -538,8 +538,8 @@ func TestSuccessfulFindCommitsRequestWithAmbiguousRef(t *testing.T) {
}
func TestFailureFindCommitsRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -589,8 +589,8 @@ func TestFailureFindCommitsRequest(t *testing.T) {
}
func TestFindCommitsRequestWithFollowAndOffset(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/isancestor_test.go b/internal/service/commit/isancestor_test.go
index b1d22eae9..8b8fed569 100644
--- a/internal/service/commit/isancestor_test.go
+++ b/internal/service/commit/isancestor_test.go
@@ -14,8 +14,8 @@ import (
)
func TestCommitIsAncestorFailure(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -80,8 +80,8 @@ func TestCommitIsAncestorFailure(t *testing.T) {
}
func TestCommitIsAncestorSuccess(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -177,8 +177,8 @@ func TestCommitIsAncestorSuccess(t *testing.T) {
}
func TestSuccessfulIsAncestorRequestWithAltGitObjectDirs(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/languages_test.go b/internal/service/commit/languages_test.go
index eaf526925..c0f9106e2 100644
--- a/internal/service/commit/languages_test.go
+++ b/internal/service/commit/languages_test.go
@@ -13,8 +13,8 @@ import (
)
func TestLanguages(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -56,8 +56,8 @@ func TestLanguages(t *testing.T) {
}
func TestFileCountIsZeroWhenFeatureIsDisabled(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -93,8 +93,8 @@ func requireLanguageEqual(t *testing.T, expected, actual *gitalypb.CommitLanguag
}
func TestLanguagesEmptyRevision(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -123,8 +123,8 @@ func TestLanguagesEmptyRevision(t *testing.T) {
}
func TestInvalidCommitLanguagesRequestRevision(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -143,8 +143,8 @@ func TestInvalidCommitLanguagesRequestRevision(t *testing.T) {
}
func TestAmbiguousRefCommitLanguagesRequestRevision(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/last_commit_for_path_test.go b/internal/service/commit/last_commit_for_path_test.go
index 484d0ed9e..cfa80149c 100644
--- a/internal/service/commit/last_commit_for_path_test.go
+++ b/internal/service/commit/last_commit_for_path_test.go
@@ -12,8 +12,8 @@ import (
)
func TestSuccessfulLastCommitForPathRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -93,8 +93,8 @@ func TestSuccessfulLastCommitForPathRequest(t *testing.T) {
}
func TestFailedLastCommitForPathRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/list_commits_by_oid_test.go b/internal/service/commit/list_commits_by_oid_test.go
index 7b3435350..03033fecc 100644
--- a/internal/service/commit/list_commits_by_oid_test.go
+++ b/internal/service/commit/list_commits_by_oid_test.go
@@ -11,8 +11,8 @@ import (
)
func TestSuccessfulListCommitsByOidRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -176,8 +176,8 @@ var masterCommitids = []string{
}
func TestSuccessfulListCommitsByOidLargeRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/list_commits_by_ref_name_test.go b/internal/service/commit/list_commits_by_ref_name_test.go
index a0a2d3969..f8de19661 100644
--- a/internal/service/commit/list_commits_by_ref_name_test.go
+++ b/internal/service/commit/list_commits_by_ref_name_test.go
@@ -10,8 +10,8 @@ import (
)
func TestSuccessfulListCommitsByRefNameRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -189,8 +189,8 @@ var repositoryRefNames = map[string]string{
}
func TestSuccessfulListCommitsByRefNameLargeRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/list_files_test.go b/internal/service/commit/list_files_test.go
index 1efcf4428..c637ca89f 100644
--- a/internal/service/commit/list_files_test.go
+++ b/internal/service/commit/list_files_test.go
@@ -49,8 +49,8 @@ func TestListFilesSuccess(t *testing.T) {
defaultBranchName = ref.DefaultBranchName
}()
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -136,8 +136,8 @@ func TestListFilesSuccess(t *testing.T) {
}
func TestListFilesFailure(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -186,8 +186,8 @@ func drainListFilesResponse(c gitalypb.CommitService_ListFilesClient) error {
}
func TestInvalidListFilesRequestRevision(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/list_last_commits_for_tree_test.go b/internal/service/commit/list_last_commits_for_tree_test.go
index c7b611dba..933de977c 100644
--- a/internal/service/commit/list_last_commits_for_tree_test.go
+++ b/internal/service/commit/list_last_commits_for_tree_test.go
@@ -20,8 +20,8 @@ type commitInfo struct {
}
func TestSuccessfulListLastCommitsForTreeRequest(t *testing.T) {
- server, serverSockerPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSockerPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSockerPath)
defer conn.Close()
@@ -210,8 +210,8 @@ func TestSuccessfulListLastCommitsForTreeRequest(t *testing.T) {
}
func TestFailedListLastCommitsForTreeRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -306,8 +306,8 @@ func TestFailedListLastCommitsForTreeRequest(t *testing.T) {
}
func TestNonUtf8ListLastCommitsForTreeRequest(t *testing.T) {
- server, serverSockerPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSockerPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSockerPath)
defer conn.Close()
diff --git a/internal/service/commit/raw_blame_test.go b/internal/service/commit/raw_blame_test.go
index 034b9f1ce..30182666e 100644
--- a/internal/service/commit/raw_blame_test.go
+++ b/internal/service/commit/raw_blame_test.go
@@ -14,8 +14,8 @@ import (
)
func TestSuccessfulRawBlameRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -74,8 +74,8 @@ func TestSuccessfulRawBlameRequest(t *testing.T) {
}
func TestFailedRawBlameRequest(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/stats_test.go b/internal/service/commit/stats_test.go
index 2d9236754..f3eaae764 100644
--- a/internal/service/commit/stats_test.go
+++ b/internal/service/commit/stats_test.go
@@ -12,8 +12,8 @@ import (
)
func TestCommitStatsSuccess(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -83,8 +83,8 @@ func TestCommitStatsSuccess(t *testing.T) {
}
func TestCommitStatsFailure(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/testhelper_test.go b/internal/service/commit/testhelper_test.go
index b4621af6a..53ada5c98 100644
--- a/internal/service/commit/testhelper_test.go
+++ b/internal/service/commit/testhelper_test.go
@@ -1,19 +1,17 @@
package commit
import (
- "net"
"os"
"testing"
"github.com/golang/protobuf/ptypes/timestamp"
+ "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"
)
-var ()
-
func TestMain(m *testing.M) {
os.Exit(testMain(m))
}
@@ -24,20 +22,15 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func startTestServices(t testing.TB) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
+func startTestServices(t testing.TB) (func(), string) {
+ srv := testhelper.NewServer(t, nil, nil)
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal("failed to start server")
- }
+ gitalypb.RegisterCommitServiceServer(srv.GrpcServer(), NewServer())
+ reflection.Register(srv.GrpcServer())
- gitalypb.RegisterCommitServiceServer(server, NewServer())
- reflection.Register(server)
+ require.NoError(t, srv.Start())
- go server.Serve(listener)
- return server, "unix://" + serverSocketPath
+ return srv.Stop, "unix://" + srv.Socket()
}
func newCommitServiceClient(t testing.TB, serviceSocketPath string) (gitalypb.CommitServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/commit/tree_entries_test.go b/internal/service/commit/tree_entries_test.go
index 6c7af65e7..ad597431d 100644
--- a/internal/service/commit/tree_entries_test.go
+++ b/internal/service/commit/tree_entries_test.go
@@ -17,8 +17,8 @@ import (
)
func TestSuccessfulGetTreeEntriesWithCurlyBraces(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -86,8 +86,8 @@ func TestSuccessfulGetTreeEntries(t *testing.T) {
commitID := "d25b6d94034242f3930dfcfeb6d8d9aac3583992"
rootOid := "21bdc8af908562ae485ed46d71dd5426c08b084a"
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -410,8 +410,8 @@ func getTreeEntriesFromTreeEntryClient(t *testing.T, client gitalypb.CommitServi
}
func TestSuccessfulGetTreeEntries_FlatPathMaxDeep_SingleFoldersStructure(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -463,8 +463,8 @@ func TestSuccessfulGetTreeEntries_FlatPathMaxDeep_SingleFoldersStructure(t *test
}
func TestFailedGetTreeEntriesRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/commit/tree_entry_test.go b/internal/service/commit/tree_entry_test.go
index 32a68a970..0ffb9d10a 100644
--- a/internal/service/commit/tree_entry_test.go
+++ b/internal/service/commit/tree_entry_test.go
@@ -21,8 +21,8 @@ type treeEntry struct {
}
func TestSuccessfulTreeEntry(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -160,8 +160,8 @@ func TestSuccessfulTreeEntry(t *testing.T) {
}
func TestFailedTreeEntryRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := startTestServices(t)
- defer server.Stop()
+ stop, serverSocketPath := startTestServices(t)
+ defer stop()
client, conn := newCommitServiceClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/conflicts/list_conflict_files_test.go b/internal/service/conflicts/list_conflict_files_test.go
index 074234caa..37d193696 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..5296055e7 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) (func(), string) {
+ 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 srv.Stop, "unix://" + srv.Socket()
}
func NewConflictsClient(t *testing.T, serverSocketPath string) (gitalypb.ConflictsServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/diff/commit_test.go b/internal/service/diff/commit_test.go
index 9953d276a..f187bed7d 100644
--- a/internal/service/diff/commit_test.go
+++ b/internal/service/diff/commit_test.go
@@ -15,8 +15,8 @@ import (
)
func TestSuccessfulCommitDiffRequest(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -192,8 +192,8 @@ func TestSuccessfulCommitDiffRequest(t *testing.T) {
}
func TestSuccessfulCommitDiffRequestWithPaths(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -270,8 +270,8 @@ func TestSuccessfulCommitDiffRequestWithPaths(t *testing.T) {
}
func TestSuccessfulCommitDiffRequestWithTypeChangeDiff(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -321,8 +321,8 @@ func TestSuccessfulCommitDiffRequestWithTypeChangeDiff(t *testing.T) {
}
func TestSuccessfulCommitDiffRequestWithIgnoreWhitespaceChange(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -435,8 +435,8 @@ func TestSuccessfulCommitDiffRequestWithIgnoreWhitespaceChange(t *testing.T) {
}
func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -657,8 +657,8 @@ func TestSuccessfulCommitDiffRequestWithLimits(t *testing.T) {
}
func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -692,8 +692,8 @@ func TestFailedCommitDiffRequestDueToValidationError(t *testing.T) {
}
func TestFailedCommitDiffRequestWithNonExistentCommit(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -717,8 +717,8 @@ func TestFailedCommitDiffRequestWithNonExistentCommit(t *testing.T) {
}
func TestSuccessfulCommitDeltaRequest(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -840,8 +840,8 @@ func TestSuccessfulCommitDeltaRequest(t *testing.T) {
}
func TestSuccessfulCommitDeltaRequestWithPaths(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -909,8 +909,8 @@ func TestSuccessfulCommitDeltaRequestWithPaths(t *testing.T) {
}
func TestFailedCommitDeltaRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -944,8 +944,8 @@ func TestFailedCommitDeltaRequestDueToValidationError(t *testing.T) {
}
func TestFailedCommitDeltaRequestWithNonExistentCommit(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/diff/numstat_test.go b/internal/service/diff/numstat_test.go
index 073e1323c..33ead17b2 100644
--- a/internal/service/diff/numstat_test.go
+++ b/internal/service/diff/numstat_test.go
@@ -13,8 +13,8 @@ import (
)
func TestSuccessfulDiffStatsRequest(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -128,8 +128,8 @@ func TestSuccessfulDiffStatsRequest(t *testing.T) {
}
func TestFailedDiffStatsRequest(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/diff/raw_test.go b/internal/service/diff/raw_test.go
index 4e3ce322a..034bbff61 100644
--- a/internal/service/diff/raw_test.go
+++ b/internal/service/diff/raw_test.go
@@ -12,8 +12,8 @@ import (
)
func TestSuccessfulRawDiffRequest(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -56,8 +56,8 @@ func TestSuccessfulRawDiffRequest(t *testing.T) {
}
func TestFailedRawDiffRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -111,8 +111,8 @@ func TestFailedRawDiffRequestDueToValidations(t *testing.T) {
}
func TestSuccessfulRawPatchRequest(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
@@ -148,8 +148,8 @@ func TestSuccessfulRawPatchRequest(t *testing.T) {
}
func TestFailedRawPatchRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runDiffServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runDiffServer(t)
+ defer stop()
client, conn := newDiffClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/diff/testhelper_test.go b/internal/service/diff/testhelper_test.go
index c8bb4219c..13ea12fe7 100644
--- a/internal/service/diff/testhelper_test.go
+++ b/internal/service/diff/testhelper_test.go
@@ -1,10 +1,10 @@
package diff
import (
- "net"
"os"
"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"
@@ -21,21 +21,15 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func runDiffServer(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, nil, nil)
+func runDiffServer(t *testing.T) (func(), string) {
+ srv := testhelper.NewServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterDiffServiceServer(server, NewServer())
- reflection.Register(server)
+ gitalypb.RegisterDiffServiceServer(srv.GrpcServer(), NewServer())
+ reflection.Register(srv.GrpcServer())
- go server.Serve(listener)
+ require.NoError(t, srv.Start())
- return server, "unix://" + serverSocketPath
+ return srv.Stop, "unix://" + srv.Socket()
}
func newDiffClient(t *testing.T, serverSocketPath string) (gitalypb.DiffServiceClient, *grpc.ClientConn) {
diff --git a/internal/service/hooks/post_receive_test.go b/internal/service/hooks/post_receive_test.go
index 1dfee6948..d68ff1dac 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..4809c26dc 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..e55ab794f 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) (func(), string) {
+ 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 srv.Stop, "unix://" + srv.Socket()
}
diff --git a/internal/service/hooks/update_test.go b/internal/service/hooks/update_test.go
index 7319be1b6..f92e52c13 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := runHooksServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
diff --git a/internal/service/objectpool/alternates_test.go b/internal/service/objectpool/alternates_test.go
index cba9ea7d5..5fb34ef4f 100644
--- a/internal/service/objectpool/alternates_test.go
+++ b/internal/service/objectpool/alternates_test.go
@@ -14,8 +14,8 @@ import (
)
func TestDisconnectGitAlternates(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -63,8 +63,8 @@ func TestDisconnectGitAlternates(t *testing.T) {
}
func TestDisconnectGitAlternatesNoAlternates(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -86,8 +86,8 @@ func TestDisconnectGitAlternatesNoAlternates(t *testing.T) {
}
func TestDisconnectGitAlternatesUnexpectedAlternates(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/objectpool/create_test.go b/internal/service/objectpool/create_test.go
index 8b6946fc9..7499c19b9 100644
--- a/internal/service/objectpool/create_test.go
+++ b/internal/service/objectpool/create_test.go
@@ -15,8 +15,8 @@ import (
)
func TestCreate(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -61,8 +61,8 @@ func TestCreate(t *testing.T) {
}
func TestUnsuccessfulCreate(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -107,8 +107,8 @@ func TestUnsuccessfulCreate(t *testing.T) {
}
func TestRemove(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/objectpool/fetch_into_object_pool_test.go b/internal/service/objectpool/fetch_into_object_pool_test.go
index 5f31a4159..771a82c68 100644
--- a/internal/service/objectpool/fetch_into_object_pool_test.go
+++ b/internal/service/objectpool/fetch_into_object_pool_test.go
@@ -20,8 +20,8 @@ import (
)
func TestFetchIntoObjectPool_Success(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -78,8 +78,8 @@ func TestFetchIntoObjectPool_CollectLogStatistics(t *testing.T) {
defer cancel()
ctx = ctxlogrus.ToContext(ctx, log.WithField("test", "logging"))
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -135,32 +135,28 @@ func TestFetchIntoObjectPool_Failure(t *testing.T) {
description string
request *gitalypb.FetchIntoObjectPoolRequest
code codes.Code
- errMsg string
}{
{
- description: "empty origin",
+ description: "origin and pool do not share the same storage",
request: &gitalypb.FetchIntoObjectPoolRequest{
- ObjectPool: pool.ToProto(),
+ Origin: testRepo,
+ ObjectPool: poolWithDifferentStorage,
},
- code: codes.InvalidArgument,
- errMsg: "origin is empty",
+ code: codes.InvalidArgument,
},
{
- description: "empty pool",
+ description: "empty origin",
request: &gitalypb.FetchIntoObjectPoolRequest{
- Origin: testRepo,
+ ObjectPool: pool.ToProto(),
},
- code: codes.InvalidArgument,
- errMsg: "object pool is empty",
+ code: codes.InvalidArgument,
},
{
- description: "origin and pool do not share the same storage",
+ description: "empty pool",
request: &gitalypb.FetchIntoObjectPoolRequest{
- Origin: testRepo,
- ObjectPool: poolWithDifferentStorage,
+ Origin: testRepo,
},
- code: codes.InvalidArgument,
- errMsg: "origin has different storage than object pool",
+ code: codes.InvalidArgument,
},
}
for _, tc := range testCases {
@@ -168,7 +164,6 @@ func TestFetchIntoObjectPool_Failure(t *testing.T) {
_, err := server.FetchIntoObjectPool(ctx, tc.request)
require.Error(t, err)
testhelper.RequireGrpcError(t, err, tc.code)
- assert.Contains(t, err.Error(), tc.errMsg)
})
}
}
diff --git a/internal/service/objectpool/get_test.go b/internal/service/objectpool/get_test.go
index 392758fd3..e6275e454 100644
--- a/internal/service/objectpool/get_test.go
+++ b/internal/service/objectpool/get_test.go
@@ -13,8 +13,8 @@ import (
)
func TestGetObjectPoolSuccess(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -45,8 +45,8 @@ func TestGetObjectPoolSuccess(t *testing.T) {
}
func TestGetObjectPoolNoFile(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -66,8 +66,8 @@ func TestGetObjectPoolNoFile(t *testing.T) {
}
func TestGetObjectPoolBadFile(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/objectpool/link_test.go b/internal/service/objectpool/link_test.go
index 9265eaf08..8add03e34 100644
--- a/internal/service/objectpool/link_test.go
+++ b/internal/service/objectpool/link_test.go
@@ -16,8 +16,8 @@ import (
)
func TestLink(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -89,8 +89,8 @@ func TestLink(t *testing.T) {
}
func TestLinkIdempotent(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -119,8 +119,8 @@ func TestLinkIdempotent(t *testing.T) {
}
func TestLinkNoClobber(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -158,8 +158,8 @@ func TestLinkNoClobber(t *testing.T) {
}
func TestLinkNoPool(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -190,8 +190,8 @@ func TestLinkNoPool(t *testing.T) {
}
func TestUnlink(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
@@ -302,8 +302,8 @@ func TestUnlink(t *testing.T) {
}
func TestUnlinkIdempotent(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/objectpool/reduplicate_test.go b/internal/service/objectpool/reduplicate_test.go
index d1d9f560c..ae8acb4dc 100644
--- a/internal/service/objectpool/reduplicate_test.go
+++ b/internal/service/objectpool/reduplicate_test.go
@@ -12,8 +12,8 @@ import (
)
func TestReduplicate(t *testing.T) {
- server, serverSocketPath := runObjectPoolServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runObjectPoolServer(t)
+ defer stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/objectpool/testhelper_test.go b/internal/service/objectpool/testhelper_test.go
index 448e3d60d..4d5ee3489 100644
--- a/internal/service/objectpool/testhelper_test.go
+++ b/internal/service/objectpool/testhelper_test.go
@@ -1,11 +1,12 @@
package objectpool
import (
- "context"
- "net"
"os"
"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/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -22,30 +23,21 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func runObjectPoolServer(t *testing.T) (*grpc.Server, string) {
- server := testhelper.NewTestGrpcServer(t, nil, nil)
+func runObjectPoolServer(t *testing.T) (func(), string) {
+ srv := testhelper.NewServer(t, nil, nil)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
-
- gitalypb.RegisterObjectPoolServiceServer(server, NewServer())
- reflection.Register(server)
+ gitalypb.RegisterObjectPoolServiceServer(srv.GrpcServer(), NewServer())
+ reflection.Register(srv.GrpcServer())
- go server.Serve(listener)
+ require.NoError(t, srv.Start())
- return server, serverSocketPath
+ return srv.Stop, "unix://" + srv.Socket()
}
func newObjectPoolClient(t *testing.T, serverSocketPath string) (gitalypb.ObjectPoolServiceClient, *grpc.ClientConn) {
connOpts := []grpc.DialOption{
grpc.WithInsecure(),
- grpc.WithContextDialer(func(ctx context.Context, addr string) (conn net.Conn, err error) {
- d := net.Dialer{}
- return d.DialContext(ctx, "unix", addr)
- }),
+ grpc.WithPerRPCCredentials(gitalyauth.RPCCredentials(config.Config.Auth.Token)),
}
conn, err := grpc.Dial(serverSocketPath, connOpts...)
diff --git a/internal/service/operations/branches_test.go b/internal/service/operations/branches_test.go
index 5d6081bf0..55f6eb1e0 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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 2074a5abf..df1ecff38 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..aec3954ba 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..a37e0c925 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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 4273d7ccf..ec5c3e5ed 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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 38e461f52..81e509346 100644
--- a/internal/service/operations/testhelper_test.go
+++ b/internal/service/operations/testhelper_test.go
@@ -3,7 +3,6 @@ package operations
import (
"fmt"
"io/ioutil"
- "net"
"os"
"path/filepath"
"testing"
@@ -67,21 +66,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) (func(), string) {
+ 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 srv.Stop, "unix://" + srv.Socket()
}
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 d332b9a1a..1b7aafdb4 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..9d0560174 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..f9bd7330f 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..4db3f58c6 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) (func(), string) {
+ 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 srv.Stop, "unix://" + srv.Socket()
}
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 87e51eb8c..a9e39e153 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
@@ -229,8 +229,8 @@ func TestSuccessfulUpdateRemoteMirrorRequestWithKeepDivergentRefs(t *testing.T)
}
func TestFailedUpdateRemoteMirrorRequestDueToValidation(t *testing.T) {
- server, serverSocketPath := runRemoteServiceServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRemoteServiceServer(t)
+ defer stop()
client, conn := NewRemoteClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/apply_gitattributes_test.go b/internal/service/repository/apply_gitattributes_test.go
index 0dd242b92..10fc714cd 100644
--- a/internal/service/repository/apply_gitattributes_test.go
+++ b/internal/service/repository/apply_gitattributes_test.go
@@ -14,8 +14,8 @@ import (
)
func TestApplyGitattributesSuccess(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -66,8 +66,8 @@ func TestApplyGitattributesSuccess(t *testing.T) {
}
func TestApplyGitattributesFailure(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/archive_test.go b/internal/service/repository/archive_test.go
index 5e129b8f9..f7c370b0e 100644
--- a/internal/service/repository/archive_test.go
+++ b/internal/service/repository/archive_test.go
@@ -17,8 +17,8 @@ import (
)
func TestGetArchiveSuccess(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -121,8 +121,8 @@ func TestGetArchiveSuccess(t *testing.T) {
}
func TestGetArchiveFailure(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -236,8 +236,8 @@ func TestGetArchiveFailure(t *testing.T) {
}
func TestGetArchivePathInjection(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/backup_custom_hooks_test.go b/internal/service/repository/backup_custom_hooks_test.go
index abd3df248..1d5f2a588 100644
--- a/internal/service/repository/backup_custom_hooks_test.go
+++ b/internal/service/repository/backup_custom_hooks_test.go
@@ -18,8 +18,8 @@ import (
)
func TestSuccessfullBackupCustomHooksRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -67,8 +67,8 @@ func TestSuccessfullBackupCustomHooksRequest(t *testing.T) {
}
func TestSuccessfullBackupCustomHooksSymlink(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -106,8 +106,8 @@ func TestSuccessfullBackupCustomHooksSymlink(t *testing.T) {
}
func TestSuccessfullBackupCustomHooksRequestWithNoHooks(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/calculate_checksum_test.go b/internal/service/repository/calculate_checksum_test.go
index b29d245dc..386376ff1 100644
--- a/internal/service/repository/calculate_checksum_test.go
+++ b/internal/service/repository/calculate_checksum_test.go
@@ -13,8 +13,8 @@ import (
)
func TestSuccessfulCalculateChecksum(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -70,8 +70,8 @@ func TestRefWhitelist(t *testing.T) {
}
func TestEmptyRepositoryCalculateChecksum(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -89,8 +89,8 @@ func TestEmptyRepositoryCalculateChecksum(t *testing.T) {
}
func TestBrokenRepositoryCalculateChecksum(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -110,8 +110,8 @@ func TestBrokenRepositoryCalculateChecksum(t *testing.T) {
}
func TestFailedCalculateChecksum(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -145,8 +145,8 @@ func TestFailedCalculateChecksum(t *testing.T) {
}
func TestInvalidRefsCalculateChecksum(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/cleanup_test.go b/internal/service/repository/cleanup_test.go
index bb0f2e4e1..f30ac32b5 100644
--- a/internal/service/repository/cleanup_test.go
+++ b/internal/service/repository/cleanup_test.go
@@ -15,8 +15,8 @@ import (
)
func TestCleanupDeletesRefsLocks(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -58,8 +58,8 @@ func TestCleanupDeletesRefsLocks(t *testing.T) {
}
func TestCleanupDeletesPackedRefsLock(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -127,8 +127,8 @@ func TestCleanupDeletesPackedRefsLock(t *testing.T) {
// TODO: replace emulated rebase RPC with actual
// https://gitlab.com/gitlab-org/gitaly/issues/1750
func TestCleanupDeletesStaleWorktrees(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -199,8 +199,8 @@ func TestCleanupDisconnectedWorktrees(t *testing.T) {
worktreeAdminDir = "worktrees"
)
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -258,8 +258,8 @@ func TestCleanupDisconnectedWorktrees(t *testing.T) {
}
func TestCleanupFileLocks(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/config_test.go b/internal/service/repository/config_test.go
index de7f099e9..1726aee82 100644
--- a/internal/service/repository/config_test.go
+++ b/internal/service/repository/config_test.go
@@ -14,8 +14,8 @@ import (
)
func TestDeleteConfig(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -74,8 +74,8 @@ func TestDeleteConfig(t *testing.T) {
}
func TestSetConfig(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/create_bundle_test.go b/internal/service/repository/create_bundle_test.go
index c70373121..256782b28 100644
--- a/internal/service/repository/create_bundle_test.go
+++ b/internal/service/repository/create_bundle_test.go
@@ -15,8 +15,8 @@ import (
)
func TestSuccessfulCreateBundleRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -53,8 +53,8 @@ func TestSuccessfulCreateBundleRequest(t *testing.T) {
}
func TestFailedCreateBundleRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/create_from_bundle_test.go b/internal/service/repository/create_from_bundle_test.go
index 161fc1c9b..0bdd59143 100644
--- a/internal/service/repository/create_from_bundle_test.go
+++ b/internal/service/repository/create_from_bundle_test.go
@@ -18,8 +18,8 @@ import (
)
func TestSuccessfulCreateRepositoryFromBundleRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -85,8 +85,8 @@ func TestSuccessfulCreateRepositoryFromBundleRequest(t *testing.T) {
}
func TestFailedCreateRepositoryFromBundleRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/create_from_snapshot_test.go b/internal/service/repository/create_from_snapshot_test.go
index 2abc1aad5..cf53d3eb0 100644
--- a/internal/service/repository/create_from_snapshot_test.go
+++ b/internal/service/repository/create_from_snapshot_test.go
@@ -55,8 +55,8 @@ func generateTarFile(t *testing.T, path string) ([]byte, []string) {
}
func createFromSnapshot(t *testing.T, req *gitalypb.CreateRepositoryFromSnapshotRequest) (*gitalypb.CreateRepositoryFromSnapshotResponse, error) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/create_from_url_test.go b/internal/service/repository/create_from_url_test.go
index d3f45f672..d660d7a21 100644
--- a/internal/service/repository/create_from_url_test.go
+++ b/internal/service/repository/create_from_url_test.go
@@ -18,8 +18,8 @@ import (
)
func TestSuccessfulCreateRepositoryFromURLRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -86,8 +86,8 @@ func TestCloneRepositoryFromUrlCommand(t *testing.T) {
}
func TestFailedCreateRepositoryFromURLRequestDueToExistingTarget(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -141,8 +141,8 @@ func TestFailedCreateRepositoryFromURLRequestDueToExistingTarget(t *testing.T) {
}
func TestPreventingRedirect(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/create_test.go b/internal/service/repository/create_test.go
index dcfc09de2..d0c4f319d 100644
--- a/internal/service/repository/create_test.go
+++ b/internal/service/repository/create_test.go
@@ -16,8 +16,8 @@ import (
)
func TestCreateRepositorySuccess(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -48,8 +48,8 @@ func TestCreateRepositorySuccess(t *testing.T) {
}
func TestCreateRepositoryFailure(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -73,8 +73,8 @@ func TestCreateRepositoryFailure(t *testing.T) {
}
func TestCreateRepositoryFailureInvalidArgs(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -103,8 +103,8 @@ func TestCreateRepositoryFailureInvalidArgs(t *testing.T) {
}
func TestCreateRepositoryIdempotent(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/fetch_remote_test.go b/internal/service/repository/fetch_remote_test.go
index 5f6cce28d..2c75eb5c1 100644
--- a/internal/service/repository/fetch_remote_test.go
+++ b/internal/service/repository/fetch_remote_test.go
@@ -44,8 +44,8 @@ func TestFetchRemoteSuccess(t *testing.T) {
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, _ := newRepositoryClient(t, serverSocketPath)
@@ -74,13 +74,11 @@ func TestFetchRemoteFailure(t *testing.T) {
desc string
req *gitalypb.FetchRemoteRequest
code codes.Code
- err string
}{
{
desc: "invalid storage",
req: &gitalypb.FetchRemoteRequest{Repository: &gitalypb.Repository{StorageName: "invalid", RelativePath: "foobar.git"}},
code: codes.InvalidArgument,
- err: "Storage can not be found by name 'invalid'",
},
}
@@ -91,7 +89,6 @@ func TestFetchRemoteFailure(t *testing.T) {
resp, err := server.FetchRemote(ctx, tc.req)
testhelper.RequireGrpcError(t, err, tc.code)
- require.Contains(t, err.Error(), tc.err)
assert.Nil(t, resp)
})
}
@@ -130,8 +127,8 @@ func getRefnames(t *testing.T, repoPath string) []string {
}
func TestFetchRemoteOverHTTP(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -186,8 +183,8 @@ func TestFetchRemoteOverHTTP(t *testing.T) {
}
func TestFetchRemoteOverHTTPWithRedirect(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -217,8 +214,8 @@ func TestFetchRemoteOverHTTPWithRedirect(t *testing.T) {
}
func TestFetchRemoteOverHTTPError(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/fsck_test.go b/internal/service/repository/fsck_test.go
index 84057ec9b..f8739f907 100644
--- a/internal/service/repository/fsck_test.go
+++ b/internal/service/repository/fsck_test.go
@@ -16,8 +16,8 @@ func TestFsckSuccess(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -35,8 +35,8 @@ func TestFsckFailureSeverelyBrokenRepo(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -61,8 +61,8 @@ func TestFsckFailureSlightlyBrokenRepo(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/gc_test.go b/internal/service/repository/gc_test.go
index 9c50e8e84..fb86a8917 100644
--- a/internal/service/repository/gc_test.go
+++ b/internal/service/repository/gc_test.go
@@ -30,8 +30,8 @@ var (
)
func TestGarbageCollectCommitGraph(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -66,8 +66,8 @@ func TestGarbageCollectCommitGraph(t *testing.T) {
}
func TestGarbageCollectSuccess(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -137,8 +137,8 @@ func TestGarbageCollectLogStatistics(t *testing.T) {
defer cancel()
ctx = ctxlogrus.ToContext(ctx, log.WithField("test", "logging"))
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -153,8 +153,8 @@ func TestGarbageCollectLogStatistics(t *testing.T) {
}
func TestGarbageCollectDeletesRefsLocks(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -201,8 +201,8 @@ func TestGarbageCollectDeletesRefsLocks(t *testing.T) {
}
func TestGarbageCollectFailure(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -231,8 +231,8 @@ func TestGarbageCollectFailure(t *testing.T) {
}
func TestCleanupInvalidKeepAroundRefs(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -328,8 +328,8 @@ func createFileWithTimes(path string, mTime time.Time) {
}
func TestGarbageCollectDeltaIslands(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/info_attributes_test.go b/internal/service/repository/info_attributes_test.go
index cc867ed68..ef8be18d9 100644
--- a/internal/service/repository/info_attributes_test.go
+++ b/internal/service/repository/info_attributes_test.go
@@ -14,8 +14,8 @@ import (
)
func TestGetInfoAttributesExisting(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -49,8 +49,8 @@ func TestGetInfoAttributesExisting(t *testing.T) {
}
func TestGetInfoAttributesNonExisting(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/license_test.go b/internal/service/repository/license_test.go
index 93d1c6d6a..65a3888e3 100644
--- a/internal/service/repository/license_test.go
+++ b/internal/service/repository/license_test.go
@@ -11,8 +11,8 @@ import (
)
func TestSuccessfulFindLicenseRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -32,8 +32,8 @@ func TestSuccessfulFindLicenseRequest(t *testing.T) {
}
func TestFindLicenseRequestEmptyRepo(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/merge_base_test.go b/internal/service/repository/merge_base_test.go
index 765479520..3ad0b41ae 100644
--- a/internal/service/repository/merge_base_test.go
+++ b/internal/service/repository/merge_base_test.go
@@ -10,8 +10,8 @@ import (
)
func TestSuccessfulFindFindMergeBaseRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -86,8 +86,8 @@ func TestSuccessfulFindFindMergeBaseRequest(t *testing.T) {
}
func TestFailedFindMergeBaseRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/raw_changes_test.go b/internal/service/repository/raw_changes_test.go
index 2aafe4f4d..9cec23f15 100644
--- a/internal/service/repository/raw_changes_test.go
+++ b/internal/service/repository/raw_changes_test.go
@@ -13,8 +13,8 @@ import (
)
func TestGetRawChanges(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -130,8 +130,8 @@ func TestGetRawChangesSpecialCharacters(t *testing.T) {
// This test looks for a specific path known to contain special
// characters.
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -174,8 +174,8 @@ func collectChanges(t *testing.T, stream gitalypb.RepositoryService_GetRawChange
}
func TestGetRawChangesFailures(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -236,8 +236,8 @@ func TestGetRawChangesFailures(t *testing.T) {
}
func TestGetRawChangesManyFiles(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -264,8 +264,8 @@ func TestGetRawChangesManyFiles(t *testing.T) {
}
func TestGetRawChangesMappingOperations(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -315,8 +315,8 @@ func TestGetRawChangesMappingOperations(t *testing.T) {
}
func TestGetRawChangesInvalidUTF8Paths(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/rebase_in_progress_test.go b/internal/service/repository/rebase_in_progress_test.go
index cddc063d4..9a412f9da 100644
--- a/internal/service/repository/rebase_in_progress_test.go
+++ b/internal/service/repository/rebase_in_progress_test.go
@@ -14,8 +14,8 @@ import (
)
func TestSuccessfulIsRebaseInProgressRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -94,8 +94,8 @@ func TestSuccessfulIsRebaseInProgressRequest(t *testing.T) {
}
func TestFailedIsRebaseInProgressRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/remove_test.go b/internal/service/repository/remove_test.go
index 652bccbe5..a4aa21869 100644
--- a/internal/service/repository/remove_test.go
+++ b/internal/service/repository/remove_test.go
@@ -9,8 +9,8 @@ import (
)
func TestRemoveRepository(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -28,8 +28,8 @@ func TestRemoveRepository(t *testing.T) {
}
func TestRemoveRepositoryDoesNotExist(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/rename_test.go b/internal/service/repository/rename_test.go
index 70c8c8ea7..8b4c98a9d 100644
--- a/internal/service/repository/rename_test.go
+++ b/internal/service/repository/rename_test.go
@@ -12,8 +12,8 @@ import (
)
func TestRenameRepositorySuccess(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -45,8 +45,8 @@ func TestRenameRepositorySuccess(t *testing.T) {
}
func TestRenameRepositoryDestinationExists(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -72,8 +72,8 @@ func TestRenameRepositoryDestinationExists(t *testing.T) {
}
func TestRenameRepositoryInvalidRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/repack_test.go b/internal/service/repository/repack_test.go
index 166b963a4..6b2784d69 100644
--- a/internal/service/repository/repack_test.go
+++ b/internal/service/repository/repack_test.go
@@ -23,8 +23,8 @@ import (
)
func TestRepackIncrementalSuccess(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -63,8 +63,8 @@ func TestRepackIncrementalCollectLogStatistics(t *testing.T) {
defer cancel()
ctx = ctxlogrus.ToContext(ctx, log.WithField("test", "logging"))
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -79,8 +79,8 @@ func TestRepackIncrementalCollectLogStatistics(t *testing.T) {
}
func TestRepackLocal(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -118,8 +118,8 @@ func TestRepackLocal(t *testing.T) {
}
func TestRepackIncrementalFailure(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -146,8 +146,8 @@ func TestRepackIncrementalFailure(t *testing.T) {
}
func TestRepackFullSuccess(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -212,8 +212,8 @@ func TestRepackFullCollectLogStatistics(t *testing.T) {
defer cancel()
ctx = ctxlogrus.ToContext(ctx, log.WithField("test", "logging"))
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -254,8 +254,8 @@ func doBitmapsContainHashCache(t *testing.T, bitmapPaths []string) {
}
func TestRepackFullFailure(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -282,8 +282,8 @@ func TestRepackFullFailure(t *testing.T) {
}
func TestRepackFullDeltaIslands(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/replicate_test.go b/internal/service/repository/replicate_test.go
index 3e8b5a6f7..c9beb69ae 100644
--- a/internal/service/repository/replicate_test.go
+++ b/internal/service/repository/replicate_test.go
@@ -179,8 +179,8 @@ func TestReplicateRepositoryInvalidArguments(t *testing.T) {
},
}
- server, serverSocketPath := repository.RunRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := repository.RunRepoServer(t)
+ defer stop()
client, conn := repository.NewRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/repository_test.go b/internal/service/repository/repository_test.go
index ea6e91763..97fbec499 100644
--- a/internal/service/repository/repository_test.go
+++ b/internal/service/repository/repository_test.go
@@ -16,8 +16,8 @@ import (
)
func TestRepositoryExists(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t, testhelper.WithStorages([]string{"default", "other", "broken"}))
+ defer stop()
storageOtherDir, err := ioutil.TempDir("", "gitaly-repository-exists-test")
require.NoError(t, err, "tempdir")
@@ -122,8 +122,8 @@ func TestRepositoryExists(t *testing.T) {
}
func TestSuccessfulHasLocalBranches(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -177,8 +177,8 @@ func TestSuccessfulHasLocalBranches(t *testing.T) {
}
func TestFailedHasLocalBranches(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/restore_custom_hooks_test.go b/internal/service/repository/restore_custom_hooks_test.go
index ebfc4c164..496d5dfbe 100644
--- a/internal/service/repository/restore_custom_hooks_test.go
+++ b/internal/service/repository/restore_custom_hooks_test.go
@@ -15,8 +15,8 @@ import (
)
func TestSuccessfullRestoreCustomHooksRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -59,8 +59,8 @@ func TestSuccessfullRestoreCustomHooksRequest(t *testing.T) {
}
func TestFailedRestoreCustomHooksDueToValidations(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -78,8 +78,8 @@ func TestFailedRestoreCustomHooksDueToValidations(t *testing.T) {
}
func TestFailedRestoreCustomHooksDueToBadTar(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/search_files_test.go b/internal/service/repository/search_files_test.go
index 3aa5204d2..c88dbe6b5 100644
--- a/internal/service/repository/search_files_test.go
+++ b/internal/service/repository/search_files_test.go
@@ -80,8 +80,8 @@ func TestSearchFilesByContentSuccessful(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -152,8 +152,8 @@ func TestSearchFilesByContentLargeFile(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -220,25 +220,21 @@ func TestSearchFilesByContentFailure(t *testing.T) {
query string
ref string
code codes.Code
- msg string
}{
{
desc: "empty request",
code: codes.InvalidArgument,
- msg: "no query given",
},
{
desc: "only query given",
query: "foo",
code: codes.InvalidArgument,
- msg: "no ref given",
},
{
desc: "no repo",
query: "foo",
ref: "master",
code: codes.InvalidArgument,
- msg: "empty Repo",
},
{
desc: "invalid ref argument",
@@ -246,7 +242,6 @@ func TestSearchFilesByContentFailure(t *testing.T) {
query: ".",
ref: "--no-index",
code: codes.InvalidArgument,
- msg: "invalid ref argument",
},
}
@@ -259,7 +254,6 @@ func TestSearchFilesByContentFailure(t *testing.T) {
}, nil)
testhelper.RequireGrpcError(t, err, tc.code)
- require.Contains(t, err.Error(), tc.msg)
})
}
}
@@ -268,8 +262,8 @@ func TestSearchFilesByNameSuccessful(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -318,8 +312,8 @@ func TestSearchFilesByNameFailure(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -330,25 +324,21 @@ func TestSearchFilesByNameFailure(t *testing.T) {
query string
ref string
code codes.Code
- msg string
}{
{
desc: "empty request",
code: codes.InvalidArgument,
- msg: "no query given",
},
{
desc: "only query given",
query: "foo",
code: codes.InvalidArgument,
- msg: "no ref given",
},
{
desc: "no repo",
query: "foo",
ref: "master",
code: codes.InvalidArgument,
- msg: "empty Repo",
},
}
@@ -363,7 +353,6 @@ func TestSearchFilesByNameFailure(t *testing.T) {
_, err = consumeFilenameByName(stream)
testhelper.RequireGrpcError(t, err, tc.code)
- require.Contains(t, err.Error(), tc.msg)
})
}
}
diff --git a/internal/service/repository/size_test.go b/internal/service/repository/size_test.go
index 9643a43c8..b7caaf463 100644
--- a/internal/service/repository/size_test.go
+++ b/internal/service/repository/size_test.go
@@ -15,8 +15,8 @@ import (
const testRepoMinSizeKB = 10000
func TestSuccessfulRepositorySizeRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -37,8 +37,8 @@ func TestSuccessfulRepositorySizeRequest(t *testing.T) {
}
func TestFailedRepositorySizeRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -67,8 +67,8 @@ func TestFailedRepositorySizeRequest(t *testing.T) {
}
func TestSuccessfulGetObjectDirectorySizeRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/snapshot_test.go b/internal/service/repository/snapshot_test.go
index 446efcc7e..5dba549ab 100644
--- a/internal/service/repository/snapshot_test.go
+++ b/internal/service/repository/snapshot_test.go
@@ -25,8 +25,8 @@ import (
)
func getSnapshot(t *testing.T, req *gitalypb.GetSnapshotRequest) ([]byte, error) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/squash_in_progress_test.go b/internal/service/repository/squash_in_progress_test.go
index 9dffb44be..23238fa9b 100644
--- a/internal/service/repository/squash_in_progress_test.go
+++ b/internal/service/repository/squash_in_progress_test.go
@@ -11,8 +11,8 @@ import (
)
func TestSuccessfulIsSquashInProgressRequest(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -62,8 +62,8 @@ func TestSuccessfulIsSquashInProgressRequest(t *testing.T) {
}
func TestFailedIsSquashInProgressRequestDueToValidations(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/repository/testhelper_test.go b/internal/service/repository/testhelper_test.go
index d377ceac2..2f7cf6718 100644
--- a/internal/service/repository/testhelper_test.go
+++ b/internal/service/repository/testhelper_test.go
@@ -3,13 +3,13 @@ package repository
import (
"crypto/x509"
"log"
- "net"
"os"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
gitalyauth "gitlab.com/gitlab-org/gitaly/auth"
"gitlab.com/gitlab-org/gitaly/client"
dcache "gitlab.com/gitlab-org/gitaly/internal/cache"
@@ -17,7 +17,6 @@ import (
mcache "gitlab.com/gitlab-org/gitaly/internal/middleware/cache"
"gitlab.com/gitlab-org/gitaly/internal/praefect/protoregistry"
"gitlab.com/gitlab-org/gitaly/internal/rubyserver"
- "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"
@@ -37,8 +36,9 @@ var (
func newRepositoryClient(t *testing.T, serverSocketPath string) (gitalypb.RepositoryServiceClient, *grpc.ClientConn) {
connOpts := []grpc.DialOption{
grpc.WithInsecure(),
- grpc.WithPerRPCCredentials(gitalyauth.RPCCredentials(testhelper.RepositoryAuthToken)),
+ grpc.WithPerRPCCredentials(gitalyauth.RPCCredentials(config.Config.Auth.Token)),
}
+
conn, err := grpc.Dial(serverSocketPath, connOpts...)
if err != nil {
t.Fatal(err)
@@ -53,7 +53,7 @@ var RunRepoServer = runRepoServer
func newSecureRepoClient(t *testing.T, serverSocketPath string, pool *x509.CertPool) (gitalypb.RepositoryServiceClient, *grpc.ClientConn) {
connOpts := []grpc.DialOption{
grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(pool, "")),
- grpc.WithPerRPCCredentials(gitalyauth.RPCCredentials(testhelper.RepositoryAuthToken)),
+ grpc.WithPerRPCCredentials(gitalyauth.RPCCredentials(config.Config.Auth.Token)),
}
conn, err := client.Dial(serverSocketPath, connOpts)
@@ -66,35 +66,27 @@ func newSecureRepoClient(t *testing.T, serverSocketPath string, pool *x509.CertP
var NewSecureRepoClient = newSecureRepoClient
-func runRepoServer(t *testing.T) (*grpc.Server, string) {
+func runRepoServer(t *testing.T, opts ...testhelper.TestServerOpt) (func(), string) {
streamInt := []grpc.StreamServerInterceptor{
- auth.StreamServerInterceptor(config.Config.Auth),
mcache.StreamInvalidator(dcache.LeaseKeyer{}, protoregistry.GitalyProtoPreregistered),
}
unaryInt := []grpc.UnaryServerInterceptor{
- auth.UnaryServerInterceptor(config.Config.Auth),
mcache.UnaryInvalidator(dcache.LeaseKeyer{}, protoregistry.GitalyProtoPreregistered),
}
- server := testhelper.NewTestGrpcServer(t, streamInt, unaryInt)
- serverSocketPath := testhelper.GetTemporaryGitalySocketFileName()
-
- listener, err := net.Listen("unix", serverSocketPath)
- if err != nil {
- t.Fatal(err)
- }
+ srv := testhelper.NewServerWithAuth(t, streamInt, unaryInt, config.Config.Auth.Token, opts...)
- gitalypb.RegisterRepositoryServiceServer(server, NewServer(RubyServer, config.GitalyInternalSocketPath()))
- reflection.Register(server)
+ gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), NewServer(RubyServer, config.GitalyInternalSocketPath()))
+ reflection.Register(srv.GrpcServer())
- go server.Serve(listener)
+ require.NoError(t, srv.Start())
- return server, "unix://" + serverSocketPath
+ return srv.Stop, "unix://" + srv.Socket()
}
func TestRepoNoAuth(t *testing.T) {
- srv, path := runRepoServer(t)
- defer srv.Stop()
+ stop, path := runRepoServer(t)
+ defer stop()
connOpts := []grpc.DialOption{
grpc.WithInsecure(),
diff --git a/internal/service/repository/write_ref_test.go b/internal/service/repository/write_ref_test.go
index 905515a7e..df240b8d6 100644
--- a/internal/service/repository/write_ref_test.go
+++ b/internal/service/repository/write_ref_test.go
@@ -12,8 +12,8 @@ import (
)
func TestWriteRefSuccessful(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
@@ -78,8 +78,8 @@ func TestWriteRefSuccessful(t *testing.T) {
}
func TestWriteRefValidationError(t *testing.T) {
- server, serverSocketPath := runRepoServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runRepoServer(t)
+ defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
diff --git a/internal/service/smarthttp/inforefs_test.go b/internal/service/smarthttp/inforefs_test.go
index 9cbb1fcaa..0e0c4efe1 100644
--- a/internal/service/smarthttp/inforefs_test.go
+++ b/internal/service/smarthttp/inforefs_test.go
@@ -26,8 +26,8 @@ import (
)
func TestSuccessfulInfoRefsUploadPack(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSmartHTTPServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
@@ -43,8 +43,8 @@ func TestSuccessfulInfoRefsUploadPack(t *testing.T) {
}
func TestSuccessfulInfoRefsUploadPackWithGitConfigOptions(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSmartHTTPServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
@@ -65,8 +65,8 @@ func TestSuccessfulInfoRefsUploadPackWithGitProtocol(t *testing.T) {
restore := testhelper.EnableGitProtocolV2Support()
defer restore()
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSmartHTTPServer(t)
+ defer stop()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
@@ -116,8 +116,8 @@ func makeInfoRefsUploadPackRequest(ctx context.Context, t *testing.T, serverSock
}
func TestSuccessfulInfoRefsReceivePack(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -149,8 +149,8 @@ func TestSuccessfulInfoRefsReceivePack(t *testing.T) {
}
func TestObjectPoolRefAdvertisementHiding(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -186,8 +186,8 @@ func TestObjectPoolRefAdvertisementHiding(t *testing.T) {
}
func TestFailureRepoNotFoundInfoRefsReceivePack(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -208,8 +208,8 @@ func TestFailureRepoNotFoundInfoRefsReceivePack(t *testing.T) {
}
func TestFailureRepoNotSetInfoRefsReceivePack(t *testing.T) {
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSmartHTTPServer(t)
+ defer stop()
client, conn := newSmartHTTPClient(t, serverSocketPath)
defer conn.Close()
@@ -250,8 +250,8 @@ func assertGitRefAdvertisement(t *testing.T, rpc, responseBody string, firstLine
func TestCacheInfoRefsUploadPack(t *testing.T) {
clearCache(t)
- server, serverSocketPath := runSmartHTTPServer(t)
- defer server.Stop()
+ stop, serverSocketPath := 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..1eb49876b 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, socket := 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..aa300b59f 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) (func(), string) {
+ 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 srv.Stop, "unix://" + srv.Socket()
}
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..6a32d4f58 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..dc1784cd3 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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..4cb526179 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) (func(), string) {
+ 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 srv.Stop, "unix://" + srv.Socket()
}
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..0df758172 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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()
+ stop, serverSocketPath := 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 d3936461d..67e5b366a 100644
--- a/internal/service/ssh/upload_pack_test.go
+++ b/internal/service/ssh/upload_pack_test.go
@@ -21,9 +21,9 @@ import (
)
func TestFailedUploadPackRequestDueToTimeout(t *testing.T) {
- server, serverSocketPath := runSSHServer(t, WithUploadPackRequestTimeout(10*time.Microsecond))
+ stop, serverSocketPath := runSSHServer(t, WithUploadPackRequestTimeout(10*time.Microsecond))
- defer server.Stop()
+ defer stop()
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -77,8 +77,8 @@ func requireFailedSSHStream(t *testing.T, recv func() (int32, error)) {
}
func TestFailedUploadPackRequestDueToValidationError(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSSHServer(t)
+ defer stop()
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -126,8 +126,8 @@ func TestFailedUploadPackRequestDueToValidationError(t *testing.T) {
}
func TestUploadPackCloneSuccess(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSSHServer(t)
+ defer stop()
localRepoPath := path.Join(testRepoRoot, "gitlab-test-upload-pack-local")
@@ -158,8 +158,8 @@ func TestUploadPackCloneSuccessWithGitProtocol(t *testing.T) {
restore := testhelper.EnableGitProtocolV2Support()
defer restore()
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSSHServer(t)
+ defer stop()
localRepoPath := path.Join(testRepoRoot, "gitlab-test-upload-pack-local")
@@ -192,8 +192,8 @@ func TestUploadPackCloneSuccessWithGitProtocol(t *testing.T) {
}
func TestUploadPackCloneHideTags(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ stop, serverSocketPath := runSSHServer(t)
+ defer stop()
localRepoPath := path.Join(testRepoRoot, "gitlab-test-upload-pack-local-hide-tags")
@@ -213,8 +213,8 @@ func TestUploadPackCloneHideTags(t *testing.T) {
}
func TestUploadPackCloneFailure(t *testing.T) {
- server, serverSocketPath := runSSHServer(t)
- defer server.Stop()
+ stop, serverSocketPath := 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()
diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go
index 6fa2f865f..d91043923 100644
--- a/internal/testhelper/testserver.go
+++ b/internal/testhelper/testserver.go
@@ -22,11 +22,14 @@ import (
grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
log "github.com/sirupsen/logrus"
"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/config/auth"
"gitlab.com/gitlab-org/gitaly/internal/git/hooks"
"gitlab.com/gitlab-org/gitaly/internal/helper/fieldextractors"
praefectconfig "gitlab.com/gitlab-org/gitaly/internal/praefect/config"
"gitlab.com/gitlab-org/gitaly/internal/praefect/models"
+ serverauth "gitlab.com/gitlab-org/gitaly/internal/server/auth"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
@@ -34,11 +37,62 @@ import (
"gopkg.in/yaml.v2"
)
+// PraefectEnabled returns whether or not tests should use a praefect proxy
+func PraefectEnabled() bool {
+ _, ok := os.LookupEnv("GITALY_TEST_PRAEFECT_BIN")
+ return ok
+}
+
+// TestServerOpt is an option for TestServer
+type TestServerOpt func(t *TestServer)
+
+// WithToken is a TestServerOpt that provides a security token
+func WithToken(token string) TestServerOpt {
+ return func(t *TestServer) {
+ t.token = token
+ }
+}
+
+// WithStorages is a TestServerOpt that sets the storages for a TestServer
+func WithStorages(storages []string) TestServerOpt {
+ return func(t *TestServer) {
+ t.storages = storages
+ }
+}
+
// NewTestServer instantiates a new TestServer
-func NewTestServer(srv *grpc.Server) *TestServer {
- return &TestServer{
+func NewTestServer(srv *grpc.Server, opts ...TestServerOpt) *TestServer {
+ ts := &TestServer{
grpcServer: srv,
}
+
+ for _, opt := range opts {
+ opt(ts)
+ }
+
+ if len(ts.storages) == 0 {
+ ts.storages = []string{"default"}
+ }
+
+ return ts
+}
+
+// NewServerWithAuth creates a new test server with authentication
+func NewServerWithAuth(tb testing.TB, streamInterceptors []grpc.StreamServerInterceptor, unaryInterceptors []grpc.UnaryServerInterceptor, token string, opts ...TestServerOpt) *TestServer {
+ if token != "" {
+ if PraefectEnabled() {
+ opts = append(opts, WithToken(token))
+ }
+ streamInterceptors = append(streamInterceptors, serverauth.StreamServerInterceptor(auth.Config{Token: token}))
+ unaryInterceptors = append(unaryInterceptors, serverauth.UnaryServerInterceptor(auth.Config{Token: token}))
+ }
+
+ return NewServer(
+ tb,
+ streamInterceptors,
+ unaryInterceptors,
+ opts...,
+ )
}
// TestServer wraps a grpc Server and handles automatically putting a praefect in front of a gitaly instance
@@ -47,6 +101,8 @@ type TestServer struct {
grpcServer *grpc.Server
socket string
process *os.Process
+ token string
+ storages []string
}
// GrpcServer returns the underlying grpc.Server
@@ -101,18 +157,23 @@ func (p *TestServer) Start() error {
c := praefectconfig.Config{
SocketPath: praefectServerSocketPath,
- VirtualStorages: []*praefectconfig.VirtualStorage{
- {
- Name: "default",
- Nodes: []*models.Node{
- {
- Storage: "default",
- Address: "unix:/" + gitalyServerSocketPath,
- DefaultPrimary: true,
- },
+ Auth: auth.Config{
+ Token: p.token,
+ },
+ }
+
+ for _, storage := range p.storages {
+ c.VirtualStorages = append(c.VirtualStorages, &praefectconfig.VirtualStorage{
+ Name: storage,
+ Nodes: []*models.Node{
+ {
+ Storage: storage,
+ Address: "unix:/" + gitalyServerSocketPath,
+ DefaultPrimary: true,
+ Token: p.token,
},
},
- },
+ })
}
if err := toml.NewEncoder(configFile).Encode(&c); err != nil {
@@ -134,7 +195,12 @@ func (p *TestServer) Start() error {
}
go cmd.Wait()
- conn, err := grpc.Dial("unix://"+praefectServerSocketPath, grpc.WithInsecure())
+ opts := []grpc.DialOption{grpc.WithInsecure()}
+ if p.token != "" {
+ opts = append(opts, grpc.WithPerRPCCredentials(gitalyauth.RPCCredentials(p.token)))
+ }
+
+ conn, err := grpc.Dial("unix://"+praefectServerSocketPath, opts...)
if err != nil {
return fmt.Errorf("dial: %v", err)
@@ -169,7 +235,7 @@ func waitForPraefectStartup(conn *grpc.ClientConn) error {
}
// NewServer creates a Server for testing purposes
-func NewServer(tb testing.TB, streamInterceptors []grpc.StreamServerInterceptor, unaryInterceptors []grpc.UnaryServerInterceptor) *TestServer {
+func NewServer(tb testing.TB, streamInterceptors []grpc.StreamServerInterceptor, unaryInterceptors []grpc.UnaryServerInterceptor, opts ...TestServerOpt) *TestServer {
logger := NewTestLogger(tb)
logrusEntry := log.NewEntry(logger).WithField("test", tb.Name())
@@ -184,7 +250,9 @@ func NewServer(tb testing.TB, streamInterceptors []grpc.StreamServerInterceptor,
grpc.NewServer(
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(streamInterceptors...)),
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(unaryInterceptors...)),
- ))
+ ),
+ opts...,
+ )
}
var changeLineRegex = regexp.MustCompile("^[a-f0-9]{40} [a-f0-9]{40} refs/[^ ]+$")