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-06-11 16:16:27 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-06-14 12:36:24 +0300
commit92ab0786cc926e7f76db513ed3ccead9c8bc1c02 (patch)
tree3969833b4e017356da7996b98b2d36aea17e3897
parentf5151016ece37da44897a03686b12a055fe8613e (diff)
tests: Remove unused Praefect server structure
We do not use the Praefect server structure for anything anymore. Let's strip it out from our tests such that we can remove it altogether.
-rw-r--r--internal/gitaly/service/operations/branches_test.go45
-rw-r--r--internal/gitaly/service/operations/rebase_test.go5
-rw-r--r--internal/gitaly/service/operations/tags_test.go7
-rw-r--r--internal/gitaly/service/ref/delete_refs_test.go2
-rw-r--r--internal/gitaly/service/remote/remotes_test.go8
-rw-r--r--internal/gitaly/service/repository/apply_gitattributes_test.go7
-rw-r--r--internal/gitaly/service/repository/config_test.go8
-rw-r--r--internal/gitaly/service/repository/create_test.go4
-rw-r--r--internal/gitaly/service/repository/fetch_remote_test.go2
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go15
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go4
-rw-r--r--internal/gitaly/transaction/manager_test.go18
12 files changed, 18 insertions, 107 deletions
diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go
index 72958ad7c..e6080e977 100644
--- a/internal/gitaly/service/operations/branches_test.go
+++ b/internal/gitaly/service/operations/branches_test.go
@@ -3,12 +3,10 @@ package operations
import (
"context"
"fmt"
- "net"
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/internal/backchannel"
- "gitlab.com/gitlab-org/gitaly/v14/internal/bootstrap/starter"
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo"
@@ -136,39 +134,17 @@ func TestUserCreateBranchWithTransaction(t *testing.T) {
// the test requires a TCP listening address.
}, testserver.WithDisablePraefect())
- addrConfig, err := starter.ParseEndpoint(addr)
- require.NoError(t, err)
- _, port, err := net.SplitHostPort(addrConfig.Addr)
- require.NoError(t, err)
-
testcases := []struct {
desc string
address string
- server txinfo.PraefectServer
}{
{
- desc: "explicit TCP address",
- address: addr,
- server: txinfo.PraefectServer{
- ListenAddr: addr,
- Token: cfg.Auth.Token,
- },
- },
- {
- desc: "catch-all TCP address",
+ desc: "TCP address",
address: addr,
- server: txinfo.PraefectServer{
- ListenAddr: "tcp://0.0.0.0:" + port,
- Token: cfg.Auth.Token,
- },
},
{
desc: "Unix socket",
address: "unix://" + cfg.GitalyInternalSocketPath(),
- server: txinfo.PraefectServer{
- SocketPath: "unix://" + cfg.GitalyInternalSocketPath(),
- Token: cfg.Auth.Token,
- },
},
}
@@ -178,6 +154,9 @@ func TestUserCreateBranchWithTransaction(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
+ ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
+ require.NoError(t, err)
+ ctx = helper.IncomingToOutgoing(ctx)
client := newMuxedOperationClient(t, ctx, tc.address, cfg.Auth.Token,
backchannel.NewClientHandshaker(
@@ -190,12 +169,6 @@ func TestUserCreateBranchWithTransaction(t *testing.T) {
),
)
- ctx, err := tc.server.Inject(ctx)
- require.NoError(t, err)
- ctx, err = txinfo.InjectTransaction(ctx, 1, "node", true)
- require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
-
request := &gitalypb.UserCreateBranchRequest{
Repository: repo,
BranchName: []byte("new-branch"),
@@ -510,17 +483,9 @@ func TestUserDeleteBranch_transaction(t *testing.T) {
))
})
- praefect := txinfo.PraefectServer{
- SocketPath: fmt.Sprintf("unix://" + cfg.GitalyInternalSocketPath()),
- Token: cfg.Auth.Token,
- }
-
ctx, cancel := testhelper.Context()
defer cancel()
-
- ctx, err := praefect.Inject(ctx)
- require.NoError(t, err)
- ctx, err = txinfo.InjectTransaction(ctx, 1, "node", true)
+ ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go
index ac0986515..1d4388a8b 100644
--- a/internal/gitaly/service/operations/rebase_test.go
+++ b/internal/gitaly/service/operations/rebase_test.go
@@ -150,11 +150,6 @@ func TestUserRebaseConfirmableTransaction(t *testing.T) {
var err error
ctx, err = txinfo.InjectTransaction(ctx, 1, "node", tc.primary)
require.NoError(t, err)
- ctx, err = (&txinfo.PraefectServer{
- SocketPath: "irrelevant",
- }).Inject(ctx)
- require.NoError(t, err)
-
ctx = helper.IncomingToOutgoing(ctx)
}
diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go
index c8d9cc4c0..4a12f9a8e 100644
--- a/internal/gitaly/service/operations/tags_test.go
+++ b/internal/gitaly/service/operations/tags_test.go
@@ -303,11 +303,6 @@ func TestUserCreateTagWithTransaction(t *testing.T) {
),
)
- praefectServer := &txinfo.PraefectServer{
- SocketPath: "unix://" + cfg.GitalyInternalSocketPath(),
- Token: cfg.Auth.Token,
- }
-
for i, testCase := range []struct {
desc string
primary bool
@@ -357,8 +352,6 @@ func TestUserCreateTagWithTransaction(t *testing.T) {
ctx = helper.OutgoingToIncoming(ctx)
ctx, err = txinfo.InjectTransaction(ctx, 1, "node", testCase.primary)
require.NoError(t, err)
- ctx, err = praefectServer.Inject(ctx)
- require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
response, err := client.UserCreateTag(ctx, request)
diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go
index 004d89ca7..ba28bf018 100644
--- a/internal/gitaly/service/ref/delete_refs_test.go
+++ b/internal/gitaly/service/ref/delete_refs_test.go
@@ -110,8 +110,6 @@ func TestDeleteRefs_transaction(t *testing.T) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx, err = (&txinfo.PraefectServer{SocketPath: "i-dont-care"}).Inject(ctx)
- require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
for _, tc := range []struct {
diff --git a/internal/gitaly/service/remote/remotes_test.go b/internal/gitaly/service/remote/remotes_test.go
index 06477c8a7..0dd518210 100644
--- a/internal/gitaly/service/remote/remotes_test.go
+++ b/internal/gitaly/service/remote/remotes_test.go
@@ -116,9 +116,7 @@ func testAddRemoteTransactional(t *testing.T, cfg config.Cfg, rubySrv *rubyserve
_, repo, repoPath, client := setupRemoteServiceWithRuby(t, cfg, rubySrv, testserver.WithTransactionManager(&txManager))
- ctx, err := (&txinfo.PraefectServer{SocketPath: "i-dont-care"}).Inject(ctx)
- require.NoError(t, err)
- ctx, err = txinfo.InjectTransaction(ctx, 1, "node", true)
+ ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
@@ -252,9 +250,7 @@ func TestRemoveRemoteTransactional(t *testing.T) {
cfg, repo, repoPath, client := setupRemoteService(t, testserver.WithTransactionManager(&txManager))
- ctx, err := (&txinfo.PraefectServer{SocketPath: "i-dont-care"}).Inject(ctx)
- require.NoError(t, err)
- ctx, err = txinfo.InjectTransaction(ctx, 1, "node", true)
+ ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
diff --git a/internal/gitaly/service/repository/apply_gitattributes_test.go b/internal/gitaly/service/repository/apply_gitattributes_test.go
index 5b8c054f6..996e6bf82 100644
--- a/internal/gitaly/service/repository/apply_gitattributes_test.go
+++ b/internal/gitaly/service/repository/apply_gitattributes_test.go
@@ -115,11 +115,6 @@ func TestApplyGitattributesWithTransaction(t *testing.T) {
}),
)
- praefect := txinfo.PraefectServer{
- SocketPath: "unix://" + cfg.GitalyInternalSocketPath(),
- Token: cfg.Auth.Token,
- }
-
for _, tc := range []struct {
desc string
revision []byte
@@ -181,8 +176,6 @@ func TestApplyGitattributesWithTransaction(t *testing.T) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "primary", true)
require.NoError(t, err)
- ctx, err = praefect.Inject(ctx)
- require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
transactionServer.vote = func(request *gitalypb.VoteTransactionRequest) (*gitalypb.VoteTransactionResponse, error) {
diff --git a/internal/gitaly/service/repository/config_test.go b/internal/gitaly/service/repository/config_test.go
index d38be7b75..599962547 100644
--- a/internal/gitaly/service/repository/config_test.go
+++ b/internal/gitaly/service/repository/config_test.go
@@ -149,9 +149,7 @@ func TestDeleteConfigTransactional(t *testing.T) {
cfg, repo, repoPath, client := setupRepositoryService(t, testserver.WithTransactionManager(&txManager))
- ctx, err := (&txinfo.PraefectServer{SocketPath: "i-dont-care"}).Inject(ctx)
- require.NoError(t, err)
- ctx, err = txinfo.InjectTransaction(ctx, 1, "node", true)
+ ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
@@ -250,9 +248,7 @@ func testSetConfigTransactional(t *testing.T, cfg config.Cfg, rubySrv *rubyserve
_, repo, repoPath, client := setupRepositoryServiceWithRuby(t, cfg, rubySrv, testserver.WithTransactionManager(&txManager))
- ctx, err := (&txinfo.PraefectServer{SocketPath: "i-dont-care"}).Inject(ctx)
- require.NoError(t, err)
- ctx, err = txinfo.InjectTransaction(ctx, 1, "node", true)
+ ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
diff --git a/internal/gitaly/service/repository/create_test.go b/internal/gitaly/service/repository/create_test.go
index 3b0d776f2..68a2983d5 100644
--- a/internal/gitaly/service/repository/create_test.go
+++ b/internal/gitaly/service/repository/create_test.go
@@ -135,9 +135,7 @@ func TestCreateRepositoryTransactional(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- ctx, err := (&txinfo.PraefectServer{SocketPath: "something"}).Inject(ctx)
- require.NoError(t, err)
- ctx, err = txinfo.InjectTransaction(ctx, 1, "node", true)
+ ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go
index da59ea317..50397f40d 100644
--- a/internal/gitaly/service/repository/fetch_remote_test.go
+++ b/internal/gitaly/service/repository/fetch_remote_test.go
@@ -238,8 +238,6 @@ func TestFetchRemote_transaction(t *testing.T) {
defer cancel()
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx, err = (&txinfo.PraefectServer{SocketPath: "i-dont-care"}).Inject(ctx)
- require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
require.Equal(t, 0, txManager.votes)
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 7f02e87c2..b9757b6f5 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -24,7 +24,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
- pconfig "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
@@ -594,23 +593,11 @@ func TestPostReceiveWithReferenceTransactionHook(t *testing.T) {
gitalypb.RegisterHookServiceServer(srv, hook.NewServer(deps.GetCfg(), deps.GetHookManager(), deps.GetGitCmdFactory()))
}, testserver.WithDisablePraefect())
- // As we ain't got a Praefect server setup, we instead hooked up the
- // RefTransaction server for Gitaly itself. As this is the only Praefect
- // service required in this context, we can just pretend that
- // Gitaly is the Praefect server and inject it.
- praefectServer, err := txinfo.PraefectFromConfig(pconfig.Config{
- SocketPath: addr,
- })
- require.NoError(t, err)
-
ctx, cancel := testhelper.Context()
defer cancel()
- ctx, err = txinfo.InjectTransaction(ctx, 1234, "primary", true)
+ ctx, err := txinfo.InjectTransaction(ctx, 1234, "primary", true)
require.NoError(t, err)
- ctx, err = praefectServer.Inject(ctx)
- require.NoError(t, err)
-
ctx = helper.IncomingToOutgoing(ctx)
client := newMuxedSmartHTTPClient(t, ctx, addr, cfg.Auth.Token, func() backchannel.Server {
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index c170b6af5..4c4ec57f5 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -277,9 +277,7 @@ func TestReceivePackTransactional(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- ctx, err := (&txinfo.PraefectServer{SocketPath: "whatever"}).Inject(ctx)
- require.NoError(t, err)
- ctx, err = txinfo.InjectTransaction(ctx, 1, "node", true)
+ ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
ctx = helper.IncomingToOutgoing(ctx)
diff --git a/internal/gitaly/transaction/manager_test.go b/internal/gitaly/transaction/manager_test.go
index d0c895561..028df3d20 100644
--- a/internal/gitaly/transaction/manager_test.go
+++ b/internal/gitaly/transaction/manager_test.go
@@ -46,13 +46,13 @@ func (s *testTransactionServer) StopTransaction(ctx context.Context, in *gitalyp
func TestPoolManager_Vote(t *testing.T) {
cfg := testcfg.Build(t)
- transactionServer, praefect := runTransactionServer(t, cfg)
+ transactionServer, transactionServerAddr := runTransactionServer(t, cfg)
ctx, cancel := testhelper.Context()
defer cancel()
registry := backchannel.NewRegistry()
- backchannelConn, err := client.Dial(ctx, praefect.ListenAddr, nil, nil)
+ backchannelConn, err := client.Dial(ctx, transactionServerAddr, nil, nil)
require.NoError(t, err)
defer backchannelConn.Close()
@@ -134,13 +134,13 @@ func TestPoolManager_Vote(t *testing.T) {
func TestPoolManager_Stop(t *testing.T) {
cfg := testcfg.Build(t)
- transactionServer, praefect := runTransactionServer(t, cfg)
+ transactionServer, transactionServerAddr := runTransactionServer(t, cfg)
ctx, cancel := testhelper.Context()
defer cancel()
registry := backchannel.NewRegistry()
- backchannelConn, err := client.Dial(ctx, praefect.ListenAddr, nil, nil)
+ backchannelConn, err := client.Dial(ctx, transactionServerAddr, nil, nil)
require.NoError(t, err)
defer backchannelConn.Close()
@@ -188,17 +188,11 @@ func TestPoolManager_Stop(t *testing.T) {
}
}
-func runTransactionServer(t *testing.T, cfg config.Cfg) (*testTransactionServer, txinfo.PraefectServer) {
+func runTransactionServer(t *testing.T, cfg config.Cfg) (*testTransactionServer, string) {
transactionServer := &testTransactionServer{}
cfg.ListenAddr = ":0" // pushes gRPC to listen on the TCP address
addr := testserver.RunGitalyServer(t, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) {
gitalypb.RegisterRefTransactionServer(srv, transactionServer)
}, testserver.WithDisablePraefect())
-
- praefect := txinfo.PraefectServer{
- ListenAddr: addr,
- Token: cfg.Auth.Token,
- }
-
- return transactionServer, praefect
+ return transactionServer, addr
}