Commit 0b213b0d authored by Valery Sizov's avatar Valery Sizov

Merge branch...

Merge branch '220519-follow-up-from-geo-track-packagefile-sync-counts-in-geo-node-statuses' into 'master'

Geo: Refactor replicator-related specs

Closes #220519

See merge request gitlab-org/gitlab!35678
parents 81d353bc 177264cc
......@@ -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,24 +18,28 @@ 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)
end
context 'Geo node status' do
context 'on a secondary node' do
let_it_be(:registry_factory) { registry_factory_name(described_class.registry_class) }
describe '.synced_count' do
it 'returns the number of synced items on secondary' do
expect(described_class.synced_count).to eq(1)
end
end
before_all do
create(registry_factory, :synced)
create(registry_factory)
create(registry_factory, :failed)
end
describe '.synced_count' do
it 'returns the number of synced items on secondary' do
expect(described_class.synced_count).to eq(1)
end
end
describe '.failed_count' do
it 'returns the number of failed items on secondary' do
expect(described_class.failed_count).to eq(1)
describe '.failed_count' do
it 'returns the number of failed items on secondary' do
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