diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2023-09-26 20:51:42 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2023-09-29 14:04:59 +0300 |
commit | 70a118b3f315e1665cd0cd71c844e54af100a350 (patch) | |
tree | 587a218ddedcb3c9d6b15354bfadaf99ec11fba3 | |
parent | f71e7fe13c3e3207d592d77a15a9618c20b46bd9 (diff) |
Setup TransactionManager's state and staging directories in storage
TransactionManager's tests are currently not setting up the staging
and state directories as they'd be configured in production. They're
generally set up by the PartitionManager which is not used in
TransactionManager's tests. This commit configures the tests to set
up both directories withing the storage directory. This is necessary
as we're about to do some relative path mangling which will verify
that relative paths don't point outside of the storage.
-rw-r--r-- | internal/gitaly/storage/storagemgr/transaction_manager_test.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/internal/gitaly/storage/storagemgr/transaction_manager_test.go b/internal/gitaly/storage/storagemgr/transaction_manager_test.go index 7575861c6..33375b174 100644 --- a/internal/gitaly/storage/storagemgr/transaction_manager_test.go +++ b/internal/gitaly/storage/storagemgr/transaction_manager_test.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "sort" + "strconv" "strings" "sync" "testing" @@ -4017,13 +4018,14 @@ func TestTransactionManager(t *testing.T) { require.NoError(t, err) defer testhelper.MustClose(t, database) - stateDir := filepath.Join(setup.Config.Storages[0].Path, "state") + txManager := transaction.NewManager(setup.Config, backchannel.NewRegistry()) + housekeepingManager := housekeeping.NewManager(setup.Config.Prometheus, txManager) - stagingDir := t.TempDir() storagePath := setup.Config.Storages[0].Path + stateDir := filepath.Join(storagePath, "state") - txManager := transaction.NewManager(setup.Config, backchannel.NewRegistry()) - housekeepingManager := housekeeping.NewManager(setup.Config.Prometheus, txManager) + stagingDir := filepath.Join(storagePath, "staging") + require.NoError(t, os.Mkdir(stagingDir, perm.PrivateDir)) var ( // managerRunning tracks whether the manager is running or closed. @@ -4478,7 +4480,15 @@ func BenchmarkTransactionManager(b *testing.B) { commit1 = gittest.WriteCommit(b, cfg, repoPath, gittest.WithParents()) commit2 = gittest.WriteCommit(b, cfg, repoPath, gittest.WithParents(commit1)) - manager := NewTransactionManager(database, cfg.Storages[0].Path, repo.RelativePath, b.TempDir(), b.TempDir(), cmdFactory, housekeepingManager, repositoryFactory) + storagePath := cfg.Storages[0].Path + + stateDir := filepath.Join(storagePath, "state", strconv.Itoa(i)) + require.NoError(b, os.MkdirAll(stateDir, perm.PrivateDir)) + + stagingDir := filepath.Join(storagePath, "staging", strconv.Itoa(i)) + require.NoError(b, os.MkdirAll(stagingDir, perm.PrivateDir)) + + manager := NewTransactionManager(database, storagePath, repo.RelativePath, stateDir, stagingDir, cmdFactory, housekeepingManager, repositoryFactory) managers = append(managers, manager) |