diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-12-07 11:33:54 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-12-13 15:32:45 +0300 |
commit | 180873d8a17b70a868860c1d688d38fb3a158d0b (patch) | |
tree | f8d48c20827c5b59259fab644235fc946b488829 | |
parent | 581bd110aa83385b3c864c780b1dd721a8f37c20 (diff) |
repository: Speed up tests for pruning of locks in garbage collection
The tests that verify we correctly prune stale locks during garbage
collection are quite slow. For one this is caused by these tests not
being parallelized. But we also create seeded repositories, which will
then cause us to repack these repositories' objects.
Refactor the code to create unseeded repositories instead. We don't test
for the repacking logic anyway, but really only care about whether the
locks are removed as expected. This speeds up the time to execute those
tests. Before:
ok gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/service/repository 2.670s
After:
ok gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/service/repository 1.280s
-rw-r--r-- | internal/gitaly/service/repository/gc_test.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go index d1c8a53e4..28572124b 100644 --- a/internal/gitaly/service/repository/gc_test.go +++ b/internal/gitaly/service/repository/gc_test.go @@ -301,13 +301,15 @@ func TestGarbageCollectDeletesFileLocks(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { + t.Parallel() + // Create a lockfile and run GarbageCollect. Because the lock has been // freshly created GarbageCollect shouldn't remove the not-yet-stale // lockfile. t.Run("with recent lockfile", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ - Seed: gittest.SeedGitLabTest, - }) + t.Parallel() + + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) lockPath := filepath.Join(repoPath, tc.lockfile) mustCreateFileWithTimes(t, lockPath, time.Now()) @@ -328,9 +330,9 @@ func TestGarbageCollectDeletesFileLocks(t *testing.T) { // Redo the same test, but this time we create the lockfile so that it is // considered stale. GarbageCollect should know to remove it. t.Run("with stale lockfile", func(t *testing.T) { - repo, repoPath := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ - Seed: gittest.SeedGitLabTest, - }) + t.Parallel() + + repo, repoPath := gittest.CreateRepository(t, ctx, cfg) lockPath := filepath.Join(repoPath, tc.lockfile) mustCreateFileWithTimes(t, lockPath, time.Now().Add(offsetUntilOld)) |