Refactor spec for Geo::ProjectRegistryFinder

parent 74eae236
......@@ -163,12 +163,16 @@ module Geo
private
def fdw_disabled?
!Gitlab::Geo::Fdw.enabled?
end
def use_legacy_queries_for_selective_sync?
selective_sync? && !Gitlab::Geo::Fdw.enabled_for_selective_sync?
fdw_disabled? || selective_sync? && !Gitlab::Geo::Fdw.enabled_for_selective_sync?
end
def finder_klass_for_synced_registries
if !Gitlab::Geo::Fdw.enabled? || use_legacy_queries_for_selective_sync?
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistrySyncedFinder
else
Geo::ProjectRegistrySyncedFinder
......@@ -182,7 +186,7 @@ module Geo
end
def finder_klass_for_failed_registries
if !Gitlab::Geo::Fdw.enabled? || use_legacy_queries_for_selective_sync?
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistrySyncFailedFinder
else
Geo::ProjectRegistrySyncFailedFinder
......@@ -196,7 +200,7 @@ module Geo
end
def finder_klass_for_verified_registries
if !Gitlab::Geo::Fdw.enabled? || use_legacy_queries_for_selective_sync?
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistryVerifiedFinder
else
Geo::ProjectRegistryVerifiedFinder
......@@ -210,10 +214,10 @@ module Geo
end
def finder_klass_for_verification_failed_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync?
Geo::ProjectRegistryVerificationFailedFinder
else
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistryVerificationFailedFinder
else
Geo::ProjectRegistryVerificationFailedFinder
end
end
......@@ -224,10 +228,10 @@ module Geo
end
def finder_klass_for_registries_retrying_verification
if Gitlab::Geo::Fdw.enabled_for_selective_sync?
Geo::ProjectRegistryRetryingVerificationFinder
else
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistryRetryingVerificationFinder
else
Geo::ProjectRegistryRetryingVerificationFinder
end
end
......@@ -238,10 +242,10 @@ module Geo
end
def finder_klass_for_mismatch_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync?
Geo::ProjectRegistryMismatchFinder
else
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistryMismatchFinder
else
Geo::ProjectRegistryMismatchFinder
end
end
......@@ -252,7 +256,7 @@ module Geo
end
def finder_klass_for_registries_pending_verification
if !Gitlab::Geo::Fdw.enabled? || use_legacy_queries_for_selective_sync?
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistryPendingVerificationFinder
else
Geo::ProjectRegistryPendingVerificationFinder
......
......@@ -11,14 +11,11 @@ describe Geo::ProjectRegistryFinder, :geo do
# different connection.
let(:secondary) { create(:geo_node) }
let(:synced_group) { create(:group) }
let!(:project_not_synced) { create(:project) }
let(:project_synced) { create(:project) }
let(:project_repository_dirty) { create(:project) }
let(:project_wiki_dirty) { create(:project) }
let(:project_repository_verified) { create(:project) }
let(:project_repository_verification_failed) { create(:project) }
let(:project_wiki_verified) { create(:project) }
let(:project_wiki_verification_failed) { create(:project) }
let(:project) { create(:project) }
let(:project_1_in_synced_group) { create(:project, group: synced_group) }
let(:project_2_in_synced_group) { create(:project, group: synced_group) }
let(:project_3_in_synced_group) { create(:project, group: synced_group) }
let(:project_4_broken_storage) { create(:project, :broken_storage) }
subject { described_class.new(current_node: secondary) }
......@@ -29,12 +26,7 @@ describe Geo::ProjectRegistryFinder, :geo do
shared_examples 'counts all the things' do |method_prefix|
describe '#count_synced_repositories' do
before do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
project_3_in_synced_group = create(:project, group: synced_group)
project_4_broken_storage = create(:project, :broken_storage)
create(:geo_project_registry, :synced, project: project_synced)
create(:geo_project_registry, :synced, project: project)
create(:geo_project_registry, :synced, :repository_dirty, project: project_1_in_synced_group)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_2_in_synced_group)
create(:geo_project_registry, :sync_failed, project: project_3_in_synced_group)
......@@ -64,12 +56,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe '#count_synced_wikis' do
before do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
project_3_in_synced_group = create(:project, group: synced_group)
project_4_broken_storage = create(:project, :broken_storage)
create(:geo_project_registry, :synced, project: project_synced)
create(:geo_project_registry, :synced, project: project)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_1_in_synced_group)
create(:geo_project_registry, :synced, :repository_dirty, project: project_2_in_synced_group)
create(:geo_project_registry, :sync_failed, project: project_3_in_synced_group)
......@@ -99,12 +86,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe '#count_failed_repositories' do
before do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
project_3_in_synced_group = create(:project, group: synced_group)
project_4_broken_storage = create(:project, :broken_storage)
create(:geo_project_registry, :synced, project: project_synced)
create(:geo_project_registry, :synced, project: project)
create(:geo_project_registry, :repository_sync_failed, project: project_1_in_synced_group)
create(:geo_project_registry, :wiki_sync_failed, project: project_2_in_synced_group)
create(:geo_project_registry, :sync_failed, project: project_3_in_synced_group)
......@@ -134,12 +116,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe '#count_failed_wikis' do
before do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
project_3_in_synced_group = create(:project, group: synced_group)
project_4_broken_storage = create(:project, :broken_storage)
create(:geo_project_registry, :synced, project: project_synced)
create(:geo_project_registry, :synced, project: project)
create(:geo_project_registry, :wiki_sync_failed, project: project_1_in_synced_group)
create(:geo_project_registry, :repository_sync_failed, project: project_2_in_synced_group)
create(:geo_project_registry, :sync_failed, project: project_3_in_synced_group)
......@@ -169,12 +146,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe '#count_verified_repositories' do
before do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
project_3_in_synced_group = create(:project, group: synced_group)
project_4_broken_storage = create(:project, :broken_storage)
create(:geo_project_registry, :repository_verified, :wiki_verified, project: project_synced)
create(:geo_project_registry, :repository_verified, :wiki_verified, project: project)
create(:geo_project_registry, :repository_verified, project: project_1_in_synced_group)
create(:geo_project_registry, :repository_verification_failed, project: project_3_in_synced_group)
create(:geo_project_registry, :repository_verified, project: project_4_broken_storage)
......@@ -204,12 +176,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe '#count_verified_wikis' do
before do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
project_3_in_synced_group = create(:project, group: synced_group)
project_4_broken_storage = create(:project, :broken_storage)
create(:geo_project_registry, :wiki_verified, :wiki_verified, project: project_synced)
create(:geo_project_registry, :wiki_verified, :wiki_verified, project: project)
create(:geo_project_registry, :wiki_verified, project: project_1_in_synced_group)
create(:geo_project_registry, :wiki_verification_failed, project: project_3_in_synced_group)
create(:geo_project_registry, :wiki_verified, project: project_4_broken_storage)
......@@ -238,47 +205,87 @@ describe Geo::ProjectRegistryFinder, :geo do
end
describe '#count_verification_failed_repositories' do
it 'counts projects that verification has failed' do
create(:geo_project_registry, :repository_verified, project: project_repository_verified)
create(:geo_project_registry, :repository_verification_failed, project: project_repository_verification_failed)
create(:geo_project_registry, :wiki_verified, project: project_wiki_verified)
create(:geo_project_registry, :wiki_verification_failed, project: project_wiki_verification_failed)
before do
create(:geo_project_registry, :repository_verification_failed, :wiki_verification_failed, project: project)
create(:geo_project_registry, :repository_verification_failed, project: project_1_in_synced_group)
create(:geo_project_registry, :repository_verification_failed, project: project_4_broken_storage)
create(:geo_project_registry, :wiki_verification_failed, project: project_2_in_synced_group)
end
it 'counts registries that repository verification has failed' do
expect(subject.count_verification_failed_repositories).to eq 3
end
context 'with selective sync by namespace' do
it 'counts registries that repository verification has failed where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_verification_failed_repositories).to eq 1
end
end
context 'with selective sync by shard' do
it 'counts registries that repository verification has failed where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_verification_failed_repositories).to eq 1
expect(subject.count_verification_failed_repositories).to eq 1
end
end
end
describe '#count_verification_failed_wikis' do
it 'counts projects that verification has failed' do
create(:geo_project_registry, :repository_verified, project: project_repository_verified)
create(:geo_project_registry, :repository_verification_failed, project: project_repository_verification_failed)
create(:geo_project_registry, :wiki_verified, project: project_wiki_verified)
create(:geo_project_registry, :wiki_verification_failed, project: project_wiki_verification_failed)
before do
create(:geo_project_registry, :repository_verification_failed, :wiki_verification_failed, project: project)
create(:geo_project_registry, :wiki_verification_failed, project: project_1_in_synced_group)
create(:geo_project_registry, :wiki_verification_failed, project: project_4_broken_storage)
create(:geo_project_registry, :repository_verification_failed, project: project_2_in_synced_group)
end
it 'counts registries that wiki verification has failed' do
expect(subject.count_verification_failed_wikis).to eq 3
end
context 'with selective sync by namespace' do
it 'counts registries that wiki verification has failed where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_verification_failed_wikis).to eq 1
expect(subject.count_verification_failed_wikis).to eq 1
end
end
context 'with selective sync by shard' do
it 'counts registries that wiki verification has failed where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_verification_failed_wikis).to eq 1
end
end
end
describe '#count_repositories_retrying_verification' do
before do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
create(:geo_project_registry, :repository_retrying_verification, :wiki_retrying_verification, project: project_synced)
create(:geo_project_registry, :repository_retrying_verification, :wiki_retrying_verification, project: project)
create(:geo_project_registry, :repository_retrying_verification, project: project_1_in_synced_group)
create(:geo_project_registry, :repository_retrying_verification, project: project_4_broken_storage)
create(:geo_project_registry, :wiki_retrying_verification, project: project_2_in_synced_group)
end
it 'counts registries that repository retrying verification' do
expect(subject.count_repositories_retrying_verification).to eq 2
expect(subject.count_repositories_retrying_verification).to eq 3
end
context 'with selective sync' do
before do
context 'with selective sync by namespace' do
it 'counts registries that repository retrying verification where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_repositories_retrying_verification).to eq 1
end
end
context 'with selective sync by shard' do
it 'counts registries that repository retrying verification where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
it 'counts registries that repository retrying verification' do
expect(subject.count_repositories_retrying_verification).to eq 1
end
end
......@@ -286,70 +293,86 @@ describe Geo::ProjectRegistryFinder, :geo do
describe '#count_wikis_retrying_verification' do
before do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
create(:geo_project_registry, :repository_retrying_verification, :wiki_retrying_verification, project: project_synced)
create(:geo_project_registry, :repository_retrying_verification, :wiki_retrying_verification, project: project)
create(:geo_project_registry, :repository_retrying_verification, project: project_1_in_synced_group)
create(:geo_project_registry, :wiki_retrying_verification, project: project_2_in_synced_group)
create(:geo_project_registry, :wiki_retrying_verification, project: project_4_broken_storage)
end
it 'counts registries that wiki retrying verification' do
expect(subject.count_wikis_retrying_verification).to eq 2
expect(subject.count_wikis_retrying_verification).to eq 3
end
context 'with selective sync' do
before do
context 'with selective sync by namespace' do
it 'counts registries that wiki retrying verification where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_wikis_retrying_verification).to eq 1
end
end
context 'with selective sync by shard' do
it 'counts registries that wiki retrying verification where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
it 'counts registries that wiki retrying verification' do
expect(subject.count_wikis_retrying_verification).to eq 1
end
end
end
describe '#count_repositories_checksum_mismatch' do
let(:project_1_in_synced_group) { create(:project, group: synced_group) }
let(:project_2_in_synced_group) { create(:project, group: synced_group) }
let!(:registry_mismatch) { create(:geo_project_registry, :repository_checksum_mismatch, :wiki_checksum_mismatch, project: project_synced) }
let!(:repository_mismatch) { create(:geo_project_registry, :repository_checksum_mismatch, project: project_1_in_synced_group) }
let!(:wiki_mismatch) { create(:geo_project_registry, :wiki_checksum_mismatch, project: project_2_in_synced_group) }
before do
create(:geo_project_registry, :repository_checksum_mismatch, :wiki_checksum_mismatch, project: project)
create(:geo_project_registry, :repository_checksum_mismatch, project: project_1_in_synced_group)
create(:geo_project_registry, :repository_checksum_mismatch, :wiki_verified, project: project_4_broken_storage)
create(:geo_project_registry, :wiki_checksum_mismatch, project: project_2_in_synced_group)
end
it 'counts registries that repository mismatch' do
expect(subject.count_repositories_checksum_mismatch).to eq 2
expect(subject.count_repositories_checksum_mismatch).to eq 3
end
context 'with selective sync' do
before do
context 'with selective sync by namespace' do
it 'counts mismatch registries where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_repositories_checksum_mismatch).to eq 1
end
end
context 'with selective sync by shard' do
it 'counts mismatch registries where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
it 'counts projects that sync has failed' do
expect(subject.count_repositories_checksum_mismatch).to eq 1
end
end
end
describe '#count_wikis_checksum_mismatch' do
let(:project_1_in_synced_group) { create(:project, group: synced_group) }
let(:project_2_in_synced_group) { create(:project, group: synced_group) }
let!(:registry_mismatch) { create(:geo_project_registry, :repository_checksum_mismatch, :wiki_checksum_mismatch, project: project_synced) }
let!(:repository_mismatch) { create(:geo_project_registry, :repository_checksum_mismatch, project: project_1_in_synced_group) }
let!(:wiki_mismatch) { create(:geo_project_registry, :wiki_checksum_mismatch, project: project_2_in_synced_group) }
before do
create(:geo_project_registry, :repository_checksum_mismatch, :wiki_checksum_mismatch, project: project)
create(:geo_project_registry, :repository_checksum_mismatch, project: project_1_in_synced_group)
create(:geo_project_registry, :wiki_checksum_mismatch, project: project_2_in_synced_group)
create(:geo_project_registry, :repository_verified, :wiki_checksum_mismatch, project: project_4_broken_storage)
end
it 'counts projects that verification has failed' do
expect(subject.count_wikis_checksum_mismatch).to eq 2
it 'counts registries that wiki mismatch' do
expect(subject.count_wikis_checksum_mismatch).to eq 3
end
context 'with selective sync' do
before do
context 'with selective sync by namespace' do
it 'counts mismatch registries where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_wikis_checksum_mismatch).to eq 1
end
end
context 'with selective sync by shard' do
it 'counts mismatch registries where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
it 'counts projects that sync has failed' do
expect(subject.count_wikis_checksum_mismatch).to eq 1
end
end
......@@ -365,7 +388,8 @@ describe Geo::ProjectRegistryFinder, :geo do
end
it 'returns projects without an entry on the tracking database' do
create(:geo_project_registry, :synced, :repository_dirty, project: project_repository_dirty)
project_not_synced = create(:project)
create(:geo_project_registry, :synced, :repository_dirty, project: project_1_in_synced_group)
projects = subject.find_unsynced_projects(batch_size: 10)
......@@ -384,9 +408,6 @@ describe Geo::ProjectRegistryFinder, :geo do
end
it 'returns untracked projects in the synced group' do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
create(:geo_project_registry, :sync_failed, project: project_1_in_synced_group)
projects = subject.find_unsynced_projects(batch_size: 10)
......@@ -404,12 +425,12 @@ describe Geo::ProjectRegistryFinder, :geo do
end
it 'returns projects with a dirty entry on the tracking database' do
create(:geo_project_registry, :synced, :repository_dirty, project: project_repository_dirty)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_wiki_dirty)
create(:geo_project_registry, :synced, :repository_dirty, project: project_1_in_synced_group)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_2_in_synced_group)
projects = subject.find_projects_updated_recently(batch_size: 10)
expect(projects).to match_ids([project_repository_dirty, project_wiki_dirty])
expect(projects).to match_ids([project_1_in_synced_group, project_2_in_synced_group])
end
context 'with selective sync' do
......@@ -424,11 +445,7 @@ describe Geo::ProjectRegistryFinder, :geo do
end
it 'returns dirty projects in the synced group' do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
project_3_in_synced_group = create(:project, group: synced_group)
create(:project, group: synced_group)
create(:geo_project_registry, :synced, :repository_dirty, project: project_1_in_synced_group)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_2_in_synced_group)
create(:geo_project_registry, :synced, project: project_3_in_synced_group)
......@@ -441,6 +458,35 @@ describe Geo::ProjectRegistryFinder, :geo do
end
end
shared_examples 'delegates to the proper finder' do |legacy_finder_klass, finder_klass, method, args|
where(:selective_sync, :fdw_enabled, :fdw_for_selective_sync, :finder) do
false | false | false | legacy_finder_klass
false | false | true | legacy_finder_klass
false | true | true | finder_klass
false | true | false | finder_klass
true | false | false | legacy_finder_klass
true | false | true | legacy_finder_klass
true | true | true | finder_klass
true | true | false | legacy_finder_klass
end
with_them do
before do
stub_fdw(fdw_enabled)
stub_feature_flags(use_fdw_queries_for_selective_sync: fdw_for_selective_sync)
stub_selective_sync(secondary, selective_sync)
end
it 'delegates to the proper finder' do
expect_next_instance_of(finder) do |finder|
expect(finder).to receive(:execute).once
end
subject.public_send(method, *args)
end
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
context 'FDW', :delete do
......@@ -477,116 +523,30 @@ describe Geo::ProjectRegistryFinder, :geo do
end
describe '#find_failed_project_registries', :delete do
where(:selective_sync, :fdw_enabled, :use_fdw_queries_for_selective_sync, :finder) do
false | false | false | Geo::LegacyProjectRegistrySyncFailedFinder
false | false | true | Geo::LegacyProjectRegistrySyncFailedFinder
false | true | true | Geo::ProjectRegistrySyncFailedFinder
false | true | false | Geo::ProjectRegistrySyncFailedFinder
true | false | false | Geo::LegacyProjectRegistrySyncFailedFinder
true | false | true | Geo::LegacyProjectRegistrySyncFailedFinder
true | true | true | Geo::ProjectRegistrySyncFailedFinder
true | true | false | Geo::LegacyProjectRegistrySyncFailedFinder
end
with_them do
before do
stub_geo_environment(secondary, selective_sync, fdw_enabled, use_fdw_queries_for_selective_sync)
end
it 'delegates to the correct finder' do
expect_next_instance_of(finder, current_node: secondary, type: 'repository') do |finder|
expect(finder).to receive(:execute).once
end
subject.find_failed_project_registries('repository')
end
end
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistrySyncFailedFinder,
Geo::ProjectRegistrySyncFailedFinder,
:find_failed_project_registries, ['repository']
end
describe '#find_registries_to_verify', :delete do
where(:selective_sync, :fdw_enabled, :use_fdw_queries_for_selective_sync, :finder) do
false | false | false | Geo::LegacyProjectRegistryPendingVerificationFinder
false | false | true | Geo::LegacyProjectRegistryPendingVerificationFinder
false | true | true | Geo::ProjectRegistryPendingVerificationFinder
false | true | false | Geo::ProjectRegistryPendingVerificationFinder
true | false | false | Geo::LegacyProjectRegistryPendingVerificationFinder
true | false | true | Geo::LegacyProjectRegistryPendingVerificationFinder
true | true | true | Geo::ProjectRegistryPendingVerificationFinder
true | true | false | Geo::LegacyProjectRegistryPendingVerificationFinder
end
with_them do
before do
stub_geo_environment(secondary, selective_sync, fdw_enabled, use_fdw_queries_for_selective_sync)
end
it 'delegates to Geo::ProjectRegistryPendingVerificationFinder' do
expect_next_instance_of(finder, current_node: secondary, shard_name: 'default', batch_size: 100) do |finder|
expect(finder).to receive(:execute).once
end
subject.find_registries_to_verify(shard_name: 'default', batch_size: 100)
end
end
end
describe '#find_checksum_mismatch_project_registries', :delete do
where(:selective_sync, :fdw_enabled, :use_fdw_queries_for_selective_sync, :finder) do
false | false | false | Geo::LegacyProjectRegistryMismatchFinder
false | false | true | Geo::LegacyProjectRegistryMismatchFinder
false | true | true | Geo::ProjectRegistryMismatchFinder
false | true | false | Geo::ProjectRegistryMismatchFinder
true | false | false | Geo::LegacyProjectRegistryMismatchFinder
true | false | true | Geo::LegacyProjectRegistryMismatchFinder
true | true | true | Geo::ProjectRegistryMismatchFinder
true | true | false | Geo::LegacyProjectRegistryMismatchFinder
end
with_them do
before do
stub_geo_environment(secondary, selective_sync, fdw_enabled, use_fdw_queries_for_selective_sync)
end
it 'delegates to the correct finder' do
expect_next_instance_of(finder, current_node: secondary, type: 'repository') do |finder|
expect(finder).to receive(:execute).once
end
subject.find_checksum_mismatch_project_registries('repository')
end
end
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistryPendingVerificationFinder,
Geo::ProjectRegistryPendingVerificationFinder,
:find_registries_to_verify, [shard_name: 'default', batch_size: 100]
end
describe '#find_verification_failed_project_registries', :delete do
where(:selective_sync, :fdw_enabled, :use_fdw_queries_for_selective_sync, :finder) do
false | false | false | Geo::LegacyProjectRegistryVerificationFailedFinder
false | false | true | Geo::LegacyProjectRegistryVerificationFailedFinder
false | true | true | Geo::ProjectRegistryVerificationFailedFinder
false | true | false | Geo::ProjectRegistryVerificationFailedFinder
true | false | false | Geo::LegacyProjectRegistryVerificationFailedFinder
true | false | true | Geo::LegacyProjectRegistryVerificationFailedFinder
true | true | true | Geo::ProjectRegistryVerificationFailedFinder
true | true | false | Geo::LegacyProjectRegistryVerificationFailedFinder
end
with_them do
before do
stub_geo_environment(secondary, selective_sync, fdw_enabled, use_fdw_queries_for_selective_sync)
end
it 'delegates to the correct finder' do
expect_next_instance_of(finder, current_node: secondary, type: 'repository') do |finder|
expect(finder).to receive(:execute).once
end
subject.find_verification_failed_project_registries('repository')
end
end
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistryVerificationFailedFinder,
Geo::ProjectRegistryVerificationFailedFinder,
:find_verification_failed_project_registries, ['repository']
end
def stub_geo_environment(node, selective_sync, fdw_enabled, use_fdw_queries_for_selective_sync)
stub_fdw(fdw_enabled)
stub_feature_flags(use_fdw_queries_for_selective_sync: use_fdw_queries_for_selective_sync)
stub_selective_sync(node, selective_sync)
describe '#find_checksum_mismatch_project_registries', :delete do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistryMismatchFinder,
Geo::ProjectRegistryMismatchFinder,
:find_checksum_mismatch_project_registries, ['repository']
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment