diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-12-16 15:11:45 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-12-20 09:48:52 +0300 |
commit | 7bfb4536e3e3b133ec2236bd35b5c2a0381f4a87 (patch) | |
tree | b9e9be14b073c2baf19639aa9de57a79b58bc6c1 | |
parent | 33062dcded86a2549a0c69debb54c04c95e473d9 (diff) |
housekeeping: Enable testing stale-data-related logic with SHA256
Refactor stale-data-related tests to not use the seed repository anymore
and enable testing with SHA256.
-rw-r--r-- | internal/git/housekeeping/clean_stale_data_test.go | 57 |
1 files changed, 44 insertions, 13 deletions
diff --git a/internal/git/housekeeping/clean_stale_data_test.go b/internal/git/housekeeping/clean_stale_data_test.go index abe931396..2a8283bc5 100644 --- a/internal/git/housekeeping/clean_stale_data_test.go +++ b/internal/git/housekeeping/clean_stale_data_test.go @@ -1,5 +1,3 @@ -//go:build !gitaly_test_sha256 - package housekeeping import ( @@ -278,9 +276,13 @@ func TestRepositoryManager_CleanStaleData(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() - cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) - repo := localrepo.NewTestRepo(t, cfg, repoProto) ctx := testhelper.Context(t) + cfg := testcfg.Build(t) + + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ + SkipCreationViaService: true, + }) + repo := localrepo.NewTestRepo(t, cfg, repoProto) // We need to fix permissions so we don't fail to // remove the temporary directory after the test. @@ -380,7 +382,12 @@ func TestRepositoryManager_CleanStaleData_references(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { t.Parallel() - cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) + ctx := testhelper.Context(t) + cfg := testcfg.Build(t) + + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ + SkipCreationViaService: true, + }) repo := localrepo.NewTestRepo(t, cfg, repoProto) for _, ref := range tc.refs { @@ -391,7 +398,6 @@ func TestRepositoryManager_CleanStaleData_references(t *testing.T) { filetime := time.Now().Add(-ref.age) require.NoError(t, os.Chtimes(path, filetime, filetime)) } - ctx := testhelper.Context(t) mgr := NewManager(cfg.Prometheus, nil) @@ -508,9 +514,13 @@ func TestRepositoryManager_CleanStaleData_emptyRefDirs(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() - cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) - repo := localrepo.NewTestRepo(t, cfg, repoProto) ctx := testhelper.Context(t) + cfg := testcfg.Build(t) + + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ + SkipCreationViaService: true, + }) + repo := localrepo.NewTestRepo(t, cfg, repoProto) for _, e := range tc.entries { e.create(t, repoPath) @@ -635,8 +645,11 @@ func TestRepositoryManager_CleanStaleData_withSpecificFile(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) + cfg := testcfg.Build(t) - cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ + SkipCreationViaService: true, + }) repo := localrepo.NewTestRepo(t, cfg, repoProto) mgr := NewManager(cfg.Prometheus, nil) @@ -697,9 +710,13 @@ func TestRepositoryManager_CleanStaleData_withSpecificFile(t *testing.T) { func TestRepositoryManager_CleanStaleData_serverInfo(t *testing.T) { t.Parallel() + ctx := testhelper.Context(t) + cfg := testcfg.Build(t) - cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ + SkipCreationViaService: true, + }) repo := localrepo.NewTestRepo(t, cfg, repoProto) entries := []entry{ @@ -811,7 +828,12 @@ func TestRepositoryManager_CleanStaleData_referenceLocks(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { t.Parallel() - cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) + + cfg := testcfg.Build(t) + + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ + SkipCreationViaService: true, + }) repo := localrepo.NewTestRepo(t, cfg, repoProto) for _, e := range tc.entries { @@ -930,9 +952,14 @@ func TestIsStaleTemporaryObject(t *testing.T) { func TestRepositoryManager_CleanStaleData_missingRepo(t *testing.T) { t.Parallel() - cfg, repoProto, repoPath := testcfg.BuildWithRepo(t) - repo := localrepo.NewTestRepo(t, cfg, repoProto) + ctx := testhelper.Context(t) + cfg := testcfg.Build(t) + + repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ + SkipCreationViaService: true, + }) + repo := localrepo.NewTestRepo(t, cfg, repoProto) require.NoError(t, os.RemoveAll(repoPath)) @@ -1023,6 +1050,10 @@ func TestRepositoryManager_CleanStaleData_unsetConfigurationTransactional(t *tes expectedConfig := "core.repositoryformatversion\ncore.filemode\ncore.bare\n" + if gittest.DefaultObjectHash.Format == "sha256" { + expectedConfig = expectedConfig + "extensions.objectformat\n" + } + if runtime.GOOS == "darwin" { expectedConfig = expectedConfig + "core.ignorecase\ncore.precomposeunicode\n" } |