Include the functionality of :delete in :geo_fdw tag

Disable transactions via :delete method because a foreign table
can't see changes inside a transaction of a different connection.
parent b53b58ef
......@@ -5,13 +5,7 @@ describe Geo::ExpireUploadsFinder, :geo do
let(:project) { create(:project) }
# 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') if Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
end
context 'FDW', :geo_fdw do
describe '#find_project_uploads' do
context 'filtering per project uploads' do
it 'returns only objects associated with the project' do
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectUnsyncedFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
describe Geo::LegacyProjectUpdatedRecentlyFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
......
......@@ -409,13 +409,7 @@ describe Geo::ProjectRegistryFinder, :geo do
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') if Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
end
context 'FDW', :geo_fdw do
context 'with use_fdw_queries_for_selective_sync disabled' do
before do
stub_feature_flags(use_fdw_queries_for_selective_sync: false)
......@@ -441,42 +435,42 @@ describe Geo::ProjectRegistryFinder, :geo do
include_examples 'counts all the things', 'legacy'
end
describe '#find_unsynced_projects', :delete do
describe '#find_unsynced_projects', :geo_fdw do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectUnsyncedFinder,
Geo::ProjectUnsyncedFinder,
:find_unsynced_projects, [shard_name: 'default', batch_size: 100]
end
describe '#find_projects_updated_recently', :delete do
describe '#find_projects_updated_recently', :geo_fdw do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectUpdatedRecentlyFinder,
Geo::ProjectUpdatedRecentlyFinder,
:find_projects_updated_recently, [shard_name: 'default', batch_size: 100]
end
describe '#find_failed_project_registries', :delete do
describe '#find_failed_project_registries', :geo_fdw do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistrySyncFailedFinder,
Geo::ProjectRegistrySyncFailedFinder,
:find_failed_project_registries, ['repository']
end
describe '#find_registries_to_verify', :delete do
describe '#find_registries_to_verify', :geo_fdw do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistryPendingVerificationFinder,
Geo::ProjectRegistryPendingVerificationFinder,
:find_registries_to_verify, [shard_name: 'default', batch_size: 100]
end
describe '#find_verification_failed_project_registries', :delete do
describe '#find_verification_failed_project_registries', :geo_fdw do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistryVerificationFailedFinder,
Geo::ProjectRegistryVerificationFailedFinder,
:find_verification_failed_project_registries, ['repository']
end
describe '#find_checksum_mismatch_project_registries', :delete do
describe '#find_checksum_mismatch_project_registries', :geo_fdw do
include_examples 'delegates to the proper finder',
Geo::LegacyProjectRegistryMismatchFinder,
Geo::ProjectRegistryMismatchFinder,
......
......@@ -2,10 +2,8 @@
require 'spec_helper'
describe Geo::ProjectRegistryMismatchFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectRegistryMismatchFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -22,10 +20,6 @@ describe Geo::ProjectRegistryMismatchFinder, :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) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
......
......@@ -2,16 +2,10 @@
require 'spec_helper'
describe Geo::ProjectRegistryPendingVerificationFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectRegistryPendingVerificationFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
subject { described_class.new(current_node: node, shard_name: 'default', batch_size: 100) }
it 'does not return registries that are verified on primary and secondary' do
......
......@@ -2,10 +2,8 @@
require 'spec_helper'
describe Geo::ProjectRegistryRetryingVerificationFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectRegistryRetryingVerificationFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -22,10 +20,6 @@ describe Geo::ProjectRegistryRetryingVerificationFinder, :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) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
......
# frozen_string_literal: true
require 'spec_helper'
describe Geo::ProjectRegistryStatusFinder, :geo do
describe Geo::ProjectRegistryStatusFinder, :geo, :geo_tracking_db do
include ::EE::GeoHelpers
set(:secondary) { create(:geo_node) }
......@@ -21,7 +21,6 @@ describe Geo::ProjectRegistryStatusFinder, :geo do
subject { described_class.new(current_node: secondary) }
before do
skip('FDW is not configured') if Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
stub_current_geo_node(secondary)
end
......
......@@ -2,10 +2,8 @@
require 'spec_helper'
describe Geo::ProjectRegistrySyncFailedFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectRegistrySyncFailedFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -22,10 +20,6 @@ describe Geo::ProjectRegistrySyncFailedFinder, :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) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
......
......@@ -2,10 +2,8 @@
require 'spec_helper'
describe Geo::ProjectRegistrySyncedFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectRegistrySyncedFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -22,10 +20,6 @@ describe Geo::ProjectRegistrySyncedFinder, :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) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
......
......@@ -2,10 +2,8 @@
require 'spec_helper'
describe Geo::ProjectRegistryVerificationFailedFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectRegistryVerificationFailedFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -22,10 +20,6 @@ describe Geo::ProjectRegistryVerificationFailedFinder, :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) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
......
......@@ -2,10 +2,8 @@
require 'spec_helper'
describe Geo::ProjectRegistryVerifiedFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectRegistryVerifiedFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -22,10 +20,6 @@ describe Geo::ProjectRegistryVerifiedFinder, :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) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
context 'with repository type' do
subject { described_class.new(current_node: node, type: :repository) }
......
......@@ -2,10 +2,8 @@
require 'spec_helper'
describe Geo::ProjectUnsyncedFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectUnsyncedFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -16,8 +14,6 @@ describe Geo::ProjectUnsyncedFinder, :geo do
let!(:project_4) { create(:project, group: group_1) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
project_4.update_column(:repository_storage, 'foo')
end
......
......@@ -2,10 +2,8 @@
require 'spec_helper'
describe Geo::ProjectUpdatedRecentlyFinder, :geo do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#execute', :delete do
describe Geo::ProjectUpdatedRecentlyFinder, :geo, :geo_fdw do
describe '#execute' do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -16,8 +14,6 @@ describe Geo::ProjectUpdatedRecentlyFinder, :geo do
let!(:project_4) { create(:project, group: group_1) }
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
project_4.update_column(:repository_storage, 'foo')
create(:geo_project_registry, :synced, :repository_dirty, project: project_1)
......
......@@ -2,9 +2,7 @@
require 'spec_helper'
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe Gitlab::Geo::Fdw::UploadRegistryQueryBuilder, :geo, :delete do
describe Gitlab::Geo::Fdw::UploadRegistryQueryBuilder, :geo, :geo_fdw do
let(:project) { create(:project) }
let(:upload_1) { create(:upload, :issuable_upload, model: project) }
let(:upload_2) { create(:upload, :issuable_upload, model: project) }
......@@ -13,10 +11,6 @@ describe Gitlab::Geo::Fdw::UploadRegistryQueryBuilder, :geo, :delete do
let!(:file_registry_2) { create(:geo_file_registry, :attachment, file_id: upload_2.id) }
let!(:file_registry_3) { create(:geo_file_registry, file_id: upload_3.id) }
before do
skip('FDW is not configured') if Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
end
describe '#for_model' do
it 'returns registries that upload belong to the model' do
expect(subject.for_model(project)).to match_ids(file_registry_1, file_registry_2)
......
......@@ -27,7 +27,7 @@ describe SystemCheck::Geo::FdwEnabledCheck, :geo do
end
describe '#check?' do
context 'with functional FDW environment', :geo_tracking_db do
context 'with functional FDW environment', :geo_fdw do
it 'returns true' do
expect(subject.check?).to be_truthy
end
......
......@@ -36,7 +36,7 @@ describe SystemCheck::Geo::FdwSchemaUpToDateCheck, :geo do
end
end
context 'with functional FDW environment', :geo_tracking_db do
context 'with functional FDW environment', :geo_fdw do
it 'returns true' do
expect(subject.check?).to be_truthy
end
......
......@@ -8,13 +8,7 @@ RSpec.describe Geo::Fdw::GeoNode, :geo, type: :model do
it { is_expected.to have_many(:namespaces).class_name('Geo::Fdw::Namespace').through(:geo_node_namespace_links) }
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#projects', :delete do
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
describe '#projects', :geo_fdw do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......@@ -50,11 +44,7 @@ RSpec.describe Geo::Fdw::GeoNode, :geo, type: :model do
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#project_registries', :delete do
before do
skip('FDW is not configured') unless Gitlab::Geo::Fdw.enabled?
end
describe '#project_registries', :geo_fdw do
let(:node) { create(:geo_node) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe Geo::UploadRegistry, :geo, :delete do
describe Geo::UploadRegistry, :geo, :geo_fdw do
let!(:lfs_registry) { create(:geo_file_registry, :lfs) }
let!(:attachment_registry) { create(:geo_file_registry, :attachment, :with_file) }
let!(:avatar_registry) { create(:geo_file_registry, :avatar) }
......@@ -28,7 +28,7 @@ describe Geo::UploadRegistry, :geo, :delete do
expect(described_class.find(attachment_registry.id).upload).to be_an_instance_of(Upload)
end
describe '.with_search', :geo_fdw do
describe '.with_search' do
it 'searches registries on path' do
upload = create(:upload, path: 'uploads/-/system/project/avatar/my-awesome-avatar.png')
upload_registry = create(:geo_upload_registry, file_id: upload.id, file_type: :avatar)
......
require 'spec_helper'
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe GeoNodeStatus, :geo, :delete do
describe GeoNodeStatus, :geo, :geo_fdw do
include ::EE::GeoHelpers
let!(:primary) { create(:geo_node, :primary) }
......@@ -122,9 +120,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#attachments_synced_count', :delete do
describe '#attachments_synced_count' do
it 'only counts successful syncs' do
create_list(:user, 3, avatar: fixture_file_upload('spec/fixtures/dk.png', 'image/png'))
uploads = Upload.all.pluck(:id)
......@@ -167,9 +163,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#attachments_synced_missing_on_primary_count', :delete do
describe '#attachments_synced_missing_on_primary_count' do
it 'only counts successful syncs' do
create_list(:user, 3, avatar: fixture_file_upload('spec/fixtures/dk.png', 'image/png'))
uploads = Upload.all.pluck(:id)
......@@ -182,7 +176,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
describe '#attachments_failed_count', :delete do
describe '#attachments_failed_count' do
it 'counts failed avatars, attachment, personal snippets and files' do
# These two should be ignored
create(:geo_file_registry, :lfs, :with_file, :failed)
......@@ -197,7 +191,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
describe '#attachments_synced_in_percentage', :delete do
describe '#attachments_synced_in_percentage' do
let(:avatar) { fixture_file_upload('spec/fixtures/dk.png') }
let(:upload_1) { create(:upload, model: group, path: avatar) }
let(:upload_2) { create(:upload, model: project_1, path: avatar) }
......@@ -243,9 +237,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#lfs_objects_synced_count', :delete do
describe '#lfs_objects_synced_count' do
it 'counts synced LFS objects' do
# These four should be ignored
create(:geo_file_registry, :failed)
......@@ -259,9 +251,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#lfs_objects_synced_missing_on_primary_count', :delete do
describe '#lfs_objects_synced_missing_on_primary_count' do
it 'counts LFS objects marked as synced due to file missing on the primary' do
# These four should be ignored
create(:geo_file_registry, :failed)
......@@ -275,9 +265,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#lfs_objects_failed_count', :delete do
describe '#lfs_objects_failed_count' do
it 'counts failed LFS objects' do
# These four should be ignored
create(:geo_file_registry, :failed)
......@@ -291,9 +279,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#lfs_objects_synced_in_percentage', :delete do
describe '#lfs_objects_synced_in_percentage' do
let(:lfs_object_project) { create(:lfs_objects_project, project: project_1) }
before do
......@@ -321,9 +307,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#job_artifacts_synced_count', :delete do
describe '#job_artifacts_synced_count' do
it 'counts synced job artifacts' do
# These should be ignored
create(:geo_file_registry)
......@@ -335,9 +319,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#job_artifacts_synced_missing_on_primary_count', :delete do
describe '#job_artifacts_synced_missing_on_primary_count' do
it 'counts job artifacts marked as synced due to file missing on the primary' do
# These should be ignored
create(:geo_file_registry, missing_on_primary: true)
......@@ -349,9 +331,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#job_artifacts_failed_count', :delete do
describe '#job_artifacts_failed_count' do
it 'counts failed job artifacts' do
# These should be ignored
create(:geo_file_registry, :failed)
......@@ -365,9 +345,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#job_artifacts_synced_in_percentage', :delete do
describe '#job_artifacts_synced_in_percentage' do
context 'when artifacts are available' do
before do
[project_1, project_2, project_3, project_4].each_with_index do |project, index|
......@@ -457,9 +435,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe '#wikis_synced_in_percentage', :delete do
describe '#wikis_synced_in_percentage' do
it 'returns 0 when no projects are available' do
expect(subject.wikis_synced_in_percentage).to eq(0)
end
......@@ -631,7 +607,7 @@ describe GeoNodeStatus, :geo, :delete do
end
end
describe '#wikis_checksummed_in_percentage', :delete do
describe '#wikis_checksummed_in_percentage' do
before do
stub_current_geo_node(primary)
end
......
require 'spec_helper'
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe Geo::FilesExpireService, :geo, :delete do
describe Geo::FilesExpireService, :geo, :geo_fdw do
let(:project) { create(:project, :legacy_storage) }
let!(:old_full_path) { project.full_path }
subject { described_class.new(project, old_full_path) }
describe '#execute' do
......
......@@ -20,6 +20,12 @@ RSpec.configure do |config|
end
config.around(:each, :geo_fdw) do |example|
example.run if Gitlab::Geo::Fdw.enabled?
if Gitlab::Geo::Fdw.enabled? && Gitlab::Geo.geo_database_configured?
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
example.metadata[:delete] = true
example.run
end
end
end
......@@ -18,13 +18,7 @@ shared_examples_for 'a file registry finder' do
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') if Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
end
context 'FDW', :geo_fdw do
include_examples 'counts all the things'
include_examples 'finds all the things' do
......
......@@ -58,9 +58,7 @@ describe 'geo rake tasks', :geo do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe 'status task', :delete do
describe 'status task', :geo_fdw do
let!(:current_node) { create(:geo_node) }
let!(:primary_node) { create(:geo_node, :primary) }
let!(:geo_event_log) { create(:geo_event_log) }
......
......@@ -14,13 +14,7 @@ describe Geo::FileDownloadDispatchWorker, :geo do
WebMock.stub_request(:get, /primary-geo-node/).to_return(status: 200, body: "", headers: {})
end
subject { described_class.new }
shared_examples '#perform' do |skip_tests|
before do
skip('FDW is not configured') if skip_tests
end
shared_examples '#perform' do
it 'does not schedule anything when tracking database is not configured' do
create(:lfs_object, :with_file)
......@@ -399,18 +393,15 @@ describe Geo::FileDownloadDispatchWorker, :geo do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe 'when PostgreSQL FDW is available', :geo, :delete do
# Skip if FDW isn't activated on this database
it_behaves_like '#perform', Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
describe 'when PostgreSQL FDW is available', :geo_fdw do
it_behaves_like '#perform'
end
describe 'when PostgreSQL FDW is not enabled', :geo do
describe 'when PostgreSQL FDW is not enabled' do
before do
allow(Gitlab::Geo::Fdw).to receive(:enabled?).and_return(false)
end
it_behaves_like '#perform', false
it_behaves_like '#perform'
end
end
......@@ -13,11 +13,7 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo do
allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:renew).and_return(true)
end
shared_examples '#perform' do |skip_tests|
before do
skip('FDW is not configured') if skip_tests
end
shared_examples '#perform' do
it 'does not run when node is disabled' do
secondary.enabled = false
secondary.save
......@@ -173,11 +169,8 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo do
end
end
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe 'when PostgreSQL FDW is available', :geo, :delete do
# Skip if FDW isn't activated on this database
it_behaves_like '#perform', Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
describe 'when PostgreSQL FDW is available', :geo, :geo_fdw do
it_behaves_like '#perform'
end
describe 'when PostgreSQL FDW is not enabled', :geo do
......@@ -185,6 +178,6 @@ describe Geo::MigratedLocalFilesCleanUpWorker, :geo do
allow(Gitlab::Geo::Fdw).to receive(:enabled?).and_return(false)
end
it_behaves_like '#perform', false
it_behaves_like '#perform'
end
end
require 'spec_helper'
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
describe Geo::RepositoryShardSyncWorker, :geo, :delete, :clean_gitlab_redis_cache do
describe Geo::RepositoryShardSyncWorker, :geo, :geo_fdw, :clean_gitlab_redis_cache do
include ::EE::GeoHelpers
include ExclusiveLeaseHelpers
......@@ -15,16 +13,12 @@ describe Geo::RepositoryShardSyncWorker, :geo, :delete, :clean_gitlab_redis_cach
stub_current_geo_node(secondary)
end
shared_examples '#perform' do |skip_tests|
shared_examples '#perform' do
let!(:restricted_group) { create(:group) }
let!(:unsynced_project_in_restricted_group) { create(:project, group: restricted_group) }
let!(:unsynced_project) { create(:project) }
before do
skip('FDW is not configured') if skip_tests
end
before do
stub_exclusive_lease(renew: true)
......@@ -291,9 +285,8 @@ describe Geo::RepositoryShardSyncWorker, :geo, :delete, :clean_gitlab_redis_cach
end
end
describe 'when PostgreSQL FDW is available', :geo do
# Skip if FDW isn't activated on this database
it_behaves_like '#perform', Gitlab::Database.postgresql? && !Gitlab::Geo::Fdw.enabled?
describe 'when PostgreSQL FDW is available', :geo, :geo_fdw do
it_behaves_like '#perform'
end
describe 'when PostgreSQL FDW is not enabled', :geo do
......@@ -301,6 +294,6 @@ describe Geo::RepositoryShardSyncWorker, :geo, :delete, :clean_gitlab_redis_cach
allow(Gitlab::Geo::Fdw).to receive(:enabled?).and_return(false)
end
it_behaves_like '#perform', false
it_behaves_like '#perform'
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