Commit 177264cc authored by Valery Sizov's avatar Valery Sizov

Geo: Refactor replicator-related specs

DRY up specs
parent 55ac007e
......@@ -3,11 +3,13 @@
require 'spec_helper'
RSpec.describe Gitlab::Geo::RegistryBatcher, :geo, :use_clean_rails_memory_store_caching do
include EE::GeoHelpers
describe '#next_range!' do
let(:model_class) { LfsObject }
let(:model_foreign_key) { registry_class::MODEL_FOREIGN_KEY }
let(:registry_class) { Geo::LfsObjectRegistry }
let(:registry_class_factory) { registry_class.underscore.tr('/', '_').to_sym }
let(:registry_class_factory) { registry_factory_name(registry_class) }
let(:key) { 'looping_batcher_spec' }
let(:batch_size) { 2 }
......
......@@ -6,6 +6,4 @@ RSpec.describe Geo::PackageFileReplicator do
let(:model_record) { build(:package_file, :npm) }
include_examples 'a blob replicator'
include_examples 'secondary counters', :geo_package_file_registry
end
......@@ -21,7 +21,7 @@ RSpec.describe Geo::RegistryConsistencyService, :geo, :use_clean_rails_memory_st
shared_examples 'registry consistency service' do |klass|
let(:registry_class) { klass }
let(:registry_class_factory) { registry_class.underscore.tr('/', '_').to_sym }
let(:registry_class_factory) { registry_factory_name(registry_class) }
let(:model_class) { registry_class::MODEL_CLASS }
let(:model_class_factory) { model_class_factory_name(model_class) }
let(:model_foreign_key) { registry_class::MODEL_FOREIGN_KEY }
......
......@@ -33,6 +33,10 @@ module EE
::Gitlab::ShardHealthCache.update(Array(shards))
end
def registry_factory_name(registry_class)
registry_class.underscore.tr('/', '_').to_sym
end
def with_no_geo_database_configured(&block)
allow(::Gitlab::Geo).to receive(:geo_database_configured?).and_return(false)
......
......@@ -18,13 +18,15 @@ RSpec.shared_examples 'a replicator' do
expect { replicator.parent_project_id }.not_to raise_error
end
end
end
RSpec.shared_examples 'secondary counters' do |registry_factory_name|
before do
create(registry_factory_name, :synced)
create(registry_factory_name)
create(registry_factory_name, :failed)
context 'Geo node status' do
context 'on a secondary node' do
let_it_be(:registry_factory) { registry_factory_name(described_class.registry_class) }
before_all do
create(registry_factory, :synced)
create(registry_factory)
create(registry_factory, :failed)
end
describe '.synced_count' do
......@@ -38,4 +40,6 @@ RSpec.shared_examples 'secondary counters' do |registry_factory_name|
expect(described_class.failed_count).to eq(1)
end
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