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-04-19 10:32:15 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-04-19 10:38:44 +0300
commitc887299c09b589023c23aea5e831a1bf250d00ac (patch)
tree955438fa78e8e5c945862cb878ec309f9c41cc34
parent3fbca5816429d1d9a01237aa52f6b0e6300eb071 (diff)
operations: Add ability to setup operations server without Praefect
For the following patch, we'll need to set up an operations service without the Praefect proxy which normally gets injected by the test-with-praefect target. This commit thus creatse the ability to inject TestServerOpts into the setup functions and creates a new `WithDisabledPraefect()` option for the testserver.
-rw-r--r--internal/gitaly/service/operations/testhelper_test.go24
-rw-r--r--internal/testhelper/testserver.go10
2 files changed, 27 insertions, 7 deletions
diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go
index 2a2d9e6ac..8cf72940d 100644
--- a/internal/gitaly/service/operations/testhelper_test.go
+++ b/internal/gitaly/service/operations/testhelper_test.go
@@ -121,6 +121,7 @@ func setupOperationsService(t testing.TB, ctx context.Context) (context.Context,
type setupConfig struct {
txManagerConstructor func() transaction.Manager
+ testServerOpts []testhelper.TestServerOpt
}
func (c setupConfig) buildTxManager(cfg config.Cfg, registry *backchannel.Registry) transaction.Manager {
@@ -138,6 +139,12 @@ func withTxManagerConstructor(constructor func() transaction.Manager) setupOptio
}
}
+func withTestServerOpts(opts ...testhelper.TestServerOpt) setupOption {
+ return func(config *setupConfig) {
+ config.testServerOpts = opts
+ }
+}
+
func setupOperationsServiceWithRuby(
t testing.TB, ctx context.Context, cfg config.Cfg, rubySrv *rubyserver.Server, options ...setupOption,
) (context.Context, config.Cfg, *gitalypb.Repository, string, gitalypb.OperationServiceClient) {
@@ -163,17 +170,22 @@ func setupOperationsServiceWithRuby(
func runOperationServiceServer(t testing.TB, cfg config.Cfg, rubySrv *rubyserver.Server, options ...setupOption) string {
t.Helper()
- registry := backchannel.NewRegistry()
- srv := testhelper.NewServerWithAuth(t, nil, nil, cfg.Auth.Token, registry, testhelper.WithInternalSocket(cfg))
-
- conns := gitalyclient.NewPool()
- t.Cleanup(func() { conns.Close() })
-
setupConfig := setupConfig{}
for _, option := range options {
option(&setupConfig)
}
+ testServerOpts := append(
+ []testhelper.TestServerOpt{testhelper.WithInternalSocket(cfg)},
+ setupConfig.testServerOpts...,
+ )
+
+ registry := backchannel.NewRegistry()
+ srv := testhelper.NewServerWithAuth(t, nil, nil, cfg.Auth.Token, registry, testServerOpts...)
+
+ conns := gitalyclient.NewPool()
+ t.Cleanup(func() { conns.Close() })
+
locator := config.NewLocator(cfg)
txManager := setupConfig.buildTxManager(cfg, registry)
diff --git a/internal/testhelper/testserver.go b/internal/testhelper/testserver.go
index 839efd1a9..906c7b9c7 100644
--- a/internal/testhelper/testserver.go
+++ b/internal/testhelper/testserver.go
@@ -66,6 +66,13 @@ func WithInternalSocket(cfg config.Cfg) TestServerOpt {
}
}
+// WithDisabledPraefect disables setup and usage of Praefect as a proxy before the gitaly service.
+func WithDisabledPraefect() TestServerOpt {
+ return func(t *TestServer) {
+ t.disablePraefect = true
+ }
+}
+
// NewTestServer instantiates a new TestServer
func NewTestServer(srv *grpc.Server, opts ...TestServerOpt) *TestServer {
ts := &TestServer{
@@ -114,6 +121,7 @@ type TestServer struct {
storages []string
waitCh chan struct{}
withInternalSocketPath string
+ disablePraefect bool
}
// GrpcServer returns the underlying grpc.Server
@@ -138,7 +146,7 @@ func (p *TestServer) Socket() string {
// Start will start the grpc server as well as spawn a praefect instance if GITALY_TEST_PRAEFECT_BIN is enabled
func (p *TestServer) Start(t testing.TB) {
praefectBinPath, ok := os.LookupEnv("GITALY_TEST_PRAEFECT_BIN")
- if !ok {
+ if !ok || p.disablePraefect {
p.socket = p.listen(t)
return
}