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
end
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(
mismatch_registries,
current_node.projects.pluck(:id),
Geo::ProjectRegistry.mismatch(type),
current_node.projects.pluck_primary_key,
Geo::ProjectRegistry,
foreign_key: :project_id
)
end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end
end
......@@ -22,30 +22,16 @@ module Geo
end
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(
registries_retrying_verification,
current_node.projects.pluck(:id),
Geo::ProjectRegistry.retrying_verification(type),
current_node.projects.pluck_primary_key,
Geo::ProjectRegistry,
foreign_key: :project_id
)
end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end
end
......@@ -2,7 +2,7 @@
# Finder for retrieving project registries that synchronization have
# failed scoped to a type (repository or wiki) using cross-database
# joins for selective sync.
# joins.
#
# Basic usage:
#
......@@ -22,30 +22,16 @@ module Geo
end
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(
failed_registries,
current_node.projects.pluck(:id),
Geo::ProjectRegistry.sync_failed(type),
current_node.projects.pluck_primary_key,
Geo::ProjectRegistry,
foreign_key: :project_id
)
end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end
end
# frozen_string_literal: true
# Finder for retrieving project registries that have been synced
# scoped to a type (repository or wiki) using cross-database joins
# for selective sync.
# scoped to a type (repository or wiki) using cross-database joins.
#
# Basic usage:
#
......@@ -22,30 +21,16 @@ module Geo
end
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(
synced_registries,
current_node.projects.pluck(:id),
Geo::ProjectRegistry.synced(type),
current_node.projects.pluck_primary_key,
Geo::ProjectRegistry,
foreign_key: :project_id
)
end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end
end
......@@ -22,30 +22,16 @@ module Geo
end
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(
failed_registries,
current_node.projects.pluck(:id),
Geo::ProjectRegistry.verification_failed(type),
current_node.projects.pluck_primary_key,
Geo::ProjectRegistry,
foreign_key: :project_id
)
end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end
end
# frozen_string_literal: true
# Finder for retrieving project registries that have been verified
# scoped to a type (repository or wiki) using cross-database joins
# for selective sync.
# scoped to a type (repository or wiki) using cross-database joins.
#
# Basic usage:
#
......@@ -22,30 +21,16 @@ module Geo
end
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(
verified_registries,
current_node.projects.pluck(:id),
Geo::ProjectRegistry.verified(type),
current_node.projects.pluck_primary_key,
Geo::ProjectRegistry,
foreign_key: :project_id
)
end
# rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :type
end
end
......@@ -163,15 +163,19 @@ 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_for_selective_sync?
Geo::ProjectRegistrySyncedFinder
else
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistrySyncedFinder
else
Geo::ProjectRegistrySyncedFinder
end
end
......@@ -182,10 +186,10 @@ module Geo
end
def finder_klass_for_failed_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync?
Geo::ProjectRegistrySyncFailedFinder
else
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistrySyncFailedFinder
else
Geo::ProjectRegistrySyncFailedFinder
end
end
......@@ -196,10 +200,10 @@ module Geo
end
def finder_klass_for_verified_registries
if Gitlab::Geo::Fdw.enabled_for_selective_sync?
Geo::ProjectRegistryVerifiedFinder
else
if use_legacy_queries_for_selective_sync?
Geo::LegacyProjectRegistryVerifiedFinder
else
Geo::ProjectRegistryVerifiedFinder
end
end
......@@ -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
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectRegistryMismatchFinder, :geo do
include EE::GeoHelpers
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
......@@ -22,102 +20,82 @@ 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_verified) { create(:geo_project_registry, :repository_verified, :wiki_verified) }
shared_examples 'finds mismatch registries' do
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'without selective sync' do
it 'returns all mismatch registries' do
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_repository_mismatch_broken_shard)
end
end
context 'with selective sync by namespace' do
it 'returns mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch)
end
context 'without selective sync' do
it 'returns all mismatch registries' do
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_repository_mismatch_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns mismatch registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_repository_mismatch_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch)
end
end
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
context 'with selective sync by shard' do
it 'returns mismatch registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all mismatch registries' do
expect(subject.execute).to contain_exactly(registry_mismatch, registry_wiki_mismatch, registry_wiki_mismatch_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_repository_mismatch_broken_shard)
end
end
end
context 'with selective sync by namespace' do
it 'returns mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
expect(subject.execute).to contain_exactly(registry_mismatch, registry_wiki_mismatch)
end
context 'without selective sync' do
it 'returns all mismatch registries' do
expect(subject.execute).to contain_exactly(registry_mismatch, registry_wiki_mismatch, registry_wiki_mismatch_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns mismatch registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_wiki_mismatch_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_mismatch, registry_wiki_mismatch)
end
end
context 'with invalid type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'with selective sync by shard' do
it 'returns mismatch registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all mismatch registries' do
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_wiki_mismatch, registry_repository_mismatch_broken_shard, registry_wiki_mismatch_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_wiki_mismatch_broken_shard)
end
end
end
context 'with selective sync by namespace' 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])
context 'with invalid type' do
subject { described_class.new(current_node: node, type: :invalid) }
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_wiki_mismatch)
end
context 'without selective sync' do
it 'returns all mismatch registries' do
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_wiki_mismatch, registry_repository_mismatch_broken_shard, registry_wiki_mismatch_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns all mismatch registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns all mismatch registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_repository_mismatch_broken_shard, registry_wiki_mismatch_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_mismatch, registry_repository_mismatch, registry_wiki_mismatch)
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 'with selective sync by shard' do
it 'returns all mismatch registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'Legacy' do
before do
stub_fdw_disabled
expect(subject.execute).to contain_exactly(registry_repository_mismatch_broken_shard, registry_wiki_mismatch_broken_shard)
end
end
include_examples 'finds mismatch registries'
end
end
end
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectRegistryPendingVerificationFinder, :geo do
include EE::GeoHelpers
describe '#execute' do
let(:node) { create(:geo_node) }
......@@ -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)
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)
.to contain_exactly(
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do
include EE::GeoHelpers
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
......@@ -22,98 +20,78 @@ describe Geo::LegacyProjectRegistryRetryingVerificationFinder, :geo do
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) }
shared_examples 'finds registries retrying verification' do
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'without selective sync' do
it 'returns all registries retrying verification' do
expect(subject.execute).to contain_exactly(retrying_verification, repository_retrying_verification, repository_retrying_verification_broken_shard)
end
end
context 'with selective sync by namespace' 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])
expect(subject.execute).to contain_exactly(retrying_verification, repository_retrying_verification)
end
context 'without selective sync' do
it 'returns all registries retrying verification' do
expect(subject.execute).to contain_exactly(retrying_verification, repository_retrying_verification, repository_retrying_verification_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns registries retrying verification where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns registries retrying verification where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(repository_retrying_verification_broken_shard)
end
expect(subject.execute).to contain_exactly(retrying_verification, repository_retrying_verification)
end
end
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
context 'with selective sync by shard' do
it 'returns registries retrying verification where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all registries retrying verification' do
expect(subject.execute).to contain_exactly(retrying_verification, wiki_retrying_verification, wiki_retrying_verification_broken_shard)
end
expect(subject.execute).to contain_exactly(repository_retrying_verification_broken_shard)
end
end
end
context 'with selective sync by namespace' 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])
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
expect(subject.execute).to contain_exactly(retrying_verification, wiki_retrying_verification)
end
context 'without selective sync' do
it 'returns all registries retrying verification' do
expect(subject.execute).to contain_exactly(retrying_verification, wiki_retrying_verification, wiki_retrying_verification_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns registries retrying verification where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns registries retrying verification where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(wiki_retrying_verification_broken_shard)
end
expect(subject.execute).to contain_exactly(retrying_verification, wiki_retrying_verification)
end
end
context 'with invalid type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'with selective sync by shard' do
it 'returns registries retrying verification where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns nothing' do
expect(subject.execute).to be_empty
end
expect(subject.execute).to contain_exactly(wiki_retrying_verification_broken_shard)
end
end
end
context 'with selective sync by namespace' do
it 'returns nothing' do
expect(subject.execute).to be_empty
end
end
context 'with invalid type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'with selective sync by shard' do
it 'returns nothing' do
expect(subject.execute).to be_empty
end
context 'without selective sync' do
it 'returns nothing' do
expect(subject.execute).to be_empty
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?
context 'with selective sync by namespace' do
it 'returns nothing' do
expect(subject.execute).to be_empty
end
end
include_examples 'finds registries retrying verification'
end
context 'Legacy' do
before do
stub_fdw_disabled
context 'with selective sync by shard' do
it 'returns nothing' do
expect(subject.execute).to be_empty
end
end
include_examples 'finds registries retrying verification'
end
end
end
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do
include EE::GeoHelpers
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
......@@ -22,102 +20,82 @@ describe Geo::LegacyProjectRegistrySyncFailedFinder, :geo do
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) }
shared_examples 'finds failed registries' do
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_repository_failed_broken_shard])
end
end
context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
expect(subject.execute).to match_array([registry_failed, registry_repository_failed])
end
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_repository_failed_broken_shard])
end
end
context 'with selective sync by shard' do
it 'returns failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_repository_failed_broken_shard])
end
expect(subject.execute).to match_array([registry_failed, registry_repository_failed])
end
end
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
context 'with selective sync by shard' do
it 'returns failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to match_array([registry_failed, registry_wiki_failed, registry_wiki_failed_broken_shard])
end
expect(subject.execute).to match_array([registry_repository_failed_broken_shard])
end
end
end
context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
expect(subject.execute).to match_array([registry_failed, registry_wiki_failed])
end
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to match_array([registry_failed, registry_wiki_failed, registry_wiki_failed_broken_shard])
end
end
context 'with selective sync by shard' do
it 'returns failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_wiki_failed_broken_shard])
end
expect(subject.execute).to match_array([registry_failed, registry_wiki_failed])
end
end
context 'with no type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'with selective sync by shard' do
it 'returns failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_wiki_failed, registry_repository_failed_broken_shard, registry_wiki_failed_broken_shard])
end
expect(subject.execute).to match_array([registry_wiki_failed_broken_shard])
end
end
end
context 'with selective sync by namespace' 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])
context 'with no type' do
subject { described_class.new(current_node: node, type: :invalid) }
expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_wiki_failed])
end
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_wiki_failed, registry_repository_failed_broken_shard, registry_wiki_failed_broken_shard])
end
end
context 'with selective sync by shard' do
it 'returns all failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns all failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_repository_failed_broken_shard, registry_wiki_failed_broken_shard])
end
expect(subject.execute).to match_array([registry_failed, registry_repository_failed, registry_wiki_failed])
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 'with selective sync by shard' do
it 'returns all failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'Legacy' do
before do
stub_fdw_disabled
expect(subject.execute).to match_array([registry_repository_failed_broken_shard, registry_wiki_failed_broken_shard])
end
end
include_examples 'finds failed registries'
end
end
end
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectRegistrySyncedFinder, :geo do
include EE::GeoHelpers
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
......@@ -22,84 +20,64 @@ describe Geo::LegacyProjectRegistrySyncedFinder, :geo do
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) }
shared_examples 'finds synced registries' do
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'without selective sync' do
it 'returns all synced registries' do
expect(subject.execute).to match_array([registry_synced, registry_wiki_dirty, registry_wiki_dirty_broken_shard])
end
end
context 'with selective sync by namespace' do
it 'returns synced registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
expect(subject.execute).to match_array([registry_synced, registry_wiki_dirty])
end
context 'without selective sync' do
it 'returns all synced registries' do
expect(subject.execute).to match_array([registry_synced, registry_wiki_dirty, registry_wiki_dirty_broken_shard])
end
end
context 'with selective sync by shard' do
it 'returns synced registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns synced registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_wiki_dirty_broken_shard])
end
expect(subject.execute).to match_array([registry_synced, registry_wiki_dirty])
end
end
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
context 'with selective sync by shard' do
it 'returns synced registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all synced registries' do
expect(subject.execute).to match_array([registry_synced, registry_repository_dirty, registry_repository_dirty_broken_shard])
end
expect(subject.execute).to match_array([registry_wiki_dirty_broken_shard])
end
end
end
context 'with selective sync by namespace' do
it 'returns synced registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
expect(subject.execute).to match_array([registry_synced, registry_repository_dirty])
end
context 'without selective sync' do
it 'returns all synced registries' do
expect(subject.execute).to match_array([registry_synced, registry_repository_dirty, registry_repository_dirty_broken_shard])
end
end
context 'with selective sync by shard' do
it 'returns synced registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns synced registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to match_array([registry_repository_dirty_broken_shard])
end
expect(subject.execute).to match_array([registry_synced, registry_repository_dirty])
end
end
context 'with invalid type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'with selective sync by shard' do
it 'returns synced registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
it 'returns nothing' do
expect(subject.execute).to be_empty
expect(subject.execute).to match_array([registry_repository_dirty_broken_shard])
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 'with invalid type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'Legacy' do
before do
stub_fdw_disabled
it 'returns nothing' do
expect(subject.execute).to be_empty
end
include_examples 'finds synced registries'
end
end
end
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectRegistryVerificationFailedFinder, :geo do
include EE::GeoHelpers
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
......@@ -22,102 +20,82 @@ 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_verified) { create(:geo_project_registry, :repository_verified, :wiki_verified) }
shared_examples 'finds registries that verification failed' do
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_repository_verification_failed_broken_shard)
end
end
context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed)
end
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_repository_verification_failed_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_repository_verification_failed_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed)
end
end
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
context 'with selective sync by shard' do
it 'returns failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_wiki_verification_failed, registry_wiki_verification_failed_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_repository_verification_failed_broken_shard)
end
end
end
context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_wiki_verification_failed)
end
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_wiki_verification_failed, registry_wiki_verification_failed_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_wiki_verification_failed_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_wiki_verification_failed)
end
end
context 'with no type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'with selective sync by shard' do
it 'returns failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_wiki_verification_failed, registry_repository_verification_failed_broken_shard, registry_wiki_verification_failed_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_wiki_verification_failed_broken_shard)
end
end
end
context 'with selective sync by namespace' 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])
context 'with no type' do
subject { described_class.new(current_node: node, type: :invalid) }
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_wiki_verification_failed)
end
context 'without selective sync' do
it 'returns all failed registries' do
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_wiki_verification_failed, registry_repository_verification_failed_broken_shard, registry_wiki_verification_failed_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns all failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns all failed registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_repository_verification_failed_broken_shard, registry_wiki_verification_failed_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_verification_failed, registry_repository_verification_failed, registry_wiki_verification_failed)
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 'with selective sync by shard' do
it 'returns all failed registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'Legacy' do
before do
stub_fdw_disabled
expect(subject.execute).to contain_exactly(registry_repository_verification_failed_broken_shard, registry_wiki_verification_failed_broken_shard)
end
end
include_examples 'finds registries that verification failed'
end
end
end
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectRegistryVerifiedFinder, :geo do
include EE::GeoHelpers
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
......@@ -22,84 +20,64 @@ 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_verification_failed) { create(:geo_project_registry, :repository_verification_failed, :wiki_verification_failed) }
shared_examples 'finds verified registries' do
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
context 'without selective sync' do
it 'returns all verified registries' do
expect(subject.execute).to contain_exactly(registry_verified, registry_wiki_verification_failed, registry_wiki_verification_failed_broken_shard)
end
end
context 'with selective sync by namespace' do
it 'returns verified registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
expect(subject.execute).to contain_exactly(registry_verified, registry_wiki_verification_failed)
end
context 'without selective sync' do
it 'returns all verified registries' do
expect(subject.execute).to contain_exactly(registry_verified, registry_wiki_verification_failed, registry_wiki_verification_failed_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns verified registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns verified registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_wiki_verification_failed_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_verified, registry_wiki_verification_failed)
end
end
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
context 'with selective sync by shard' do
it 'returns verified registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'without selective sync' do
it 'returns all verified registries' do
expect(subject.execute).to contain_exactly(registry_verified, registry_repository_verification_failed, registry_repository_verification_failed_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_wiki_verification_failed_broken_shard)
end
end
end
context 'with selective sync by namespace' do
it 'returns verified registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1, nested_group_1])
context 'with wiki type' do
subject { described_class.new(current_node: node, type: :wiki) }
expect(subject.execute).to contain_exactly(registry_verified, registry_repository_verification_failed)
end
context 'without selective sync' do
it 'returns all verified registries' do
expect(subject.execute).to contain_exactly(registry_verified, registry_repository_verification_failed, registry_repository_verification_failed_broken_shard)
end
end
context 'with selective sync by shard' do
it 'returns verified registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
context 'with selective sync by namespace' do
it 'returns verified registries where projects belongs to the namespaces' do
node.update!(selective_sync_type: 'namespaces', namespaces: [group_1])
expect(subject.execute).to contain_exactly(registry_repository_verification_failed_broken_shard)
end
expect(subject.execute).to contain_exactly(registry_verified, registry_repository_verification_failed)
end
end
context 'with invalid type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'with selective sync by shard' do
it 'returns verified registries where projects belongs to the shards' do
node.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
it 'returns nothing' do
expect(subject.execute).to be_empty
expect(subject.execute).to contain_exactly(registry_repository_verification_failed_broken_shard)
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 'with invalid type' do
subject { described_class.new(current_node: node, type: :invalid) }
context 'Legacy' do
before do
stub_fdw_disabled
it 'returns nothing' do
expect(subject.execute).to be_empty
end
include_examples 'finds verified registries'
end
end
end
......@@ -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) }
......@@ -28,27 +25,29 @@ describe Geo::ProjectRegistryFinder, :geo do
shared_examples 'counts all the things' do |method_prefix|
describe '#count_synced_repositories' do
it 'counts repositories that have been synced' do
create(:geo_project_registry, :sync_failed)
create(:geo_project_registry, :synced, project: project_synced)
create(:geo_project_registry, :synced, :repository_dirty, project: project_repository_dirty)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_wiki_dirty)
before do
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)
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
context 'with selective sync' do
before do
context 'with selective sync by namespace' 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])
end
it 'counts projects that has been synced' do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
expect(subject.count_synced_repositories).to eq 1
end
end
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)
context 'with selective sync by shard' do
it 'counts registries that repository have been synced where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_synced_repositories).to eq 1
end
......@@ -56,35 +55,29 @@ describe Geo::ProjectRegistryFinder, :geo do
end
describe '#count_synced_wikis' do
it 'counts wiki that have been synced' do
create(:geo_project_registry, :sync_failed)
create(:geo_project_registry, :synced, project: project_synced)
create(:geo_project_registry, :synced, :repository_dirty, project: project_repository_dirty)
create(:geo_project_registry, :synced, :wiki_dirty, project: project_wiki_dirty)
expect(subject.count_synced_wikis).to eq 2
before do
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)
create(:geo_project_registry, :synced, :repository_dirty, project: project_4_broken_storage)
end
it 'counts synced wikis with nil wiki_access_level (which means enabled wiki)' do
project_synced.project_feature.update!(wiki_access_level: nil)
create(:geo_project_registry, :synced, project: project_synced)
expect(subject.count_synced_wikis).to eq 1
it 'counts registries that wiki have been synced' do
expect(subject.count_synced_wikis).to eq 3
end
context 'with selective sync' do
before do
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])
end
it 'counts projects that has been synced' do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
expect(subject.count_synced_wikis).to eq 1
end
end
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)
context 'with selective sync by shard' do
it 'counts registries that wiki have been synced where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_synced_wikis).to eq 1
end
......@@ -92,27 +85,29 @@ describe Geo::ProjectRegistryFinder, :geo do
end
describe '#count_failed_repositories' do
it 'counts projects that sync has failed' do
create(:geo_project_registry, :synced)
create(:geo_project_registry, :sync_failed, project: project_synced)
create(:geo_project_registry, :repository_sync_failed, project: project_repository_dirty)
create(:geo_project_registry, :wiki_sync_failed, project: project_wiki_dirty)
before do
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)
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
context 'with selective sync' do
before do
context 'with selective sync by namespace' 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])
end
it 'counts projects that sync has failed' do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
expect(subject.count_failed_repositories).to eq 2
end
end
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, :synced, project: project_2_in_synced_group)
context 'with selective sync by shard' do
it 'counts registries that repository sync has failed where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_failed_repositories).to eq 1
end
......@@ -120,27 +115,29 @@ describe Geo::ProjectRegistryFinder, :geo do
end
describe '#count_failed_wikis' do
it 'counts projects that sync has failed' do
create(:geo_project_registry, :synced)
create(:geo_project_registry, :sync_failed, project: project_synced)
create(:geo_project_registry, :repository_sync_failed, project: project_repository_dirty)
create(:geo_project_registry, :wiki_sync_failed, project: project_wiki_dirty)
before do
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)
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
context 'with selective sync' do
before do
context 'with selective sync by namespace' 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])
end
it 'counts projects that sync has failed' do
project_1_in_synced_group = create(:project, group: synced_group)
project_2_in_synced_group = create(:project, group: synced_group)
expect(subject.count_failed_wikis).to eq 2
end
end
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, :synced, project: project_2_in_synced_group)
context 'with selective sync by shard' do
it 'counts registries that wiki sync has failed where projects belongs to the shards' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
expect(subject.count_failed_wikis).to eq 1
end
......@@ -148,67 +145,147 @@ describe Geo::ProjectRegistryFinder, :geo do
end
describe '#count_verified_repositories' do
it 'counts projects that verified' do
create(:geo_project_registry, :repository_verified, project: project_repository_verified)
create(:geo_project_registry, :repository_verified, project: build(:project))
create(:geo_project_registry, :repository_verification_failed, project: project_repository_verification_failed)
before do
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)
create(:geo_project_registry, :wiki_verified, project: project_2_in_synced_group)
end
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 2
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
describe '#count_verified_wikis' do
it 'counts wikis that verified' do
create(:geo_project_registry, :wiki_verified, project: project_wiki_verified)
create(:geo_project_registry, :wiki_verified, project: build(:project))
create(:geo_project_registry, :wiki_verification_failed, project: project_wiki_verification_failed)
before do
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)
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
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
expect(subject.count_verification_failed_repositories).to eq 1
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
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
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
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
......@@ -216,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
......@@ -295,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)
......@@ -314,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)
......@@ -334,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
......@@ -354,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)
......@@ -369,87 +456,33 @@ describe Geo::ProjectRegistryFinder, :geo do
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
it 'returns only project registries that wiki sync has failed' do
expect(subject.find_failed_project_registries('wiki')).to match_array([sync_failed, wiki_sync_failed])
end
context 'with selective sync' 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
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
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)
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
context 'with selective sync' do
before do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [synced_group])
end
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
it 'returns only project registries that repository mismatch when type is set to repository' do
create(:geo_project_registry, :wiki_checksum_mismatch)
expect(subject.find_checksum_mismatch_project_registries('wiki')).to contain_exactly(wiki_mismatch)
it 'delegates to the proper finder' do
expect_next_instance_of(finder) do |finder|
expect(finder).to receive(:execute).once
end
it 'returns project registries that repository or wiki mismatch' do
expect(subject.find_checksum_mismatch_project_registries).to contain_exactly(repository_mismatch, wiki_mismatch)
end
subject.public_send(method, *args)
end
end
end
......@@ -489,32 +522,31 @@ describe Geo::ProjectRegistryFinder, :geo do
include_examples 'finds all the things', 'legacy'
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
describe '#find_failed_project_registries', :delete do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistrySyncFailedFinder,
Geo::ProjectRegistrySyncFailedFinder,
:find_failed_project_registries, ['repository']
end
with_them do
before do
stub_fdw(fdw_enabled)
stub_feature_flags(use_fdw_queries_for_selective_sync: use_fdw_queries_for_selective_sync)
stub_selective_sync(secondary, selective_sync)
end
describe '#find_registries_to_verify', :delete do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistryPendingVerificationFinder,
Geo::ProjectRegistryPendingVerificationFinder,
:find_registries_to_verify, [shard_name: 'default', batch_size: 100]
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
describe '#find_verification_failed_project_registries', :delete do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistryVerificationFailedFinder,
Geo::ProjectRegistryVerificationFailedFinder,
:find_verification_failed_project_registries, ['repository']
end
subject.find_registries_to_verify(shard_name: 'default', batch_size: 100)
end
end
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
......@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' 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)
end
......@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' 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)
end
......@@ -89,7 +89,7 @@ describe Geo::ProjectRegistryMismatchFinder, :geo do
context 'with selective sync by namespace' 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)
end
......
......@@ -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)
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)
.to contain_exactly(
......
......@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryRetryingVerificationFinder, :geo do
context 'with selective sync by namespace' 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)
end
......@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryRetryingVerificationFinder, :geo do
context 'with selective sync by namespace' 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)
end
......
......@@ -37,7 +37,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' 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])
end
......@@ -63,7 +63,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' 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])
end
......@@ -89,7 +89,7 @@ describe Geo::ProjectRegistrySyncFailedFinder, :geo do
context 'with selective sync by namespace' 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])
end
......
......@@ -37,7 +37,7 @@ describe Geo::ProjectRegistrySyncedFinder, :geo do
context 'with selective sync by namespace' 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])
end
......@@ -63,7 +63,7 @@ describe Geo::ProjectRegistrySyncedFinder, :geo do
context 'with selective sync by namespace' 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])
end
......
......@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' 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)
end
......@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' 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)
end
......@@ -89,7 +89,7 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :geo do
context 'with selective sync by namespace' 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)
end
......
......@@ -37,7 +37,7 @@ describe Geo::ProjectRegistryVerifiedFinder, :geo do
context 'with selective sync by namespace' 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)
end
......@@ -63,7 +63,7 @@ describe Geo::ProjectRegistryVerifiedFinder, :geo do
context 'with selective sync by namespace' 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)
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