Commit 9a90e5d2 authored by Michael Kozono's avatar Michael Kozono

Merge branch '8798-refactor-project-registry-finder' into 'master'

Geo - Refactor the `Geo::ProjectRegistryFinder` class

See merge request gitlab-org/gitlab-ee!10529
parents c3292e65 f04739cd
...@@ -22,30 +22,16 @@ module Geo ...@@ -22,30 +22,16 @@ module Geo
end end
def execute def execute
if selective_sync?
mismatch_registries_for_selective_sync
else
mismatch_registries
end
end
private
attr_reader :type
def mismatch_registries
Geo::ProjectRegistry.mismatch(type)
end
# rubocop: disable CodeReuse/ActiveRecord
def mismatch_registries_for_selective_sync
legacy_inner_join_registry_ids( legacy_inner_join_registry_ids(
mismatch_registries, Geo::ProjectRegistry.mismatch(type),
current_node.projects.pluck(:id), current_node.projects.pluck_primary_key,
Geo::ProjectRegistry, Geo::ProjectRegistry,
foreign_key: :project_id foreign_key: :project_id
) )
end end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end end
end end
...@@ -22,30 +22,16 @@ module Geo ...@@ -22,30 +22,16 @@ module Geo
end end
def execute def execute
if selective_sync?
registries_retrying_verification_for_selective_sync
else
registries_retrying_verification
end
end
private
attr_reader :type
def registries_retrying_verification
Geo::ProjectRegistry.retrying_verification(type)
end
# rubocop: disable CodeReuse/ActiveRecord
def registries_retrying_verification_for_selective_sync
legacy_inner_join_registry_ids( legacy_inner_join_registry_ids(
registries_retrying_verification, Geo::ProjectRegistry.retrying_verification(type),
current_node.projects.pluck(:id), current_node.projects.pluck_primary_key,
Geo::ProjectRegistry, Geo::ProjectRegistry,
foreign_key: :project_id foreign_key: :project_id
) )
end end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end end
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Finder for retrieving project registries that synchronization have # Finder for retrieving project registries that synchronization have
# failed scoped to a type (repository or wiki) using cross-database # failed scoped to a type (repository or wiki) using cross-database
# joins for selective sync. # joins.
# #
# Basic usage: # Basic usage:
# #
...@@ -22,30 +22,16 @@ module Geo ...@@ -22,30 +22,16 @@ module Geo
end end
def execute def execute
if selective_sync?
failed_registries_for_selective_sync
else
failed_registries
end
end
private
attr_reader :type
def failed_registries
Geo::ProjectRegistry.sync_failed(type)
end
# rubocop: disable CodeReuse/ActiveRecord
def failed_registries_for_selective_sync
legacy_inner_join_registry_ids( legacy_inner_join_registry_ids(
failed_registries, Geo::ProjectRegistry.sync_failed(type),
current_node.projects.pluck(:id), current_node.projects.pluck_primary_key,
Geo::ProjectRegistry, Geo::ProjectRegistry,
foreign_key: :project_id foreign_key: :project_id
) )
end end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
# Finder for retrieving project registries that have been synced # Finder for retrieving project registries that have been synced
# scoped to a type (repository or wiki) using cross-database joins # scoped to a type (repository or wiki) using cross-database joins.
# for selective sync.
# #
# Basic usage: # Basic usage:
# #
...@@ -22,30 +21,16 @@ module Geo ...@@ -22,30 +21,16 @@ module Geo
end end
def execute def execute
if selective_sync?
synced_registries_for_selective_sync
else
synced_registries
end
end
private
attr_reader :type
def synced_registries
Geo::ProjectRegistry.synced(type)
end
# rubocop: disable CodeReuse/ActiveRecord
def synced_registries_for_selective_sync
legacy_inner_join_registry_ids( legacy_inner_join_registry_ids(
synced_registries, Geo::ProjectRegistry.synced(type),
current_node.projects.pluck(:id), current_node.projects.pluck_primary_key,
Geo::ProjectRegistry, Geo::ProjectRegistry,
foreign_key: :project_id foreign_key: :project_id
) )
end end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end end
end end
...@@ -22,30 +22,16 @@ module Geo ...@@ -22,30 +22,16 @@ module Geo
end end
def execute def execute
if selective_sync?
failed_registries_for_selective_sync
else
failed_registries
end
end
private
attr_reader :type
def failed_registries
Geo::ProjectRegistry.verification_failed(type)
end
# rubocop: disable CodeReuse/ActiveRecord
def failed_registries_for_selective_sync
legacy_inner_join_registry_ids( legacy_inner_join_registry_ids(
failed_registries, Geo::ProjectRegistry.verification_failed(type),
current_node.projects.pluck(:id), current_node.projects.pluck_primary_key,
Geo::ProjectRegistry, Geo::ProjectRegistry,
foreign_key: :project_id foreign_key: :project_id
) )
end end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
# Finder for retrieving project registries that have been verified # Finder for retrieving project registries that have been verified
# scoped to a type (repository or wiki) using cross-database joins # scoped to a type (repository or wiki) using cross-database joins.
# for selective sync.
# #
# Basic usage: # Basic usage:
# #
...@@ -22,30 +21,16 @@ module Geo ...@@ -22,30 +21,16 @@ module Geo
end end
def execute def execute
if selective_sync?
verified_registries_for_selective_sync
else
verified_registries
end
end
private
attr_reader :type
def verified_registries
Geo::ProjectRegistry.verified(type)
end
# rubocop: disable CodeReuse/ActiveRecord
def verified_registries_for_selective_sync
legacy_inner_join_registry_ids( legacy_inner_join_registry_ids(
verified_registries, Geo::ProjectRegistry.verified(type),
current_node.projects.pluck(:id), current_node.projects.pluck_primary_key,
Geo::ProjectRegistry, Geo::ProjectRegistry,
foreign_key: :project_id foreign_key: :project_id
) )
end end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end end
end end
...@@ -163,15 +163,19 @@ module Geo ...@@ -163,15 +163,19 @@ module Geo
private private
def fdw_disabled?
!Gitlab::Geo::Fdw.enabled?
end
def use_legacy_queries_for_selective_sync? 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 end
def finder_klass_for_synced_registries def finder_klass_for_synced_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync? if use_legacy_queries_for_selective_sync?
Geo::ProjectRegistrySyncedFinder
else
Geo::LegacyProjectRegistrySyncedFinder Geo::LegacyProjectRegistrySyncedFinder
else
Geo::ProjectRegistrySyncedFinder
end end
end end
...@@ -182,10 +186,10 @@ module Geo ...@@ -182,10 +186,10 @@ module Geo
end end
def finder_klass_for_failed_registries def finder_klass_for_failed_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync? if use_legacy_queries_for_selective_sync?
Geo::ProjectRegistrySyncFailedFinder
else
Geo::LegacyProjectRegistrySyncFailedFinder Geo::LegacyProjectRegistrySyncFailedFinder
else
Geo::ProjectRegistrySyncFailedFinder
end end
end end
...@@ -196,10 +200,10 @@ module Geo ...@@ -196,10 +200,10 @@ module Geo
end end
def finder_klass_for_verified_registries def finder_klass_for_verified_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync? if use_legacy_queries_for_selective_sync?
Geo::ProjectRegistryVerifiedFinder
else
Geo::LegacyProjectRegistryVerifiedFinder Geo::LegacyProjectRegistryVerifiedFinder
else
Geo::ProjectRegistryVerifiedFinder
end end
end end
...@@ -210,10 +214,10 @@ module Geo ...@@ -210,10 +214,10 @@ module Geo
end end
def finder_klass_for_verification_failed_registries def finder_klass_for_verification_failed_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync? if use_legacy_queries_for_selective_sync?
Geo::ProjectRegistryVerificationFailedFinder
else
Geo::LegacyProjectRegistryVerificationFailedFinder Geo::LegacyProjectRegistryVerificationFailedFinder
else
Geo::ProjectRegistryVerificationFailedFinder
end end
end end
...@@ -224,10 +228,10 @@ module Geo ...@@ -224,10 +228,10 @@ module Geo
end end
def finder_klass_for_registries_retrying_verification def finder_klass_for_registries_retrying_verification
if Gitlab::Geo::Fdw.enabled_for_selective_sync? if use_legacy_queries_for_selective_sync?
Geo::ProjectRegistryRetryingVerificationFinder
else
Geo::LegacyProjectRegistryRetryingVerificationFinder Geo::LegacyProjectRegistryRetryingVerificationFinder
else
Geo::ProjectRegistryRetryingVerificationFinder
end end
end end
...@@ -238,10 +242,10 @@ module Geo ...@@ -238,10 +242,10 @@ module Geo
end end
def finder_klass_for_mismatch_registries def finder_klass_for_mismatch_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync? if use_legacy_queries_for_selective_sync?
Geo::ProjectRegistryMismatchFinder
else
Geo::LegacyProjectRegistryMismatchFinder Geo::LegacyProjectRegistryMismatchFinder
else
Geo::ProjectRegistryMismatchFinder
end end
end end
...@@ -252,7 +256,7 @@ module Geo ...@@ -252,7 +256,7 @@ module Geo
end end
def finder_klass_for_registries_pending_verification 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 Geo::LegacyProjectRegistryPendingVerificationFinder
else else
Geo::ProjectRegistryPendingVerificationFinder Geo::ProjectRegistryPendingVerificationFinder
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Geo::LegacyProjectRegistryMismatchFinder, :geo do describe Geo::LegacyProjectRegistryMismatchFinder, :geo do
include EE::GeoHelpers
describe '#execute' do describe '#execute' do
let(:node) { create(:geo_node) } let(:node) { create(:geo_node) }
let(:group_1) { create(:group) } let(:group_1) { create(:group) }
...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do ...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do
let!(:registry_repository_mismatch_broken_shard) { create(:geo_project_registry, :repository_checksum_mismatch, :wiki_verified, project: project_5) } let!(:registry_repository_mismatch_broken_shard) { create(:geo_project_registry, :repository_checksum_mismatch, :wiki_verified, project: project_5) }
let!(:registry_verified) { create(:geo_project_registry, :repository_verified, :wiki_verified) } let!(:registry_verified) { create(:geo_project_registry, :repository_verified, :wiki_verified) }
shared_examples 'finds mismatch registries' do
context 'with repository type' do context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) } subject { described_class.new(current_node: node, type: :repository) }
...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do ...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns mismatch registries where projects belongs to the namespaces' do it 'returns mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch) expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch)
end end
...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do ...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns mismatch registries where projects belongs to the namespaces' do it 'returns mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_mismatch, registry_wiki_mismatch) expect(subject.execute).to contain_exactly(registry_mismatch, registry_wiki_mismatch)
end end
...@@ -86,7 +83,7 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do ...@@ -86,7 +83,7 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns all mismatch registries where projects belongs to the namespaces' do it 'returns all mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_wiki_mismatch) expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_wiki_mismatch)
end end
...@@ -101,23 +98,4 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do ...@@ -101,23 +98,4 @@ describe Geo::LegacyProjectRegistryMismatchFinder, :geo do
end end
end 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
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
include_examples 'finds mismatch registries'
end
context 'Legacy' do
before do
stub_fdw_disabled
end
include_examples 'finds mismatch registries'
end
end
end end
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Geo::LegacyProjectRegistryPendingVerificationFinder, :geo do describe Geo::LegacyProjectRegistryPendingVerificationFinder, :geo do
include EE::GeoHelpers
describe '#execute' do describe '#execute' do
let(:node) { create(:geo_node) } let(:node) { create(:geo_node) }
...@@ -145,7 +143,7 @@ describe Geo::LegacyProjectRegistryPendingVerificationFinder, :geo do ...@@ -145,7 +143,7 @@ describe Geo::LegacyProjectRegistryPendingVerificationFinder, :geo do
registry_outdated_secondary = create(:geo_project_registry, :synced, :repository_verification_outdated, :wiki_verification_outdated, project: project_2) registry_outdated_secondary = create(:geo_project_registry, :synced, :repository_verification_outdated, :wiki_verification_outdated, project: project_2)
create(:geo_project_registry, :synced, :repository_verification_outdated, :wiki_verified, project: project_3) create(:geo_project_registry, :synced, :repository_verification_outdated, :wiki_verified, project: project_3)
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute) expect(subject.execute)
.to contain_exactly( .to contain_exactly(
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do
include EE::GeoHelpers
describe '#execute' do describe '#execute' do
let(:node) { create(:geo_node) } let(:node) { create(:geo_node) }
let(:group_1) { create(:group) } let(:group_1) { create(:group) }
...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do ...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do
let!(:repository_retrying_verification_broken_shard) { create(:geo_project_registry, :repository_retrying_verification, :wiki_verified, project: project_5) } let!(:repository_retrying_verification_broken_shard) { create(:geo_project_registry, :repository_retrying_verification, :wiki_verified, project: project_5) }
let!(:verified) { create(:geo_project_registry, :repository_verified, :wiki_verified) } let!(:verified) { create(:geo_project_registry, :repository_verified, :wiki_verified) }
shared_examples 'finds registries retrying verification' do
context 'with repository type' do context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) } subject { described_class.new(current_node: node, type: :repository) }
...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do ...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns registries retrying verification where projects belongs to the namespaces' do it 'returns registries retrying verification where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(retrying_verification, repository_retrying_verification) expect(subject.execute).to contain_exactly(retrying_verification, repository_retrying_verification)
end end
...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do ...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns registries retrying verification where projects belongs to the namespaces' do it 'returns registries retrying verification where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(retrying_verification, wiki_retrying_verification) expect(subject.execute).to contain_exactly(retrying_verification, wiki_retrying_verification)
end end
...@@ -97,23 +94,4 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do ...@@ -97,23 +94,4 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do
end end
end 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
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
include_examples 'finds registries retrying verification'
end
context 'Legacy' do
before do
stub_fdw_disabled
end
include_examples 'finds registries retrying verification'
end
end
end end
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do
include EE::GeoHelpers
describe '#execute' do describe '#execute' do
let(:node) { create(:geo_node) } let(:node) { create(:geo_node) }
let(:group_1) { create(:group) } let(:group_1) { create(:group) }
...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do ...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do
let!(:registry_repository_failed_broken_shard) { create(:geo_project_registry, :synced, :repository_sync_failed, project: project_5) } let!(:registry_repository_failed_broken_shard) { create(:geo_project_registry, :synced, :repository_sync_failed, project: project_5) }
let!(:registry_synced) { create(:geo_project_registry, :synced) } let!(:registry_synced) { create(:geo_project_registry, :synced) }
shared_examples 'finds failed registries' do
context 'with repository type' do context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) } subject { described_class.new(current_node: node, type: :repository) }
...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do ...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_failed, registry_repository_failed]) expect(subject.execute).to match_array([registry_failed, registry_repository_failed])
end end
...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do ...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_failed, registry_wiki_failed]) expect(subject.execute).to match_array([registry_failed, registry_wiki_failed])
end end
...@@ -86,7 +83,7 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do ...@@ -86,7 +83,7 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns all failed registries where projects belongs to the namespaces' do it 'returns all failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_wiki_failed]) expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_wiki_failed])
end end
...@@ -101,23 +98,4 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do ...@@ -101,23 +98,4 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do
end end
end 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
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
include_examples 'finds failed registries'
end
context 'Legacy' do
before do
stub_fdw_disabled
end
include_examples 'finds failed registries'
end
end
end end
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Geo::LegacyProjectRegistrySyncedFinder, :geo do describe Geo::LegacyProjectRegistrySyncedFinder, :geo do
include EE::GeoHelpers
describe '#execute' do describe '#execute' do
let(:node) { create(:geo_node) } let(:node) { create(:geo_node) }
let(:group_1) { create(:group) } let(:group_1) { create(:group) }
...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do ...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do
let!(:registry_repository_dirty_broken_shard) { create(:geo_project_registry, :synced, :repository_dirty, project: project_5) } let!(:registry_repository_dirty_broken_shard) { create(:geo_project_registry, :synced, :repository_dirty, project: project_5) }
let!(:registry_sync_failed) { create(:geo_project_registry, :sync_failed) } let!(:registry_sync_failed) { create(:geo_project_registry, :sync_failed) }
shared_examples 'finds synced registries' do
context 'with repository type' do context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) } subject { described_class.new(current_node: node, type: :repository) }
...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do ...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns synced registries where projects belongs to the namespaces' do it 'returns synced registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_synced, registry_wiki_dirty]) expect(subject.execute).to match_array([registry_synced, registry_wiki_dirty])
end end
...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do ...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns synced registries where projects belongs to the namespaces' do it 'returns synced registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_synced, registry_repository_dirty]) expect(subject.execute).to match_array([registry_synced, registry_repository_dirty])
end end
...@@ -83,23 +80,4 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do ...@@ -83,23 +80,4 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do
end end
end 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
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
include_examples 'finds synced registries'
end
context 'Legacy' do
before do
stub_fdw_disabled
end
include_examples 'finds synced registries'
end
end
end end
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do
include EE::GeoHelpers
describe '#execute' do describe '#execute' do
let(:node) { create(:geo_node) } let(:node) { create(:geo_node) }
let(:group_1) { create(:group) } let(:group_1) { create(:group) }
...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do ...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do
let!(:registry_repository_verification_failed_broken_shard) { create(:geo_project_registry, :repository_verification_failed, :wiki_verified, project: project_5) } let!(:registry_repository_verification_failed_broken_shard) { create(:geo_project_registry, :repository_verification_failed, :wiki_verified, project: project_5) }
let!(:registry_verified) { create(:geo_project_registry, :repository_verified, :wiki_verified) } let!(:registry_verified) { create(:geo_project_registry, :repository_verified, :wiki_verified) }
shared_examples 'finds registries that verification failed' do
context 'with repository type' do context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) } subject { described_class.new(current_node: node, type: :repository) }
...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do ...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed) expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed)
end end
...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do ...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_wiki_verification_failed) expect(subject.execute).to contain_exactly(registry_verification_failed, registry_wiki_verification_failed)
end end
...@@ -86,7 +83,7 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do ...@@ -86,7 +83,7 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns all failed registries where projects belongs to the namespaces' do it 'returns all failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_wiki_verification_failed) expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_wiki_verification_failed)
end end
...@@ -101,23 +98,4 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do ...@@ -101,23 +98,4 @@ describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do
end end
end 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
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
include_examples 'finds registries that verification failed'
end
context 'Legacy' do
before do
stub_fdw_disabled
end
include_examples 'finds registries that verification failed'
end
end
end end
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do
include EE::GeoHelpers
describe '#execute' do describe '#execute' do
let(:node) { create(:geo_node) } let(:node) { create(:geo_node) }
let(:group_1) { create(:group) } let(:group_1) { create(:group) }
...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do ...@@ -22,7 +20,6 @@ describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do
let!(:registry_wiki_verification_failed_broken_shard) { create(:geo_project_registry, :repository_verified, :wiki_verification_failed, project: project_4) } let!(:registry_wiki_verification_failed_broken_shard) { create(:geo_project_registry, :repository_verified, :wiki_verification_failed, project: project_4) }
let!(:registry_verification_failed) { create(:geo_project_registry, :repository_verification_failed, :wiki_verification_failed) } let!(:registry_verification_failed) { create(:geo_project_registry, :repository_verification_failed, :wiki_verification_failed) }
shared_examples 'finds verified registries' do
context 'with repository type' do context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) } subject { described_class.new(current_node: node, type: :repository) }
...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do ...@@ -34,7 +31,7 @@ describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns verified registries where projects belongs to the namespaces' do it 'returns verified registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verified, registry_wiki_verification_failed) expect(subject.execute).to contain_exactly(registry_verified, registry_wiki_verification_failed)
end end
...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do ...@@ -60,7 +57,7 @@ describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns verified registries where projects belongs to the namespaces' do it 'returns verified registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verified, registry_repository_verification_failed) expect(subject.execute).to contain_exactly(registry_verified, registry_repository_verification_failed)
end end
...@@ -83,23 +80,4 @@ describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do ...@@ -83,23 +80,4 @@ describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do
end end
end 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
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
include_examples 'finds verified registries'
end
context 'Legacy' do
before do
stub_fdw_disabled
end
include_examples 'finds verified registries'
end
end
end end
...@@ -11,14 +11,11 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -11,14 +11,11 @@ describe Geo::ProjectRegistryFinder, :geo do
# different connection. # different connection.
let(:secondary) { create(:geo_node) } let(:secondary) { create(:geo_node) }
let(:synced_group) { create(:group) } let(:synced_group) { create(:group) }
let!(:project_not_synced) { create(:project) } let(:project) { create(:project) }
let(:project_synced) { create(:project) } let(:project_1_in_synced_group) { create(:project, group: synced_group) }
let(:project_repository_dirty) { create(:project) } let(:project_2_in_synced_group) { create(:project, group: synced_group) }
let(:project_wiki_dirty) { create(:project) } let(:project_3_in_synced_group) { create(:project, group: synced_group) }
let(:project_repository_verified) { create(:project) } let(:project_4_broken_storage) { create(:project, :broken_storage) }
let(:project_repository_verification_failed) { create(:project) }
let(:project_wiki_verified) { create(:project) }
let(:project_wiki_verification_failed) { create(:project) }
subject { described_class.new(current_node: secondary) } subject { described_class.new(current_node: secondary) }
...@@ -28,27 +25,29 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -28,27 +25,29 @@ describe Geo::ProjectRegistryFinder, :geo do
shared_examples 'counts all the things' do |method_prefix| shared_examples 'counts all the things' do |method_prefix|
describe '#count_synced_repositories' do describe '#count_synced_repositories' do
it 'counts repositories that have been synced' do before do
create(:geo_project_registry, :sync_failed) create(:geo_project_registry, :synced, project: project)
create(:geo_project_registry, :synced, project: project_synced) create(:geo_project_registry, :synced, :repository_dirty, project: project_1_in_synced_group)
create(:geo_project_registry, :synced, :repository_dirty, project: project_repository_dirty) create(:geo_project_registry, :synced, :wiki_dirty, project: project_2_in_synced_group)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_wiki_dirty) create(:geo_project_registry, :sync_failed, project: project_3_in_synced_group)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_4_broken_storage)
end
expect(subject.count_synced_repositories).to eq 2 it 'counts registries that repository have been synced' do
expect(subject.count_synced_repositories).to eq 3
end end
context 'with selective sync' do context 'with selective sync by namespace' do
before do it 'counts registries that repository have been synced where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'counts projects that has been synced' do expect(subject.count_synced_repositories).to eq 1
project_1_in_synced_group = create(:project, group: synced_group) end
project_2_in_synced_group = create(:project, group: synced_group) end
create(:geo_project_registry, :synced, project: project_synced) context 'with selective sync by shard' do
create(:geo_project_registry, :synced, project: project_1_in_synced_group) it 'counts registries that repository have been synced where projects belongs to the shards' do
create(:geo_project_registry, :sync_failed, project: project_2_in_synced_group) secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_synced_repositories).to eq 1 expect(subject.count_synced_repositories).to eq 1
end end
...@@ -56,35 +55,29 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -56,35 +55,29 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
describe '#count_synced_wikis' do describe '#count_synced_wikis' do
it 'counts wiki that have been synced' do before do
create(:geo_project_registry, :sync_failed) create(:geo_project_registry, :synced, project: project)
create(:geo_project_registry, :synced, project: project_synced) create(:geo_project_registry, :synced, :wiki_dirty, project: project_1_in_synced_group)
create(:geo_project_registry, :synced, :repository_dirty, project: project_repository_dirty) create(:geo_project_registry, :synced, :repository_dirty, project: project_2_in_synced_group)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_wiki_dirty) create(:geo_project_registry, :sync_failed, project: project_3_in_synced_group)
create(:geo_project_registry, :synced, :repository_dirty, project: project_4_broken_storage)
expect(subject.count_synced_wikis).to eq 2
end end
it 'counts synced wikis with nil wiki_access_level (which means enabled wiki)' do it 'counts registries that wiki have been synced' do
project_synced.project_feature.update!(wiki_access_level: nil) expect(subject.count_synced_wikis).to eq 3
end
create(:geo_project_registry, :synced, project: project_synced) context 'with selective sync by namespace' do
it 'counts registries that wiki have been synced where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_synced_wikis).to eq 1 expect(subject.count_synced_wikis).to eq 1
end end
context 'with selective sync' do
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end end
it 'counts projects that has been synced' do context 'with selective sync by shard' do
project_1_in_synced_group = create(:project, group: synced_group) it 'counts registries that wiki have been synced where projects belongs to the shards' do
project_2_in_synced_group = create(:project, group: synced_group) secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
create(:geo_project_registry, :synced, project: project_synced)
create(:geo_project_registry, :synced, project: project_1_in_synced_group)
create(:geo_project_registry, :sync_failed, project: project_2_in_synced_group)
expect(subject.count_synced_wikis).to eq 1 expect(subject.count_synced_wikis).to eq 1
end end
...@@ -92,27 +85,29 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -92,27 +85,29 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
describe '#count_failed_repositories' do describe '#count_failed_repositories' do
it 'counts projects that sync has failed' do before do
create(:geo_project_registry, :synced) create(:geo_project_registry, :synced, project: project)
create(:geo_project_registry, :sync_failed, project: project_synced) create(:geo_project_registry, :repository_sync_failed, project: project_1_in_synced_group)
create(:geo_project_registry, :repository_sync_failed, project: project_repository_dirty) create(:geo_project_registry, :wiki_sync_failed, project: project_2_in_synced_group)
create(:geo_project_registry, :wiki_sync_failed, project: project_wiki_dirty) create(:geo_project_registry, :sync_failed, project: project_3_in_synced_group)
create(:geo_project_registry, :repository_sync_failed, project: project_4_broken_storage)
end
expect(subject.count_failed_repositories).to eq 2 it 'counts registries that repository sync has failed' do
expect(subject.count_failed_repositories).to eq 3
end end
context 'with selective sync' do context 'with selective sync by namespace' do
before do it 'counts registries that repository sync has failed where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'counts projects that sync has failed' do expect(subject.count_failed_repositories).to eq 2
project_1_in_synced_group = create(:project, group: synced_group) end
project_2_in_synced_group = create(:project, group: synced_group) end
create(:geo_project_registry, :sync_failed, project: project_synced) context 'with selective sync by shard' do
create(:geo_project_registry, :repository_sync_failed, project: project_1_in_synced_group) it 'counts registries that repository sync has failed where projects belongs to the shards' do
create(:geo_project_registry, :synced, project: project_2_in_synced_group) secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_failed_repositories).to eq 1 expect(subject.count_failed_repositories).to eq 1
end end
...@@ -120,27 +115,29 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -120,27 +115,29 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
describe '#count_failed_wikis' do describe '#count_failed_wikis' do
it 'counts projects that sync has failed' do before do
create(:geo_project_registry, :synced) create(:geo_project_registry, :synced, project: project)
create(:geo_project_registry, :sync_failed, project: project_synced) create(:geo_project_registry, :wiki_sync_failed, project: project_1_in_synced_group)
create(:geo_project_registry, :repository_sync_failed, project: project_repository_dirty) create(:geo_project_registry, :repository_sync_failed, project: project_2_in_synced_group)
create(:geo_project_registry, :wiki_sync_failed, project: project_wiki_dirty) create(:geo_project_registry, :sync_failed, project: project_3_in_synced_group)
create(:geo_project_registry, :wiki_sync_failed, project: project_4_broken_storage)
end
expect(subject.count_failed_wikis).to eq 2 it 'counts registries that wiki sync has failed' do
expect(subject.count_failed_wikis).to eq 3
end end
context 'with selective sync' do context 'with selective sync by namespace' do
before do it 'counts registries that wiki sync has failed where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'counts projects that sync has failed' do expect(subject.count_failed_wikis).to eq 2
project_1_in_synced_group = create(:project, group: synced_group) end
project_2_in_synced_group = create(:project, group: synced_group) end
create(:geo_project_registry, :sync_failed, project: project_synced) context 'with selective sync by shard' do
create(:geo_project_registry, :wiki_sync_failed, project: project_1_in_synced_group) it 'counts registries that wiki sync has failed where projects belongs to the shards' do
create(:geo_project_registry, :synced, project: project_2_in_synced_group) secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_failed_wikis).to eq 1 expect(subject.count_failed_wikis).to eq 1
end end
...@@ -148,67 +145,147 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -148,67 +145,147 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
describe '#count_verified_repositories' do describe '#count_verified_repositories' do
it 'counts projects that verified' do before do
create(:geo_project_registry, :repository_verified, project: project_repository_verified) create(:geo_project_registry, :repository_verified, :wiki_verified, project: project)
create(:geo_project_registry, :repository_verified, project: build(:project)) create(:geo_project_registry, :repository_verified, project: project_1_in_synced_group)
create(:geo_project_registry, :repository_verification_failed, project: project_repository_verification_failed) create(:geo_project_registry, :repository_verification_failed, project: project_3_in_synced_group)
create(:geo_project_registry, :repository_verified, project: project_4_broken_storage)
create(:geo_project_registry, :wiki_verified, project: project_2_in_synced_group)
end
expect(subject.count_verified_repositories).to eq 2 it 'counts registries that repository have beend verified' do
expect(subject.count_verified_repositories).to eq 3
end
context 'with selective sync by namespace' do
it 'counts registries that repository have beend verified where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_verified_repositories).to eq 1
end
end
context 'with selective sync by shard' do
it 'counts registries that repository have beend verified where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_verified_repositories).to eq 1
end
end end
end end
describe '#count_verified_wikis' do describe '#count_verified_wikis' do
it 'counts wikis that verified' do before do
create(:geo_project_registry, :wiki_verified, project: project_wiki_verified) create(:geo_project_registry, :wiki_verified, :wiki_verified, project: project)
create(:geo_project_registry, :wiki_verified, project: build(:project)) create(:geo_project_registry, :wiki_verified, project: project_1_in_synced_group)
create(:geo_project_registry, :wiki_verification_failed, project: project_wiki_verification_failed) create(:geo_project_registry, :wiki_verification_failed, project: project_3_in_synced_group)
create(:geo_project_registry, :wiki_verified, project: project_4_broken_storage)
create(:geo_project_registry, :repository_verified, project: project_2_in_synced_group)
end
expect(subject.count_verified_wikis).to eq 2 it 'counts registries that wiki have beend verified' do
expect(subject.count_verified_wikis).to eq 3
end
context 'with selective sync by namespace' do
it 'counts registries that wiki have beend verified where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_verified_wikis).to eq 1
end
end
context 'with selective sync by shard' do
it 'counts registries that wiki have beend verified where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_verified_wikis).to eq 1
end
end end
end end
describe '#count_verification_failed_repositories' do describe '#count_verification_failed_repositories' do
it 'counts projects that verification has failed' do before do
create(:geo_project_registry, :repository_verified, project: project_repository_verified) create(:geo_project_registry, :repository_verification_failed, :wiki_verification_failed, project: project)
create(:geo_project_registry, :repository_verification_failed, project: project_repository_verification_failed) create(:geo_project_registry, :repository_verification_failed, project: project_1_in_synced_group)
create(:geo_project_registry, :wiki_verified, project: project_wiki_verified) create(:geo_project_registry, :repository_verification_failed, project: project_4_broken_storage)
create(:geo_project_registry, :wiki_verification_failed, project: project_wiki_verification_failed) 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 expect(subject.count_verification_failed_repositories).to eq 1
end end
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
end
end
end
describe '#count_verification_failed_wikis' do describe '#count_verification_failed_wikis' do
it 'counts projects that verification has failed' do before do
create(:geo_project_registry, :repository_verified, project: project_repository_verified) create(:geo_project_registry, :repository_verification_failed, :wiki_verification_failed, project: project)
create(:geo_project_registry, :repository_verification_failed, project: project_repository_verification_failed) create(:geo_project_registry, :wiki_verification_failed, project: project_1_in_synced_group)
create(:geo_project_registry, :wiki_verified, project: project_wiki_verified) create(:geo_project_registry, :wiki_verification_failed, project: project_4_broken_storage)
create(:geo_project_registry, :wiki_verification_failed, project: project_wiki_verification_failed) 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
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 describe '#count_repositories_retrying_verification' do
before do before do
project_1_in_synced_group = create(:project, group: synced_group) create(:geo_project_registry, :repository_retrying_verification, :wiki_retrying_verification, project: project)
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, project: project_1_in_synced_group) 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) create(:geo_project_registry, :wiki_retrying_verification, project: project_2_in_synced_group)
end end
it 'counts registries that repository retrying verification' do 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 end
context 'with selective sync' do context 'with selective sync by namespace' do
before do it 'counts registries that repository retrying verification where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_repositories_retrying_verification).to eq 1
end
end end
it 'counts registries that repository retrying verification' do 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'])
expect(subject.count_repositories_retrying_verification).to eq 1 expect(subject.count_repositories_retrying_verification).to eq 1
end end
end end
...@@ -216,70 +293,86 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -216,70 +293,86 @@ describe Geo::ProjectRegistryFinder, :geo do
describe '#count_wikis_retrying_verification' do describe '#count_wikis_retrying_verification' do
before do before do
project_1_in_synced_group = create(:project, group: synced_group) create(:geo_project_registry, :repository_retrying_verification, :wiki_retrying_verification, project: project)
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, project: project_1_in_synced_group) 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_2_in_synced_group)
create(:geo_project_registry, :wiki_retrying_verification, project: project_4_broken_storage)
end end
it 'counts registries that wiki retrying verification' do 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 end
context 'with selective sync' do context 'with selective sync by namespace' do
before do it 'counts registries that wiki retrying verification where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_wikis_retrying_verification).to eq 1
end
end end
it 'counts registries that wiki retrying verification' do 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'])
expect(subject.count_wikis_retrying_verification).to eq 1 expect(subject.count_wikis_retrying_verification).to eq 1
end end
end end
end end
describe '#count_repositories_checksum_mismatch' do describe '#count_repositories_checksum_mismatch' do
let(:project_1_in_synced_group) { create(:project, group: synced_group) } before do
let(:project_2_in_synced_group) { create(:project, group: synced_group) } 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)
let!(:registry_mismatch) { create(:geo_project_registry, :repository_checksum_mismatch, :wiki_checksum_mismatch, project: project_synced) } create(:geo_project_registry, :repository_checksum_mismatch, :wiki_verified, project: project_4_broken_storage)
let!(:repository_mismatch) { 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)
let!(:wiki_mismatch) { create(:geo_project_registry, :wiki_checksum_mismatch, project: project_2_in_synced_group) } end
it 'counts registries that repository mismatch' do 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 end
context 'with selective sync' do context 'with selective sync by namespace' do
before do it 'counts mismatch registries where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_repositories_checksum_mismatch).to eq 1
end 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 expect(subject.count_repositories_checksum_mismatch).to eq 1
end end
end end
end end
describe '#count_wikis_checksum_mismatch' do describe '#count_wikis_checksum_mismatch' do
let(:project_1_in_synced_group) { create(:project, group: synced_group) } before do
let(:project_2_in_synced_group) { create(:project, group: synced_group) } 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)
let!(:registry_mismatch) { create(:geo_project_registry, :repository_checksum_mismatch, :wiki_checksum_mismatch, project: project_synced) } create(:geo_project_registry, :wiki_checksum_mismatch, project: project_2_in_synced_group)
let!(:repository_mismatch) { create(:geo_project_registry, :repository_checksum_mismatch, project: project_1_in_synced_group) } create(:geo_project_registry, :repository_verified, :wiki_checksum_mismatch, project: project_4_broken_storage)
let!(:wiki_mismatch) { create(:geo_project_registry, :wiki_checksum_mismatch, project: project_2_in_synced_group) } end
it 'counts projects that verification has failed' do it 'counts registries that wiki mismatch' do
expect(subject.count_wikis_checksum_mismatch).to eq 2 expect(subject.count_wikis_checksum_mismatch).to eq 3
end end
context 'with selective sync' do context 'with selective sync by namespace' do
before do it 'counts mismatch registries where projects belongs to the namespaces' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
expect(subject.count_wikis_checksum_mismatch).to eq 1
end
end end
it 'counts projects that sync has failed' do 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'])
expect(subject.count_wikis_checksum_mismatch).to eq 1 expect(subject.count_wikis_checksum_mismatch).to eq 1
end end
end end
...@@ -295,7 +388,8 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -295,7 +388,8 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
it 'returns projects without an entry on the tracking database' do 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) projects = subject.find_unsynced_projects(batch_size: 10)
...@@ -314,9 +408,6 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -314,9 +408,6 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
it 'returns untracked projects in the synced group' do 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) create(:geo_project_registry, :sync_failed, project: project_1_in_synced_group)
projects = subject.find_unsynced_projects(batch_size: 10) projects = subject.find_unsynced_projects(batch_size: 10)
...@@ -334,12 +425,12 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -334,12 +425,12 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
it 'returns projects with a dirty entry on the tracking database' do 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, :repository_dirty, project: project_1_in_synced_group)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_wiki_dirty) create(:geo_project_registry, :synced, :wiki_dirty, project: project_2_in_synced_group)
projects = subject.find_projects_updated_recently(batch_size: 10) 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 end
context 'with selective sync' do context 'with selective sync' do
...@@ -354,11 +445,7 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -354,11 +445,7 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
it 'returns dirty projects in the synced group' do 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(:project, group: synced_group)
create(:geo_project_registry, :synced, :repository_dirty, project: project_1_in_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, :wiki_dirty, project: project_2_in_synced_group)
create(:geo_project_registry, :synced, project: project_3_in_synced_group) create(:geo_project_registry, :synced, project: project_3_in_synced_group)
...@@ -369,87 +456,33 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -369,87 +456,33 @@ describe Geo::ProjectRegistryFinder, :geo do
end end
end end
end end
describe '#find_failed_project_registries' do
let(:project_1_in_synced_group) { create(:project, group: synced_group) }
let(:project_2_in_synced_group) { create(:project, group: synced_group) }
let!(:synced) { create(:geo_project_registry, :synced) }
let!(:sync_failed) { create(:geo_project_registry, :sync_failed, project: project_synced) }
let!(:repository_sync_failed) { create(:geo_project_registry, :repository_sync_failed, project: project_1_in_synced_group) }
let!(:wiki_sync_failed) { create(:geo_project_registry, :wiki_sync_failed, project: project_2_in_synced_group) }
it 'returns only project registries that repository sync has failed' do
expect(subject.find_failed_project_registries('repository')).to match_array([sync_failed, repository_sync_failed])
end end
it 'returns only project registries that wiki sync has failed' do shared_examples 'delegates to the proper finder' do |legacy_finder_klass, finder_klass, method, args|
expect(subject.find_failed_project_registries('wiki')).to match_array([sync_failed, wiki_sync_failed]) 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 end
context 'with selective sync' do with_them do
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
it 'returns project registries that sync has failed' do
expect(subject.find_failed_project_registries).to match_array([repository_sync_failed, wiki_sync_failed])
end
it 'returns only project registries that repository sync has failed' do
create(:geo_project_registry, :repository_sync_failed)
expect(subject.find_failed_project_registries('repository')).to match_array([repository_sync_failed])
end
it 'returns only project registries that wiki sync has failed' do
create(:geo_project_registry, :wiki_sync_failed)
expect(subject.find_failed_project_registries('wiki')).to match_array([wiki_sync_failed])
end
end
end
describe '#find_checksum_mismatch_project_registries' 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) }
it 'returns only project registries that repository mismatch when type is set to repository' do
expect(subject.find_checksum_mismatch_project_registries('repository')).to contain_exactly(registry_mismatch, repository_mismatch)
end
it 'returns only project registries that repository mismatch when type is set to repository' do
expect(subject.find_checksum_mismatch_project_registries('wiki')).to contain_exactly(registry_mismatch, wiki_mismatch)
end
it 'returns project registries that repository or wiki mismatch' do
expect(subject.find_checksum_mismatch_project_registries).to contain_exactly(registry_mismatch, repository_mismatch, wiki_mismatch)
end
context 'with selective sync' do
before do before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group]) stub_fdw(fdw_enabled)
end stub_feature_flags(use_fdw_queries_for_selective_sync: fdw_for_selective_sync)
stub_selective_sync(secondary, selective_sync)
it 'returns only project registries that repository mismatch when type is set to repository' do
create(:geo_project_registry, :repository_checksum_mismatch)
expect(subject.find_checksum_mismatch_project_registries('repository')).to contain_exactly(repository_mismatch)
end end
it 'returns only project registries that repository mismatch when type is set to repository' do it 'delegates to the proper finder' do
create(:geo_project_registry, :wiki_checksum_mismatch) expect_next_instance_of(finder) do |finder|
expect(finder).to receive(:execute).once
expect(subject.find_checksum_mismatch_project_registries('wiki')).to contain_exactly(wiki_mismatch)
end end
it 'returns project registries that repository or wiki mismatch' do subject.public_send(method, *args)
expect(subject.find_checksum_mismatch_project_registries).to contain_exactly(repository_mismatch, wiki_mismatch)
end
end end
end end
end end
...@@ -489,32 +522,31 @@ describe Geo::ProjectRegistryFinder, :geo do ...@@ -489,32 +522,31 @@ describe Geo::ProjectRegistryFinder, :geo do
include_examples 'finds all the things', 'legacy' include_examples 'finds all the things', 'legacy'
end end
describe '#find_registries_to_verify', :delete do describe '#find_failed_project_registries', :delete do
where(:selective_sync, :fdw_enabled, :use_fdw_queries_for_selective_sync, :finder) do include_examples 'delegates to the proper finder',
false | false | false | Geo::LegacyProjectRegistryPendingVerificationFinder Geo::LegacyProjectRegistrySyncFailedFinder,
false | false | true | Geo::LegacyProjectRegistryPendingVerificationFinder Geo::ProjectRegistrySyncFailedFinder,
false | true | true | Geo::ProjectRegistryPendingVerificationFinder :find_failed_project_registries, ['repository']
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 end
with_them do describe '#find_registries_to_verify', :delete do
before do include_examples 'delegates to the proper finder',
stub_fdw(fdw_enabled) Geo::LegacyProjectRegistryPendingVerificationFinder,
stub_feature_flags(use_fdw_queries_for_selective_sync: use_fdw_queries_for_selective_sync) Geo::ProjectRegistryPendingVerificationFinder,
stub_selective_sync(secondary, selective_sync) :find_registries_to_verify, [shard_name: 'default', batch_size: 100]
end end
it 'delegates to Geo::ProjectRegistryPendingVerificationFinder' do describe '#find_verification_failed_project_registries', :delete do
expect_next_instance_of(finder, current_node: secondary, shard_name: 'default', batch_size: 100) do |finder| include_examples 'delegates to the proper finder',
expect(finder).to receive(:execute).once Geo::LegacyProjectRegistryVerificationFailedFinder,
Geo::ProjectRegistryVerificationFailedFinder,
:find_verification_failed_project_registries, ['repository']
end end
subject.find_registries_to_verify(shard_name: 'default', batch_size: 100) describe '#find_checksum_mismatch_project_registries', :delete do
end include_examples 'delegates to the proper finder',
end Geo::LegacyProjectRegistryMismatchFinder,
Geo::ProjectRegistryMismatchFinder,
:find_checksum_mismatch_project_registries, ['repository']
end end
end end
...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do ...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns mismatch registries where projects belongs to the namespaces' do it 'returns mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch) expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch)
end end
...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do ...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns mismatch registries where projects belongs to the namespaces' do it 'returns mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_mismatch, registry_wiki_mismatch) expect(subject.execute).to contain_exactly(registry_mismatch, registry_wiki_mismatch)
end end
...@@ -89,7 +89,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do ...@@ -89,7 +89,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns all mismatch registries where projects belongs to the namespaces' do it 'returns all mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_wiki_mismatch) expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_wiki_mismatch)
end end
......
...@@ -149,7 +149,7 @@ describe Geo::ProjectRegistryPendingVerificationFinder, :geo do ...@@ -149,7 +149,7 @@ describe Geo::ProjectRegistryPendingVerificationFinder, :geo do
registry_outdated_secondary = create(:geo_project_registry, :synced, :repository_verification_outdated, :wiki_verification_outdated, project: project_2) registry_outdated_secondary = create(:geo_project_registry, :synced, :repository_verification_outdated, :wiki_verification_outdated, project: project_2)
create(:geo_project_registry, :synced, :repository_verification_outdated, :wiki_verified, project: project_3) create(:geo_project_registry, :synced, :repository_verification_outdated, :wiki_verified, project: project_3)
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute) expect(subject.execute)
.to contain_exactly( .to contain_exactly(
......
...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryRetryingVerificationFinder, :geo do ...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryRetryingVerificationFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns registries retrying verification where projects belongs to the namespaces' do it 'returns registries retrying verification where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(retrying_verification, repository_retrying_verification) expect(subject.execute).to contain_exactly(retrying_verification, repository_retrying_verification)
end end
...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryRetryingVerificationFinder, :geo do ...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryRetryingVerificationFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns registries retrying verification where projects belongs to the namespaces' do it 'returns registries retrying verification where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(retrying_verification, wiki_retrying_verification) expect(subject.execute).to contain_exactly(retrying_verification, wiki_retrying_verification)
end end
......
...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do ...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_failed, registry_repository_failed]) expect(subject.execute).to match_array([registry_failed, registry_repository_failed])
end end
...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do ...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_failed, registry_wiki_failed]) expect(subject.execute).to match_array([registry_failed, registry_wiki_failed])
end end
...@@ -89,7 +89,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do ...@@ -89,7 +89,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns all failed registries where projects belongs to the namespaces' do it 'returns all failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_wiki_failed]) expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_wiki_failed])
end end
......
...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistrySyncedFinder, :geo do ...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistrySyncedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns synced registries where projects belongs to the namespaces' do it 'returns synced registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_synced, registry_wiki_dirty]) expect(subject.execute).to match_array([registry_synced, registry_wiki_dirty])
end end
...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistrySyncedFinder, :geo do ...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistrySyncedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns synced registries where projects belongs to the namespaces' do it 'returns synced registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_synced, registry_repository_dirty]) expect(subject.execute).to match_array([registry_synced, registry_repository_dirty])
end end
......
...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do ...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed) expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed)
end end
...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do ...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_wiki_verification_failed) expect(subject.execute).to contain_exactly(registry_verification_failed, registry_wiki_verification_failed)
end end
...@@ -89,7 +89,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do ...@@ -89,7 +89,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns all failed registries where projects belongs to the namespaces' do it 'returns all failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_wiki_verification_failed) expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_wiki_verification_failed)
end end
......
...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryVerifiedFinder, :geo do ...@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryVerifiedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns verified registries where projects belongs to the namespaces' do it 'returns verified registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verified, registry_wiki_verification_failed) expect(subject.execute).to contain_exactly(registry_verified, registry_wiki_verification_failed)
end end
...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryVerifiedFinder, :geo do ...@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryVerifiedFinder, :geo do
context 'with selective sync by namespace' do context 'with selective sync by namespace' do
it 'returns verified registries where projects belongs to the namespaces' do it 'returns verified registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1]) node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_verified, registry_repository_verification_failed) expect(subject.execute).to contain_exactly(registry_verified, registry_repository_verification_failed)
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