diff options
Diffstat (limited to 'internal/gitaly/storage/storagemgr/testhelper_test.go')
-rw-r--r-- | internal/gitaly/storage/storagemgr/testhelper_test.go | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/internal/gitaly/storage/storagemgr/testhelper_test.go b/internal/gitaly/storage/storagemgr/testhelper_test.go index dcd8bb58c..1d9798e6a 100644 --- a/internal/gitaly/storage/storagemgr/testhelper_test.go +++ b/internal/gitaly/storage/storagemgr/testhelper_test.go @@ -77,6 +77,8 @@ type PackfilesState struct { PooledObjects []git.ObjectID // HasMultiPackIndex asserts whether there is a multi-pack-index inside the objects/pack directory. HasMultiPackIndex bool + // HasCommitGraphs assert whether the repository has valid commit graphs. + HasCommitGraphs bool } // PackfileState describes the asserted state of an individual packfile, including its contained objects, index, bitmap. @@ -336,6 +338,10 @@ func collectPackfilesState(tb testing.TB, repoPath string, cfg config.Cfg, objec require.NoError(tb, err) } + info, err := stats.CommitGraphInfoForRepository(repoPath) + require.NoError(tb, err) + state.HasCommitGraphs = info.Exists + return state } @@ -454,10 +460,12 @@ type testTransactionTag struct { } type testTransactionCommits struct { - First testTransactionCommit - Second testTransactionCommit - Third testTransactionCommit - Diverging testTransactionCommit + First testTransactionCommit + Second testTransactionCommit + Third testTransactionCommit + Diverging testTransactionCommit + Orphan testTransactionCommit + Unreachable testTransactionCommit } type testTransactionSetup struct { @@ -557,6 +565,14 @@ type RunPackRefs struct { TransactionID int } +// RunRepack calls repack housekeeping task on a transaction. +type RunRepack struct { + // TransactionID is the transaction for which the repack task runs. + TransactionID int + // Config is the desired repacking config for the task. + Config housekeeping.RepackObjectsConfig +} + // Commit calls Commit on a transaction. type Commit struct { // TransactionID identifies the transaction to commit. @@ -777,7 +793,7 @@ func runTransactionTest(t *testing.T, ctx context.Context, tc transactionTestCas transaction, err := transactionManager.Begin(beginCtx, step.RelativePath, step.SnapshottedRelativePaths, step.ReadOnly) require.ErrorIs(t, err, step.ExpectedError) if err == nil { - require.Equal(t, step.ExpectedSnapshotLSN, transaction.SnapshotLSN()) + require.Equalf(t, step.ExpectedSnapshotLSN, transaction.SnapshotLSN(), "mismatched ExpectedSnapshotLSN") } if step.ReadOnly { @@ -936,6 +952,11 @@ func runTransactionTest(t *testing.T, ctx context.Context, tc transactionTestCas transaction := openTransactions[step.TransactionID] transaction.PackRefs() + case RunRepack: + require.Contains(t, openTransactions, step.TransactionID, "test error: repack housekeeping task aborted on committed before beginning it") + + transaction := openTransactions[step.TransactionID] + transaction.Repack(step.Config) case RepositoryAssertion: require.Contains(t, openTransactions, step.TransactionID, "test error: transaction's snapshot asserted before beginning it") transaction := openTransactions[step.TransactionID] |