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:
authorPaul Okstad <pokstad@gitlab.com>2020-04-24 08:50:36 +0300
committerPaul Okstad <pokstad@gitlab.com>2020-04-24 08:50:36 +0300
commit47361b547fe8cbf13adf9915b2235d183f360fec (patch)
treed532414b2843cab49653cd9c47e90bd073c87b08
parente05bf02432b9fdde44fdd217bb111c6bcd9e40d7 (diff)
Debugging for TestRepoRemoval flaky testpo-fix-testreporemoval-race
-rw-r--r--internal/praefect/helper_test.go24
-rw-r--r--internal/praefect/server_test.go13
2 files changed, 34 insertions, 3 deletions
diff --git a/internal/praefect/helper_test.go b/internal/praefect/helper_test.go
index e0275c856..e76d1a0ff 100644
--- a/internal/praefect/helper_test.go
+++ b/internal/praefect/helper_test.go
@@ -157,9 +157,24 @@ func noopBackoffFunc() (backoff, backoffReset) {
}, func() {}
}
+type runPraefectServerWithGitalyOption func(*testServerOptions)
+
+func withReplicator(r Replicator) runPraefectServerWithGitalyOption {
+ return func(tso *testServerOptions) { tso.replicator = r }
+}
+
+type testServerOptions struct {
+ replicator Replicator
+}
+
// runPraefectServerWithGitaly runs a praefect server with actual Gitaly nodes
// requires exactly 1 virtual storage
-func runPraefectServerWithGitaly(t *testing.T, conf config.Config) (*grpc.ClientConn, *Server, testhelper.Cleanup) {
+func runPraefectServerWithGitaly(t *testing.T, conf config.Config, opts ...runPraefectServerWithGitalyOption) (*grpc.ClientConn, *Server, testhelper.Cleanup) {
+ options := testServerOptions{}
+ for _, opt := range opts {
+ opt(&options)
+ }
+
require.Len(t, conf.VirtualStorages, 1)
var cleanups []testhelper.Cleanup
@@ -193,12 +208,17 @@ func runPraefectServerWithGitaly(t *testing.T, conf config.Config) (*grpc.Client
require.NoError(t, registry.RegisterFiles(protoregistry.GitalyProtoFileDescriptors...))
coordinator := NewCoordinator(logEntry, ds, nodeMgr, conf, registry)
+ replMgrOpts := []ReplMgrOpt{WithQueueMetric(&promtest.MockGauge{})}
+ if options.replicator != nil {
+ replMgrOpts = append(replMgrOpts, WithReplicator(options.replicator))
+ }
+
replmgr := NewReplMgr(
conf.VirtualStorages[0].Name,
logEntry,
ds,
nodeMgr,
- WithQueueMetric(&promtest.MockGauge{}),
+ replMgrOpts...,
)
prf := NewServer(
coordinator.StreamDirector,
diff --git a/internal/praefect/server_test.go b/internal/praefect/server_test.go
index 8e805460f..7c9be8034 100644
--- a/internal/praefect/server_test.go
+++ b/internal/praefect/server_test.go
@@ -3,6 +3,7 @@ package praefect
import (
"context"
"io/ioutil"
+ "log"
"os"
"path/filepath"
"strings"
@@ -28,6 +29,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/testhelper/promtest"
"gitlab.com/gitlab-org/gitaly/internal/version"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
+ "google.golang.org/grpc"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
)
@@ -372,6 +374,15 @@ func TestWarnDuplicateAddrs(t *testing.T) {
}
}
+type replicatorWrapper struct {
+ Replicator
+}
+
+func (r replicatorWrapper) Destroy(ctx context.Context, job datastore.ReplJob, target *grpc.ClientConn) error {
+ log.Printf("replicatorWrapper: %+v", job)
+ return r.Replicator.Destroy(ctx, job, target)
+}
+
func TestRepoRemoval(t *testing.T) {
conf := config.Config{
VirtualStorages: []*config.VirtualStorage{
@@ -428,7 +439,7 @@ func TestRepoRemoval(t *testing.T) {
require.DirExists(t, path1)
require.DirExists(t, path2)
- cc, _, cleanup := runPraefectServerWithGitaly(t, conf)
+ cc, _, cleanup := runPraefectServerWithGitaly(t, conf, withReplicator(replicatorWrapper{defaultReplicator{}}))
defer cleanup()
ctx, cancel := testhelper.Context()