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:
authorToon Claes <toon@gitlab.com>2021-03-16 20:41:51 +0300
committerToon Claes <toon@gitlab.com>2021-03-16 20:41:51 +0300
commit51f43bcd5e747ea497a5562bb31f09aaa260cf86 (patch)
treeebc7231eb350af18a6db031450cd0de5708222b2
parent371ec6373c78fd14580d6461af6c047a9d0e858e (diff)
parent83563969bb73c9354752e1429d9827044c64e0b5 (diff)
Merge branch 'ps-rm-config-cleanup' into 'master'
Removal of the config.Config from cleanup package See merge request gitlab-org/gitaly!3255
-rw-r--r--internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go33
-rw-r--r--internal/gitaly/service/cleanup/testhelper_test.go18
2 files changed, 27 insertions, 24 deletions
diff --git a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
index 4e9558b76..c123283ec 100644
--- a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
+++ b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
@@ -10,24 +10,18 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
- "gitlab.com/gitlab-org/gitaly/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/internal/git/localrepo"
- "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc/codes"
)
func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
- serverSocketPath, stop := runCleanupServiceServer(t, config.Config)
- defer stop()
+ cfg, protoRepo, repoPath, client := setupCleanupService(t)
- client, conn := newCleanupServiceClient(t, serverSocketPath)
- defer conn.Close()
+ testhelper.ConfigureGitalyHooksBin(t, cfg)
- testRepo, testRepoPath, cleanupFn := gittest.CloneRepo(t)
- defer cleanupFn()
- repo := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(cfg), protoRepo, cfg)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -46,7 +40,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
"refs/environments/1", "refs/keep-around/1", "refs/merge-requests/1", "refs/pipelines/1",
"refs/heads/_keep", "refs/tags/_keep", "refs/notes/_keep",
} {
- testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "update-ref", ref, headCommit.Id)
+ testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "update-ref", ref, headCommit.Id)
}
// Create some refs pointing to ref/tags/v1.0.0, simulating an unmodified
@@ -54,7 +48,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
for _, ref := range []string{
"refs/environments/_keep", "refs/keep-around/_keep", "refs/merge-requests/_keep", "refs/pipelines/_keep",
} {
- testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "update-ref", ref, tagID)
+ testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "update-ref", ref, tagID)
}
const filterRepoCommitMapHeader = "old new\n"
@@ -67,7 +61,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
tagID, tagID,
)
- entries, err := doStreamingRequest(ctx, t, testRepo, client, objectMapData)
+ entries, err := doStreamingRequest(ctx, t, protoRepo, client, objectMapData)
require.NoError(t, err)
// Ensure that the internal refs are gone, but the others still exist
@@ -100,30 +94,27 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
}
func requireEntry(t *testing.T, entry *gitalypb.ApplyBfgObjectMapStreamResponse_Entry, oldOid, newOid string, objectType gitalypb.ObjectType) {
+ t.Helper()
+
require.Equal(t, objectType, entry.Type)
require.Equal(t, oldOid, entry.OldOid)
require.Equal(t, newOid, entry.NewOid)
}
func TestApplyBfgObjectMapStreamFailsOnInvalidInput(t *testing.T) {
- serverSocketPath, stop := runCleanupServiceServer(t, config.Config)
- defer stop()
-
- client, conn := newCleanupServiceClient(t, serverSocketPath)
- defer conn.Close()
-
- testRepo, _, cleanupFn := gittest.CloneRepo(t)
- defer cleanupFn()
+ _, repo, _, client := setupCleanupService(t)
ctx, cancel := testhelper.Context()
defer cancel()
- entries, err := doStreamingRequest(ctx, t, testRepo, client, "invalid-data here as you can see")
+ entries, err := doStreamingRequest(ctx, t, repo, client, "invalid-data here as you can see")
require.Empty(t, entries)
testhelper.RequireGrpcError(t, err, codes.InvalidArgument)
}
func doStreamingRequest(ctx context.Context, t *testing.T, repo *gitalypb.Repository, client gitalypb.CleanupServiceClient, objectMap string) ([]*gitalypb.ApplyBfgObjectMapStreamResponse_Entry, error) {
+ t.Helper()
+
// Split the data across multiple requests
parts := strings.SplitN(objectMap, " ", 2)
req1 := &gitalypb.ApplyBfgObjectMapStreamRequest{
diff --git a/internal/gitaly/service/cleanup/testhelper_test.go b/internal/gitaly/service/cleanup/testhelper_test.go
index c6a44b44b..4adb3eafa 100644
--- a/internal/gitaly/service/cleanup/testhelper_test.go
+++ b/internal/gitaly/service/cleanup/testhelper_test.go
@@ -10,6 +10,7 @@ import (
hookservice "gitlab.com/gitlab-org/gitaly/internal/gitaly/service/hook"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
+ "gitlab.com/gitlab-org/gitaly/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
@@ -23,11 +24,21 @@ func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
cleanup := testhelper.Configure()
defer cleanup()
- testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir)
return m.Run()
}
-func runCleanupServiceServer(t *testing.T, cfg config.Cfg) (string, func()) {
+func setupCleanupService(t *testing.T) (config.Cfg, *gitalypb.Repository, string, gitalypb.CleanupServiceClient) {
+ cfg, repo, repoPath := testcfg.BuildWithRepo(t)
+
+ serverSocketPath := runCleanupServiceServer(t, cfg)
+
+ client, conn := newCleanupServiceClient(t, serverSocketPath)
+ t.Cleanup(func() { conn.Close() })
+
+ return cfg, repo, repoPath, client
+}
+
+func runCleanupServiceServer(t *testing.T, cfg config.Cfg) string {
srv := testhelper.NewServer(t, nil, nil, testhelper.WithInternalSocket(cfg))
locator := config.NewLocator(cfg)
@@ -44,8 +55,9 @@ func runCleanupServiceServer(t *testing.T, cfg config.Cfg) (string, func()) {
reflection.Register(srv.GrpcServer())
srv.Start(t)
+ t.Cleanup(srv.Stop)
- return "unix://" + srv.Socket(), srv.Stop
+ return "unix://" + srv.Socket()
}
func newCleanupServiceClient(t *testing.T, serverSocketPath string) (gitalypb.CleanupServiceClient, *grpc.ClientConn) {