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-03-04 14:40:12 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-03-04 15:23:13 +0300
commit456e9a3ab51c515135b8b14b1822f96d820ade8e (patch)
treeda8d364226952c55444ad4e9d5d90d0172d3d56c /internal/praefect/replicator_test.go
parent9c3d5914f9e4c888469c9ef6573b4c222e3a82b3 (diff)
replicator: Do not bump repository generation for PackRefs
Similar in spirit to fc93593cb (praefect: Stop creating replication jobs on cleanup, 2021-02-03), we're still bumping the repository generation when creating PackRefs jobs. But given that these only optimize the repository without changing the user-visible state of the repository, bumping the repository generation is only going to needlessly cause us to regard secondaries as out-of-date. Fix the issue by introducing a separate "PackRefs" change type which doesn't cause us to bump the generation.
Diffstat (limited to 'internal/praefect/replicator_test.go')
-rw-r--r--internal/praefect/replicator_test.go40
1 files changed, 31 insertions, 9 deletions
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index 79433a660..0b2aef714 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -374,6 +374,7 @@ func TestPropagateReplicationJob(t *testing.T) {
cc := dialLocalPort(t, port, false)
repositoryClient := gitalypb.NewRepositoryServiceClient(cc)
+ refClient := gitalypb.NewRefServiceClient(cc)
defer listener.Close()
defer cc.Close()
@@ -396,6 +397,9 @@ func TestPropagateReplicationJob(t *testing.T) {
_, err = repositoryClient.Cleanup(ctx, &gitalypb.CleanupRequest{Repository: repository})
require.NoError(t, err)
+ _, err = refClient.PackRefs(ctx, &gitalypb.PackRefsRequest{Repository: repository})
+ require.NoError(t, err)
+
primaryRepository := &gitalypb.Repository{StorageName: primaryStorage, RelativePath: repositoryRelativePath}
expectedPrimaryGcReq := &gitalypb.GarbageCollectRequest{
Repository: primaryRepository,
@@ -411,6 +415,9 @@ func TestPropagateReplicationJob(t *testing.T) {
expectedPrimaryCleanup := &gitalypb.CleanupRequest{
Repository: primaryRepository,
}
+ expectedPrimaryPackRefs := &gitalypb.PackRefsRequest{
+ Repository: primaryRepository,
+ }
replCtx, cancel := testhelper.Context()
defer cancel()
@@ -421,6 +428,7 @@ func TestPropagateReplicationJob(t *testing.T) {
waitForRequest(t, primaryServer.repackIncrChan, expectedPrimaryRepackIncrementalReq, 5*time.Second)
waitForRequest(t, primaryServer.repackFullChan, expectedPrimaryRepackFullReq, 5*time.Second)
waitForRequest(t, primaryServer.cleanupChan, expectedPrimaryCleanup, 5*time.Second)
+ waitForRequest(t, primaryServer.packRefsChan, expectedPrimaryPackRefs, 5*time.Second)
secondaryRepository := &gitalypb.Repository{StorageName: secondaryStorage, RelativePath: repositoryRelativePath}
@@ -436,57 +444,70 @@ func TestPropagateReplicationJob(t *testing.T) {
expectedSecondaryCleanup := expectedPrimaryCleanup
expectedSecondaryCleanup.Repository = secondaryRepository
+ expectedSecondaryPackRefs := expectedPrimaryPackRefs
+ expectedSecondaryPackRefs.Repository = secondaryRepository
+
// ensure secondary gitaly server received the expected requests
waitForRequest(t, secondaryServer.gcChan, expectedSecondaryGcReq, 5*time.Second)
waitForRequest(t, secondaryServer.repackIncrChan, expectedSecondaryRepackIncrementalReq, 5*time.Second)
waitForRequest(t, secondaryServer.repackFullChan, expectedSecondaryRepackFullReq, 5*time.Second)
waitForRequest(t, secondaryServer.cleanupChan, expectedSecondaryCleanup, 5*time.Second)
+ waitForRequest(t, secondaryServer.packRefsChan, expectedSecondaryPackRefs, 5*time.Second)
}
-type mockRepositoryServer struct {
- gcChan, repackFullChan, repackIncrChan, cleanupChan chan proto.Message
+type mockServer struct {
+ gcChan, repackFullChan, repackIncrChan, cleanupChan, packRefsChan chan proto.Message
gitalypb.UnimplementedRepositoryServiceServer
+ gitalypb.UnimplementedRefServiceServer
}
-func newMockRepositoryServer() *mockRepositoryServer {
- return &mockRepositoryServer{
+func newMockRepositoryServer() *mockServer {
+ return &mockServer{
gcChan: make(chan proto.Message),
repackFullChan: make(chan proto.Message),
repackIncrChan: make(chan proto.Message),
cleanupChan: make(chan proto.Message),
+ packRefsChan: make(chan proto.Message),
}
}
-func (m *mockRepositoryServer) GarbageCollect(ctx context.Context, in *gitalypb.GarbageCollectRequest) (*gitalypb.GarbageCollectResponse, error) {
+func (m *mockServer) GarbageCollect(ctx context.Context, in *gitalypb.GarbageCollectRequest) (*gitalypb.GarbageCollectResponse, error) {
go func() {
m.gcChan <- in
}()
return &gitalypb.GarbageCollectResponse{}, nil
}
-func (m *mockRepositoryServer) RepackFull(ctx context.Context, in *gitalypb.RepackFullRequest) (*gitalypb.RepackFullResponse, error) {
+func (m *mockServer) RepackFull(ctx context.Context, in *gitalypb.RepackFullRequest) (*gitalypb.RepackFullResponse, error) {
go func() {
m.repackFullChan <- in
}()
return &gitalypb.RepackFullResponse{}, nil
}
-func (m *mockRepositoryServer) RepackIncremental(ctx context.Context, in *gitalypb.RepackIncrementalRequest) (*gitalypb.RepackIncrementalResponse, error) {
+func (m *mockServer) RepackIncremental(ctx context.Context, in *gitalypb.RepackIncrementalRequest) (*gitalypb.RepackIncrementalResponse, error) {
go func() {
m.repackIncrChan <- in
}()
return &gitalypb.RepackIncrementalResponse{}, nil
}
-func (m *mockRepositoryServer) Cleanup(ctx context.Context, in *gitalypb.CleanupRequest) (*gitalypb.CleanupResponse, error) {
+func (m *mockServer) Cleanup(ctx context.Context, in *gitalypb.CleanupRequest) (*gitalypb.CleanupResponse, error) {
go func() {
m.cleanupChan <- in
}()
return &gitalypb.CleanupResponse{}, nil
}
-func runMockRepositoryServer(t *testing.T) (*mockRepositoryServer, string, func()) {
+func (m *mockServer) PackRefs(ctx context.Context, in *gitalypb.PackRefsRequest) (*gitalypb.PackRefsResponse, error) {
+ go func() {
+ m.packRefsChan <- in
+ }()
+ return &gitalypb.PackRefsResponse{}, nil
+}
+
+func runMockRepositoryServer(t *testing.T) (*mockServer, string, func()) {
server := testhelper.NewTestGrpcServer(t, nil, nil)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName(t)
@@ -496,6 +517,7 @@ func runMockRepositoryServer(t *testing.T) (*mockRepositoryServer, string, func(
mockServer := newMockRepositoryServer()
gitalypb.RegisterRepositoryServiceServer(server, mockServer)
+ gitalypb.RegisterRefServiceServer(server, mockServer)
healthpb.RegisterHealthServer(server, health.NewServer())
reflection.Register(server)