Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-08 17:02:18 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-13 09:47:19 +0300
commitdac1c323929b21e9ab0fc98af3e79dec3495b2a0 (patch)
tree7d7c1d41a2c03b5c411174aa9cda8bec0041e348 /internal
parent5a38b03f6bce4c3cd329c835e8c2fbbeb6b65608 (diff)
tests: Convert to use `transaction.TrackingManager`
Convert tests to use the new `transaction.TrackingManager`, which simply records all votes which have been cast.
Diffstat (limited to 'internal')
-rw-r--r--internal/git/housekeeping/housekeeping_test.go13
-rw-r--r--internal/git/localrepo/config_test.go24
-rw-r--r--internal/git/objectpool/link_test.go13
-rw-r--r--internal/gitaly/service/operations/apply_patch_test.go16
-rw-r--r--internal/gitaly/service/operations/rebase_test.go14
-rw-r--r--internal/gitaly/service/ref/delete_refs_test.go13
-rw-r--r--internal/gitaly/service/repository/create_repository_from_bundle_test.go32
-rw-r--r--internal/gitaly/service/repository/create_repository_test.go29
-rw-r--r--internal/gitaly/service/repository/fetch_remote_test.go18
-rw-r--r--internal/gitaly/service/repository/midx_test.go11
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go18
11 files changed, 51 insertions, 150 deletions
diff --git a/internal/git/housekeeping/housekeeping_test.go b/internal/git/housekeeping/housekeeping_test.go
index c70143080..2daae8b96 100644
--- a/internal/git/housekeeping/housekeeping_test.go
+++ b/internal/git/housekeeping/housekeeping_test.go
@@ -2,7 +2,6 @@ package housekeeping
import (
"bytes"
- "context"
"fmt"
"os"
"path/filepath"
@@ -20,7 +19,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"google.golang.org/grpc/peer"
)
@@ -706,13 +704,7 @@ func TestPerform_UnsetConfiguration_transactional(t *testing.T) {
gittest.Exec(t, cfg, "-C", repoPath, "config", "http.some.extraHeader", "value")
- votes := 0
- txManager := &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- votes++
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
@@ -721,8 +713,7 @@ func TestPerform_UnsetConfiguration_transactional(t *testing.T) {
})
require.NoError(t, Perform(ctx, repo, txManager))
-
- require.Equal(t, 2, votes)
+ require.Equal(t, 2, len(txManager.Votes()))
configKeys := gittest.Exec(t, cfg, "-C", repoPath, "config", "--list", "--local", "--name-only")
diff --git a/internal/git/localrepo/config_test.go b/internal/git/localrepo/config_test.go
index e0d188cf4..2a31977a7 100644
--- a/internal/git/localrepo/config_test.go
+++ b/internal/git/localrepo/config_test.go
@@ -1,7 +1,6 @@
package localrepo
import (
- "context"
"fmt"
"path/filepath"
"runtime"
@@ -18,7 +17,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"google.golang.org/grpc/peer"
)
@@ -121,17 +119,12 @@ func TestRepo_SetConfig(t *testing.T) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
ctx = peer.NewContext(ctx, backchannelPeer)
- votes := 0
+ txManager := transaction.NewTrackingManager()
require.NoError(t, err)
- require.NoError(t, repo.SetConfig(ctx, "some.key", "value", &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- votes++
- return nil
- },
- }))
+ require.NoError(t, repo.SetConfig(ctx, "some.key", "value", txManager))
- require.Equal(t, 2, votes)
+ require.Equal(t, 2, len(txManager.Votes()))
})
}
@@ -262,16 +255,11 @@ func TestRepo_UnsetMatchingConfig(t *testing.T) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
ctx = peer.NewContext(ctx, backchannelPeer)
- votes := 0
+ txManager := transaction.NewTrackingManager()
require.NoError(t, err)
- require.NoError(t, repo.UnsetMatchingConfig(ctx, "some.key", &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- votes++
- return nil
- },
- }))
+ require.NoError(t, repo.UnsetMatchingConfig(ctx, "some.key", txManager))
- require.Equal(t, 2, votes)
+ require.Equal(t, 2, len(txManager.Votes()))
})
}
diff --git a/internal/git/objectpool/link_test.go b/internal/git/objectpool/link_test.go
index 3a45adb37..c960f48db 100644
--- a/internal/git/objectpool/link_test.go
+++ b/internal/git/objectpool/link_test.go
@@ -1,7 +1,6 @@
package objectpool
import (
- "context"
"os"
"path/filepath"
"strings"
@@ -13,7 +12,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"google.golang.org/grpc/peer"
)
@@ -54,13 +52,8 @@ func TestLink_transactional(t *testing.T) {
pool, poolMember := setupObjectPool(t)
require.NoError(t, pool.Create(ctx, poolMember))
- votes := 0
- pool.txManager = &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- votes++
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
+ pool.txManager = txManager
alternatesPath, err := pool.locator.InfoAlternatesPath(poolMember)
require.NoError(t, err)
@@ -74,7 +67,7 @@ func TestLink_transactional(t *testing.T) {
require.NoError(t, pool.Link(ctx, poolMember))
- require.Equal(t, 2, votes)
+ require.Equal(t, 2, len(txManager.Votes()))
}
func TestLinkRemoveBitmap(t *testing.T) {
diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go
index 89b50f4f0..b0676804d 100644
--- a/internal/gitaly/service/operations/apply_patch_test.go
+++ b/internal/gitaly/service/operations/apply_patch_test.go
@@ -1,12 +1,10 @@
package operations
import (
- "context"
"fmt"
"io"
"os"
"strings"
- "sync/atomic"
"testing"
"testing/iotest"
"time"
@@ -26,7 +24,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v14/streamio"
"google.golang.org/grpc/codes"
@@ -621,16 +618,7 @@ func TestUserApplyPatchTransactional(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- var votes int32
- txManager := &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- // We can see a race here between adding the worktree and changing its
- // config and updating refs via the reference-transaction hook. Given that
- // both come in via different threads, Go perceives it as a potential race.
- atomic.AddInt32(&votes, 1)
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
ctx, cfg, repoProto, repoPath, client := setupOperationsService(t, ctx, testserver.WithTransactionManager(txManager))
@@ -665,7 +653,7 @@ func TestUserApplyPatchTransactional(t *testing.T) {
require.True(t, response.BranchUpdate.BranchCreated)
- require.Equal(t, int32(14), votes)
+ require.Equal(t, 14, len(txManager.Votes()))
splitIndex := gittest.Exec(t, cfg, "-C", repoPath, "config", "core.splitIndex")
require.Equal(t, "false", text.ChompBytes(splitIndex))
diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go
index 555c7048c..5c05880b3 100644
--- a/internal/gitaly/service/operations/rebase_test.go
+++ b/internal/gitaly/service/operations/rebase_test.go
@@ -1,7 +1,6 @@
package operations
import (
- "context"
"fmt"
"io"
"strings"
@@ -18,7 +17,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/proto"
@@ -93,13 +91,7 @@ func TestUserRebaseConfirmableTransaction(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- var voteCount int
- txManager := &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- voteCount++
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
ctx, cfg, repoProto, repoPath, client := setupOperationsService(
t, ctx,
@@ -141,7 +133,7 @@ func TestUserRebaseConfirmableTransaction(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
preReceiveHookOutputPath := gittest.WriteEnvToCustomHook(t, repoPath, "pre-receive")
- voteCount = 0
+ txManager.Reset()
ctx := ctx
if tc.withTransaction {
@@ -173,7 +165,7 @@ func TestUserRebaseConfirmableTransaction(t *testing.T) {
require.Nil(t, response)
require.Equal(t, io.EOF, err)
- require.Equal(t, tc.expectedVotes, voteCount)
+ require.Equal(t, tc.expectedVotes, len(txManager.Votes()))
if tc.expectPreReceiveHook {
require.FileExists(t, preReceiveHookOutputPath)
} else {
diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go
index b52c3f74c..b508e4308 100644
--- a/internal/gitaly/service/ref/delete_refs_test.go
+++ b/internal/gitaly/service/ref/delete_refs_test.go
@@ -17,7 +17,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
@@ -92,13 +91,7 @@ func testDeleteRefsTransaction(t *testing.T, ctx context.Context) {
testcfg.BuildGitalyHooks(t, cfg)
- var votes int
- txManager := &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- votes++
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
addr := testserver.RunGitalyServer(t, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) {
gitalypb.RegisterRefServiceServer(srv, NewServer(
@@ -139,7 +132,7 @@ func testDeleteRefsTransaction(t *testing.T, ctx context.Context) {
},
} {
t.Run(tc.desc, func(t *testing.T) {
- votes = 0
+ txManager.Reset()
repo, _ := gittest.CloneRepo(t, cfg, cfg.Storages[0])
tc.request.Repository = repo
@@ -153,7 +146,7 @@ func testDeleteRefsTransaction(t *testing.T, ctx context.Context) {
expectedVotes *= 2
}
- require.Equal(t, expectedVotes, votes)
+ require.Equal(t, expectedVotes, len(txManager.Votes()))
})
}
}
diff --git a/internal/gitaly/service/repository/create_repository_from_bundle_test.go b/internal/gitaly/service/repository/create_repository_from_bundle_test.go
index 90ab876d9..0787122c4 100644
--- a/internal/gitaly/service/repository/create_repository_from_bundle_test.go
+++ b/internal/gitaly/service/repository/create_repository_from_bundle_test.go
@@ -104,16 +104,9 @@ func TestCreateRepositoryFromBundle_transactional(t *testing.T) {
}
func testCreateRepositoryFromBundleTransactional(t *testing.T, ctx context.Context) {
- var votes []voting.Vote
- txManager := &transaction.MockManager{
- VoteFn: func(ctx context.Context, tx txinfo.Transaction, vote voting.Vote) error {
- votes = append(votes, vote)
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
- cfg, repoProto, repoPath, client := setupRepositoryService(t,
- testserver.WithTransactionManager(txManager))
+ cfg, repoProto, repoPath, client := setupRepositoryService(t, testserver.WithTransactionManager(txManager))
masterOID := text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "refs/heads/master"))
featureOID := text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "refs/heads/feature"))
@@ -155,21 +148,22 @@ func testCreateRepositoryFromBundleTransactional(t *testing.T, ctx context.Conte
require.NoError(t, err)
if featureflag.TxAtomicRepositoryCreation.IsEnabled(ctx) {
- var actualVotes []string
- for _, vote := range votes {
- actualVotes = append(actualVotes, vote.String())
+ createVote := func(hash string) voting.Vote {
+ vote, err := voting.VoteFromString(hash)
+ require.NoError(t, err)
+ return vote
}
// While the following votes are opaque to us, this doesn't really matter. All we do
// care about is that they're stable.
- require.Equal(t, []string{
+ require.Equal(t, []voting.Vote{
// These are the votes created by git-fetch(1).
- "47553c06f575f757ad56ef3216c59804b72aa4a6",
- "47553c06f575f757ad56ef3216c59804b72aa4a6",
+ createVote("47553c06f575f757ad56ef3216c59804b72aa4a6"),
+ createVote("47553c06f575f757ad56ef3216c59804b72aa4a6"),
// And this is the manual votes we compute by walking the repository.
- "da39a3ee5e6b4b0d3255bfef95601890afd80709",
- "da39a3ee5e6b4b0d3255bfef95601890afd80709",
- }, actualVotes)
+ createVote("da39a3ee5e6b4b0d3255bfef95601890afd80709"),
+ createVote("da39a3ee5e6b4b0d3255bfef95601890afd80709"),
+ }, txManager.Votes())
return
}
@@ -198,7 +192,7 @@ func testCreateRepositoryFromBundleTransactional(t *testing.T, ctx context.Conte
expectedVotes = append(expectedVotes, voting.VoteFromData([]byte(expectedVote)))
}
- require.Equal(t, votes, expectedVotes)
+ require.Equal(t, expectedVotes, txManager.Votes())
}
func TestCreateRepositoryFromBundle_invalidBundle(t *testing.T) {
diff --git a/internal/gitaly/service/repository/create_repository_test.go b/internal/gitaly/service/repository/create_repository_test.go
index 813259a4f..5fca7246c 100644
--- a/internal/gitaly/service/repository/create_repository_test.go
+++ b/internal/gitaly/service/repository/create_repository_test.go
@@ -150,26 +150,16 @@ func TestCreateRepository_transactional(t *testing.T) {
}
func testCreateRepositoryTransactional(t *testing.T, ctx context.Context) {
- var actualVote voting.Vote
- var called int
-
- mockTxManager := transaction.MockManager{
- VoteFn: func(ctx context.Context, tx txinfo.Transaction, v voting.Vote) error {
- actualVote = v
- called++
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
- cfg, client := setupRepositoryServiceWithoutRepo(t, testserver.WithTransactionManager(&mockTxManager))
+ cfg, client := setupRepositoryServiceWithoutRepo(t, testserver.WithTransactionManager(txManager))
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
ctx = metadata.IncomingToOutgoing(ctx)
t.Run("initial creation without refs", func(t *testing.T) {
- called = 0
- actualVote = voting.Vote{}
+ txManager.Reset()
repo := &gitalypb.Repository{
StorageName: cfg.Storages[0].Name,
@@ -180,16 +170,16 @@ func testCreateRepositoryTransactional(t *testing.T, ctx context.Context) {
require.DirExists(t, filepath.Join(cfg.Storages[0].Path, getReplicaPath(ctx, t, client, repo)))
if featureflag.TxAtomicRepositoryCreation.IsEnabled(ctx) {
- require.Equal(t, 2, called, "expected transactional vote")
+ require.Equal(t, 2, len(txManager.Votes()), "expected transactional vote")
} else {
- require.Equal(t, 1, called, "expected transactional vote")
- require.Equal(t, voting.VoteFromData([]byte{}), actualVote)
+ require.Equal(t, []voting.Vote{
+ voting.VoteFromData([]byte{}),
+ }, txManager.Votes())
}
})
t.Run("idempotent creation with preexisting refs", func(t *testing.T) {
- called = 0
- actualVote = voting.Vote{}
+ txManager.Reset()
// The above test creates the second repository on the server. As this test can run with Praefect in front of it,
// we'll use the next replica path Praefect will assign in order to ensure this repository creation conflicts even
@@ -212,8 +202,7 @@ func testCreateRepositoryTransactional(t *testing.T, ctx context.Context) {
refs := gittest.Exec(t, cfg, "-C", repoPath, "for-each-ref")
require.NotEmpty(t, refs)
- require.Equal(t, 1, called, "expected transactional vote")
- require.Equal(t, voting.VoteFromData(refs), actualVote)
+ require.Equal(t, []voting.Vote{voting.VoteFromData(refs)}, txManager.Votes())
})
}
diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go
index 56355d45e..8f86bcac7 100644
--- a/internal/gitaly/service/repository/fetch_remote_test.go
+++ b/internal/gitaly/service/repository/fetch_remote_test.go
@@ -1,7 +1,6 @@
package repository
import (
- "context"
"fmt"
"net/http"
"net/http/httptest"
@@ -24,7 +23,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
@@ -184,21 +182,11 @@ func TestFetchRemote_withDefaultRefmaps(t *testing.T) {
require.Equal(t, sourceRefs, targetRefs)
}
-type mockTxManager struct {
- transaction.Manager
- votes int
-}
-
-func (m *mockTxManager) Vote(context.Context, txinfo.Transaction, voting.Vote) error {
- m.votes++
- return nil
-}
-
func TestFetchRemote_transaction(t *testing.T) {
t.Parallel()
sourceCfg, _, sourceRepoPath := testcfg.BuildWithRepo(t)
- txManager := &mockTxManager{}
+ txManager := transaction.NewTrackingManager()
addr := testserver.RunGitalyServer(t, sourceCfg, nil, func(srv *grpc.Server, deps *service.Dependencies) {
gitalypb.RegisterRepositoryServiceServer(srv, NewServer(
deps.GetCfg(),
@@ -223,7 +211,7 @@ func TestFetchRemote_transaction(t *testing.T) {
require.NoError(t, err)
ctx = metadata.IncomingToOutgoing(ctx)
- require.Equal(t, 0, txManager.votes)
+ require.Equal(t, 0, len(txManager.Votes()))
_, err = client.FetchRemote(ctx, &gitalypb.FetchRemoteRequest{
Repository: targetRepoProto,
@@ -233,7 +221,7 @@ func TestFetchRemote_transaction(t *testing.T) {
})
require.NoError(t, err)
- require.Equal(t, 1, txManager.votes)
+ require.Equal(t, 1, len(txManager.Votes()))
}
func TestFetchRemote_prune(t *testing.T) {
diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go
index 03db17ff1..b160f02d1 100644
--- a/internal/gitaly/service/repository/midx_test.go
+++ b/internal/gitaly/service/repository/midx_test.go
@@ -20,7 +20,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc/peer"
)
@@ -118,13 +117,7 @@ func TestMidxRepack_transactional(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- votes := 0
- txManager := &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- votes++
- return nil
- },
- }
+ txManager := transaction.NewTrackingManager()
cfg, repo, repoPath, client := setupRepositoryService(t, testserver.WithTransactionManager(txManager))
@@ -140,7 +133,7 @@ func TestMidxRepack_transactional(t *testing.T) {
})
require.NoError(t, err)
- require.Equal(t, 2, votes)
+ require.Equal(t, 2, len(txManager.Votes()))
multiPackIndex := gittest.Exec(t, cfg, "-C", repoPath, "config", "core.multiPackIndex")
require.Equal(t, "true", text.ChompBytes(multiPackIndex))
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index 6c27ae7d8..56d9ac5c3 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -2,7 +2,6 @@ package ssh
import (
"bytes"
- "context"
"fmt"
"io"
"os"
@@ -29,7 +28,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
- "gitlab.com/gitlab-org/gitaly/v14/internal/transaction/voting"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v14/streamio"
"google.golang.org/grpc/codes"
@@ -282,15 +280,9 @@ func TestReceivePackTransactional(t *testing.T) {
testcfg.BuildGitalyHooks(t, cfg)
- var votes int
- serverSocketPath := runSSHServer(t, cfg, testserver.WithTransactionManager(
- &transaction.MockManager{
- VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
- votes++
- return nil
- },
- },
- ))
+ txManager := transaction.NewTrackingManager()
+
+ serverSocketPath := runSSHServer(t, cfg, testserver.WithTransactionManager(txManager))
client, conn := newSSHClient(t, serverSocketPath)
defer conn.Close()
@@ -435,7 +427,7 @@ func TestReceivePackTransactional(t *testing.T) {
},
} {
t.Run(tc.desc, func(t *testing.T) {
- votes = 0
+ txManager.Reset()
var request bytes.Buffer
for i, command := range tc.commands {
@@ -480,7 +472,7 @@ func TestReceivePackTransactional(t *testing.T) {
require.Equal(t, expectedOID, actualOID.String())
}
}
- require.Equal(t, tc.expectedVotes, votes)
+ require.Equal(t, tc.expectedVotes, len(txManager.Votes()))
})
}
}