1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package objectpool
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/internal/backchannel"
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/housekeeping"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
)
func TestMain(m *testing.M) {
testhelper.Run(m)
}
func setupObjectPool(t *testing.T, ctx context.Context) (config.Cfg, *ObjectPool, *gitalypb.Repository) {
t.Helper()
cfg, repo, _ := testcfg.BuildWithRepo(t)
gitCommandFactory := gittest.NewCommandFactory(t, cfg, git.WithSkipHooks())
catfileCache := catfile.NewCache(cfg)
t.Cleanup(catfileCache.Stop)
txManager := transaction.NewManager(cfg, backchannel.NewRegistry())
pool, err := NewObjectPool(
config.NewLocator(cfg),
gitCommandFactory,
catfileCache,
txManager,
housekeeping.NewManager(cfg.Prometheus, txManager),
repo.GetStorageName(),
gittest.NewObjectPoolName(t),
)
require.NoError(t, err)
t.Cleanup(func() {
if err := pool.Remove(ctx); err != nil {
panic(err)
}
})
return cfg, pool, repo
}
|