Refactor legacy finder to find registries verification failed

These changes use the new finder when FDW is enabled without selective
sync to avoid code duplication.
parent 1720e039
...@@ -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
...@@ -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) }
...@@ -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
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