Commit b31cee4e authored by Michael Kozono's avatar Michael Kozono

Merge branch '223104-geo-refactor-finders' into 'master'

Geo - Refactor finders (Part I)

See merge request gitlab-org/gitlab!40313
parents 67bf6822 3c629e4e
...@@ -31,7 +31,7 @@ module Geo ...@@ -31,7 +31,7 @@ module Geo
.map! { |id, uploader| [id, uploader.sub(/Uploader\z/, '').underscore] } .map! { |id, uploader| [id, uploader.sub(/Uploader\z/, '').underscore] }
tracked = tracked =
syncable registry_class
.model_id_in(range) .model_id_in(range)
.pluck(:file_id, :file_type) .pluck(:file_id, :file_type)
# rubocop:enable CodeReuse/ActiveRecord # rubocop:enable CodeReuse/ActiveRecord
...@@ -46,7 +46,7 @@ module Geo ...@@ -46,7 +46,7 @@ module Geo
::Upload.replicables_for_geo_node ::Upload.replicables_for_geo_node
end end
def syncable def registry_class
Geo::UploadRegistry Geo::UploadRegistry
end end
end end
......
...@@ -2,32 +2,6 @@ ...@@ -2,32 +2,6 @@
module Geo module Geo
class ContainerRepositoryRegistryFinder < RegistryFinder class ContainerRepositoryRegistryFinder < RegistryFinder
def count_syncable
container_repositories.count
end
def count_synced
Geo::ContainerRepositoryRegistry.synced.count
end
def count_failed
Geo::ContainerRepositoryRegistry.failed.count
end
def count_registry
Geo::ContainerRepositoryRegistry.count
end
def find_registry_differences(range)
source_ids = container_repositories.id_in(range).pluck_primary_key
tracked_ids = Geo::ContainerRepositoryRegistry.pluck_model_ids_in_range(range)
untracked_ids = source_ids - tracked_ids
unused_tracked_ids = tracked_ids - source_ids
[untracked_ids, unused_tracked_ids]
end
# Returns Geo::ContainerRepositoryRegistry records that have never been synced. # Returns Geo::ContainerRepositoryRegistry records that have never been synced.
# #
# Does not care about selective sync, because it considers the Registry # Does not care about selective sync, because it considers the Registry
...@@ -46,7 +20,7 @@ module Geo ...@@ -46,7 +20,7 @@ module Geo
# @param [Array<Integer>] except_ids ids that will be ignored from the query # @param [Array<Integer>] except_ids ids that will be ignored from the query
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_never_synced_registries(batch_size:, except_ids: []) def find_never_synced_registries(batch_size:, except_ids: [])
Geo::ContainerRepositoryRegistry registry_class
.never_synced .never_synced
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
.limit(batch_size) .limit(batch_size)
...@@ -55,7 +29,7 @@ module Geo ...@@ -55,7 +29,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_retryable_dirty_registries(batch_size:, except_ids: []) def find_retryable_dirty_registries(batch_size:, except_ids: [])
Geo::ContainerRepositoryRegistry registry_class
.failed .failed
.retry_due .retry_due
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
...@@ -66,8 +40,12 @@ module Geo ...@@ -66,8 +40,12 @@ module Geo
private private
def container_repositories def replicables
current_node.container_repositories current_node.container_repositories
end end
def registry_class
Geo::ContainerRepositoryRegistry
end
end end
end end
...@@ -2,32 +2,6 @@ ...@@ -2,32 +2,6 @@
module Geo module Geo
class DesignRegistryFinder < RegistryFinder class DesignRegistryFinder < RegistryFinder
def count_syncable
designs.count
end
def count_synced
registries.synced.count
end
def count_failed
registries.failed.count
end
def count_registry
registries.count
end
def find_registry_differences(range)
source_ids = designs.id_in(range).pluck_primary_key
tracked_ids = registries.pluck_model_ids_in_range(range)
untracked_ids = source_ids - tracked_ids
unused_tracked_ids = tracked_ids - source_ids
[untracked_ids, unused_tracked_ids]
end
# Returns Geo::DesignRegistry records that have never been synced. # Returns Geo::DesignRegistry records that have never been synced.
# #
# Does not care about selective sync, because it considers the Registry # Does not care about selective sync, because it considers the Registry
...@@ -46,7 +20,7 @@ module Geo ...@@ -46,7 +20,7 @@ module Geo
# @param [Array<Integer>] except_ids ids that will be ignored from the query # @param [Array<Integer>] except_ids ids that will be ignored from the query
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_never_synced_registries(batch_size:, except_ids: []) def find_never_synced_registries(batch_size:, except_ids: [])
registries registry_class
.never_synced .never_synced
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
.limit(batch_size) .limit(batch_size)
...@@ -55,7 +29,7 @@ module Geo ...@@ -55,7 +29,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_retryable_dirty_registries(batch_size:, except_ids: []) def find_retryable_dirty_registries(batch_size:, except_ids: [])
registries registry_class
.updated_recently .updated_recently
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
.order(Gitlab::Database.nulls_first_order(:last_synced_at)) .order(Gitlab::Database.nulls_first_order(:last_synced_at))
...@@ -65,11 +39,11 @@ module Geo ...@@ -65,11 +39,11 @@ module Geo
private private
def designs def replicables
current_node.designs current_node.designs
end end
def registries def registry_class
Geo::DesignRegistry Geo::DesignRegistry
end end
end end
......
...@@ -2,65 +2,11 @@ ...@@ -2,65 +2,11 @@
module Geo module Geo
class FileRegistryFinder < RegistryFinder class FileRegistryFinder < RegistryFinder
# @!method count_syncable
# Return a count of the registry records for the tracked file_type(s)
def count_syncable
syncable.count
end
# @!method count_synced
# Return a count of the registry records for the tracked file_type(s)
# that are synced
def count_synced
syncable.synced.count
end
# @!method count_failed
# Return a count of the registry records for the tracked file_type(s)
# that are sync failed
def count_failed
syncable.failed.count
end
# @!method count_synced_missing_on_primary # @!method count_synced_missing_on_primary
# Return a count of the registry records for the tracked file_type(s) # Return a count of the registry records for the tracked file_type(s)
# that are synced and missing on the primary # that are synced and missing on the primary
def count_synced_missing_on_primary def count_synced_missing_on_primary
syncable.synced.missing_on_primary.count registry_class.synced.missing_on_primary.count
end
# @!method count_registry
# Return a count of the registry records for the tracked file_type(s)
def count_registry
syncable.count
end
# @!method find_registry_differences
# Returns untracked IDs as well as tracked IDs that are unused.
#
# Untracked IDs are model IDs that are supposed to be synced but don't yet
# have a registry entry.
#
# Unused tracked IDs are model IDs that are not supposed to be synced but
# already have a registry entry. For example:
#
# - orphaned registries
# - records that became excluded from selective sync
# - records that are in object storage, and `sync_object_storage` became
# disabled
#
# We compute both sets in this method to reduce the number of DB queries
# performed.
#
# @return [Array] the first element is an Array of untracked IDs, and the second element is an Array of tracked IDs that are unused
def find_registry_differences(range)
source_ids = replicables.id_in(range).pluck(replicable_primary_key) # rubocop:disable CodeReuse/ActiveRecord
tracked_ids = syncable.pluck_model_ids_in_range(range)
untracked_ids = source_ids - tracked_ids
unused_tracked_ids = tracked_ids - source_ids
[untracked_ids, unused_tracked_ids]
end end
# @!method find_never_synced_registries # @!method find_never_synced_registries
...@@ -84,7 +30,7 @@ module Geo ...@@ -84,7 +30,7 @@ module Geo
# #
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_never_synced_registries(batch_size:, except_ids: []) def find_never_synced_registries(batch_size:, except_ids: [])
syncable registry_class
.never .never
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
.limit(batch_size) .limit(batch_size)
...@@ -101,7 +47,7 @@ module Geo ...@@ -101,7 +47,7 @@ module Geo
# #
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_retryable_failed_registries(batch_size:, except_ids: []) def find_retryable_failed_registries(batch_size:, except_ids: [])
syncable registry_class
.failed .failed
.retry_due .retry_due
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
...@@ -119,7 +65,7 @@ module Geo ...@@ -119,7 +65,7 @@ module Geo
# #
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_retryable_synced_missing_on_primary_registries(batch_size:, except_ids: []) def find_retryable_synced_missing_on_primary_registries(batch_size:, except_ids: [])
syncable registry_class
.synced .synced
.missing_on_primary .missing_on_primary
.retry_due .retry_due
...@@ -128,28 +74,6 @@ module Geo ...@@ -128,28 +74,6 @@ module Geo
end end
# rubocop:enable CodeReuse/ActiveRecord # rubocop:enable CodeReuse/ActiveRecord
# @!method syncable
# Return an ActiveRecord::Base class for the tracked file_type(s)
def syncable
raise NotImplementedError,
"#{self.class} does not implement #{__method__}"
end
# @!method replicables
# Return an ActiveRecord::Relation of the replicable records for the
# tracked file_type(s)
def replicables
raise NotImplementedError,
"#{self.class} does not implement #{__method__}"
end
# @!method syncable
# Return the fully qualified name of the replicable primary key for the
# tracked file_type(s)
def replicable_primary_key
syncable::MODEL_CLASS.arel_table[:id]
end
def local_storage_only? def local_storage_only?
!current_node&.sync_object_storage !current_node&.sync_object_storage
end end
......
...@@ -6,7 +6,7 @@ module Geo ...@@ -6,7 +6,7 @@ module Geo
::Ci::JobArtifact.replicables_for_geo_node ::Ci::JobArtifact.replicables_for_geo_node
end end
def syncable def registry_class
Geo::JobArtifactRegistry Geo::JobArtifactRegistry
end end
end end
......
...@@ -6,7 +6,7 @@ module Geo ...@@ -6,7 +6,7 @@ module Geo
local_storage_only? ? lfs_objects.with_files_stored_locally : lfs_objects local_storage_only? ? lfs_objects.with_files_stored_locally : lfs_objects
end end
def syncable def registry_class
Geo::LfsObjectRegistry Geo::LfsObjectRegistry
end end
......
...@@ -10,6 +10,69 @@ module Geo ...@@ -10,6 +10,69 @@ module Geo
@current_node_id = current_node_id @current_node_id = current_node_id
end end
# @!method find_registry_differences
# Returns untracked IDs as well as tracked IDs that are unused.
#
# Untracked IDs are model IDs that are supposed to be synced but don't yet
# have a registry entry.
#
# Unused tracked IDs are model IDs that are not supposed to be synced but
# already have a registry entry. For example:
#
# - orphaned registries
# - records that became excluded from selective sync
# - records that are in object storage, and `sync_object_storage` became
# disabled
#
# We compute both sets in this method to reduce the number of DB queries
# performed.
#
# @return [Array] the first element is an Array of untracked IDs, and the second element is an Array of tracked IDs that are unused
def find_registry_differences(range)
source_ids = replicables.id_in(range).pluck(replicable_primary_key) # rubocop:disable CodeReuse/ActiveRecord
tracked_ids = registry_class.pluck_model_ids_in_range(range)
untracked_ids = source_ids - tracked_ids
unused_tracked_ids = tracked_ids - source_ids
[untracked_ids, unused_tracked_ids]
end
# @!method registry_class
# Return an ActiveRecord::Base class for the tracked type
def registry_class
raise NotImplementedError,
"#{self.class} does not implement #{__method__}"
end
# @!method replicables
# Return an ActiveRecord::Relation of the replicable records for the
# tracked file_type(s)
def replicables
raise NotImplementedError,
"#{self.class} does not implement #{__method__}"
end
# @!method registry_count
# Return a count of the registry records for the tracked type(s)
def registry_count
registry_class.count
end
# @!method synced_count
# Return a count of the registry records for the tracked type
# that are synced
def synced_count
registry_class.synced.count
end
# @!method failed_count
# Return a count of the registry records for the tracked type
# that are sync failed
def failed_count
registry_class.failed.count
end
private private
def current_node def current_node
...@@ -17,5 +80,12 @@ module Geo ...@@ -17,5 +80,12 @@ module Geo
GeoNode.find(current_node_id) if current_node_id GeoNode.find(current_node_id) if current_node_id
end end
end end
# @!method registry_class
# Return the fully qualified name of the replicable primary key for the
# tracked file_type(s)
def replicable_primary_key
registry_class::MODEL_CLASS.arel_table[:id]
end
end end
end end
...@@ -296,9 +296,6 @@ class GeoNodeStatus < ApplicationRecord ...@@ -296,9 +296,6 @@ class GeoNodeStatus < ApplicationRecord
self.version = Gitlab::VERSION self.version = Gitlab::VERSION
self.revision = Gitlab.revision self.revision = Gitlab.revision
self.projects_count = geo_node.projects.count
self.package_files_count = Geo::PackageFileReplicator.primary_total_count
load_status_message load_status_message
load_event_data load_event_data
load_primary_data load_primary_data
...@@ -424,10 +421,8 @@ class GeoNodeStatus < ApplicationRecord ...@@ -424,10 +421,8 @@ class GeoNodeStatus < ApplicationRecord
def load_primary_data def load_primary_data
return unless Gitlab::Geo.primary? return unless Gitlab::Geo.primary?
self.lfs_objects_count = LfsObject.count self.projects_count = geo_node.projects.count
self.job_artifacts_count = Ci::JobArtifact.not_expired.count self.package_files_count = Geo::PackageFileReplicator.primary_total_count
self.attachments_count = Upload.count
self.replication_slots_count = geo_node.replication_slots_count self.replication_slots_count = geo_node.replication_slots_count
self.replication_slots_used_count = geo_node.replication_slots_used_count self.replication_slots_used_count = geo_node.replication_slots_used_count
self.replication_slots_max_retained_wal_bytes = geo_node.replication_slots_max_retained_wal_bytes self.replication_slots_max_retained_wal_bytes = geo_node.replication_slots_max_retained_wal_bytes
...@@ -450,6 +445,7 @@ class GeoNodeStatus < ApplicationRecord ...@@ -450,6 +445,7 @@ class GeoNodeStatus < ApplicationRecord
end end
def load_repositories_data def load_repositories_data
self.projects_count = Geo::ProjectRegistry.count
self.repositories_synced_count = Geo::ProjectRegistry.synced(:repository).count self.repositories_synced_count = Geo::ProjectRegistry.synced(:repository).count
self.repositories_failed_count = Geo::ProjectRegistry.sync_failed(:repository).count self.repositories_failed_count = Geo::ProjectRegistry.sync_failed(:repository).count
self.wikis_synced_count = Geo::ProjectRegistry.synced(:wiki).count self.wikis_synced_count = Geo::ProjectRegistry.synced(:wiki).count
...@@ -459,54 +455,55 @@ class GeoNodeStatus < ApplicationRecord ...@@ -459,54 +455,55 @@ class GeoNodeStatus < ApplicationRecord
def load_lfs_objects_data def load_lfs_objects_data
return unless lfs_objects_replication_enabled return unless lfs_objects_replication_enabled
self.lfs_objects_count = lfs_objects_finder.count_syncable self.lfs_objects_count = lfs_objects_finder.registry_count
self.lfs_objects_synced_count = lfs_objects_finder.count_synced self.lfs_objects_synced_count = lfs_objects_finder.synced_count
self.lfs_objects_failed_count = lfs_objects_finder.count_failed self.lfs_objects_failed_count = lfs_objects_finder.failed_count
self.lfs_objects_registry_count = lfs_objects_finder.count_registry self.lfs_objects_registry_count = lfs_objects_finder.registry_count
self.lfs_objects_synced_missing_on_primary_count = lfs_objects_finder.count_synced_missing_on_primary self.lfs_objects_synced_missing_on_primary_count = lfs_objects_finder.count_synced_missing_on_primary
end end
def load_job_artifacts_data def load_job_artifacts_data
return unless job_artifacts_replication_enabled return unless job_artifacts_replication_enabled
self.job_artifacts_count = job_artifacts_finder.count_syncable self.job_artifacts_count = job_artifacts_finder.registry_count
self.job_artifacts_synced_count = job_artifacts_finder.count_synced self.job_artifacts_synced_count = job_artifacts_finder.synced_count
self.job_artifacts_failed_count = job_artifacts_finder.count_failed self.job_artifacts_failed_count = job_artifacts_finder.failed_count
self.job_artifacts_registry_count = job_artifacts_finder.count_registry self.job_artifacts_registry_count = job_artifacts_finder.registry_count
self.job_artifacts_synced_missing_on_primary_count = job_artifacts_finder.count_synced_missing_on_primary self.job_artifacts_synced_missing_on_primary_count = job_artifacts_finder.count_synced_missing_on_primary
end end
def load_attachments_data def load_attachments_data
return unless attachments_replication_enabled return unless attachments_replication_enabled
self.attachments_count = attachments_finder.count_syncable self.attachments_count = attachments_finder.registry_count
self.attachments_synced_count = attachments_finder.count_synced self.attachments_synced_count = attachments_finder.synced_count
self.attachments_failed_count = attachments_finder.count_failed self.attachments_failed_count = attachments_finder.failed_count
self.attachments_registry_count = attachments_finder.count_registry self.attachments_registry_count = attachments_finder.registry_count
self.attachments_synced_missing_on_primary_count = attachments_finder.count_synced_missing_on_primary self.attachments_synced_missing_on_primary_count = attachments_finder.count_synced_missing_on_primary
end end
def load_container_registry_data def load_container_registry_data
return unless container_repositories_replication_enabled return unless container_repositories_replication_enabled
self.container_repositories_count = container_registry_finder.count_syncable self.container_repositories_count = container_registry_finder.registry_count
self.container_repositories_synced_count = container_registry_finder.count_synced self.container_repositories_synced_count = container_registry_finder.synced_count
self.container_repositories_failed_count = container_registry_finder.count_failed self.container_repositories_failed_count = container_registry_finder.failed_count
self.container_repositories_registry_count = container_registry_finder.count_registry self.container_repositories_registry_count = container_registry_finder.registry_count
end end
def load_designs_data def load_designs_data
return unless design_repositories_replication_enabled return unless design_repositories_replication_enabled
self.design_repositories_count = design_registry_finder.count_syncable self.design_repositories_count = design_registry_finder.registry_count
self.design_repositories_synced_count = design_registry_finder.count_synced self.design_repositories_synced_count = design_registry_finder.synced_count
self.design_repositories_failed_count = design_registry_finder.count_failed self.design_repositories_failed_count = design_registry_finder.failed_count
self.design_repositories_registry_count = design_registry_finder.count_registry self.design_repositories_registry_count = design_registry_finder.registry_count
end end
def load_package_files_data def load_package_files_data
# return unless package_files_replication_enabled # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/221069 # return unless package_files_replication_enabled # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/221069
self.package_files_count = Geo::PackageFileReplicator.registry_count
self.package_files_registry_count = Geo::PackageFileReplicator.registry_count self.package_files_registry_count = Geo::PackageFileReplicator.registry_count
self.package_files_synced_count = Geo::PackageFileReplicator.synced_count self.package_files_synced_count = Geo::PackageFileReplicator.synced_count
self.package_files_failed_count = Geo::PackageFileReplicator.failed_count self.package_files_failed_count = Geo::PackageFileReplicator.failed_count
......
...@@ -30,7 +30,7 @@ RSpec.describe Geo::AttachmentRegistryFinder, :geo do ...@@ -30,7 +30,7 @@ RSpec.describe Geo::AttachmentRegistryFinder, :geo do
subject { described_class.new(current_node_id: secondary.id) } subject { described_class.new(current_node_id: secondary.id) }
describe '#count_syncable' do describe '#registry_count' do
it 'counts registries for uploads' do it 'counts registries for uploads' do
create(:geo_upload_registry, :attachment, :failed, file_id: upload_1.id) create(:geo_upload_registry, :attachment, :failed, file_id: upload_1.id)
create(:geo_upload_registry, :attachment, file_id: upload_2.id, missing_on_primary: true) create(:geo_upload_registry, :attachment, file_id: upload_2.id, missing_on_primary: true)
...@@ -41,26 +41,11 @@ RSpec.describe Geo::AttachmentRegistryFinder, :geo do ...@@ -41,26 +41,11 @@ RSpec.describe Geo::AttachmentRegistryFinder, :geo do
create(:geo_upload_registry, :attachment, file_id: upload_7.id, missing_on_primary: true) create(:geo_upload_registry, :attachment, file_id: upload_7.id, missing_on_primary: true)
create(:geo_upload_registry, :attachment, :never_synced, file_id: upload_8.id) create(:geo_upload_registry, :attachment, :never_synced, file_id: upload_8.id)
expect(subject.count_syncable).to eq 8 expect(subject.registry_count).to eq 8
end end
end end
describe '#count_registry' do describe '#synced_count' do
it 'counts registries for uploads' do
create(:geo_upload_registry, :attachment, :failed, file_id: upload_1.id)
create(:geo_upload_registry, :attachment, file_id: upload_2.id, missing_on_primary: true)
create(:geo_upload_registry, :attachment, :never_synced, file_id: upload_3.id)
create(:geo_upload_registry, :attachment, :failed, file_id: upload_4.id)
create(:geo_upload_registry, :attachment, file_id: upload_5.id, missing_on_primary: true, retry_at: 1.day.ago)
create(:geo_upload_registry, :attachment, :failed, file_id: upload_6.id)
create(:geo_upload_registry, :attachment, file_id: upload_7.id, missing_on_primary: true)
create(:geo_upload_registry, :attachment, :never_synced, file_id: upload_8.id)
expect(subject.count_registry).to eq 8
end
end
describe '#count_synced' do
it 'counts registries that has been synced' do it 'counts registries that has been synced' do
create(:geo_upload_registry, :attachment, :failed, file_id: upload_1.id) create(:geo_upload_registry, :attachment, :failed, file_id: upload_1.id)
create(:geo_upload_registry, :attachment, file_id: upload_2.id, missing_on_primary: true) create(:geo_upload_registry, :attachment, file_id: upload_2.id, missing_on_primary: true)
...@@ -71,11 +56,11 @@ RSpec.describe Geo::AttachmentRegistryFinder, :geo do ...@@ -71,11 +56,11 @@ RSpec.describe Geo::AttachmentRegistryFinder, :geo do
create(:geo_upload_registry, :attachment, file_id: upload_7.id, missing_on_primary: true) create(:geo_upload_registry, :attachment, file_id: upload_7.id, missing_on_primary: true)
create(:geo_upload_registry, :attachment, :never_synced, file_id: upload_8.id) create(:geo_upload_registry, :attachment, :never_synced, file_id: upload_8.id)
expect(subject.count_synced).to eq 3 expect(subject.synced_count).to eq 3
end end
end end
describe '#count_failed' do describe '#failed_count' do
it 'counts registries that sync has failed' do it 'counts registries that sync has failed' do
create(:geo_upload_registry, :attachment, :failed, file_id: upload_1.id) create(:geo_upload_registry, :attachment, :failed, file_id: upload_1.id)
create(:geo_upload_registry, :attachment, file_id: upload_2.id, missing_on_primary: true) create(:geo_upload_registry, :attachment, file_id: upload_2.id, missing_on_primary: true)
...@@ -86,7 +71,7 @@ RSpec.describe Geo::AttachmentRegistryFinder, :geo do ...@@ -86,7 +71,7 @@ RSpec.describe Geo::AttachmentRegistryFinder, :geo do
create(:geo_upload_registry, :attachment, file_id: upload_7.id, missing_on_primary: true) create(:geo_upload_registry, :attachment, file_id: upload_7.id, missing_on_primary: true)
create(:geo_upload_registry, :attachment, :never_synced, file_id: upload_8.id) create(:geo_upload_registry, :attachment, :never_synced, file_id: upload_8.id)
expect(subject.count_failed).to eq 3 expect(subject.failed_count).to eq 3
end end
end end
......
...@@ -24,36 +24,30 @@ RSpec.describe Geo::ContainerRepositoryRegistryFinder, :geo do ...@@ -24,36 +24,30 @@ RSpec.describe Geo::ContainerRepositoryRegistryFinder, :geo do
stub_registry_replication_config(enabled: true) stub_registry_replication_config(enabled: true)
end end
describe '#count_syncable' do describe '#registry_count' do
it 'returns number of container repositories' do it 'returns number of container registries' do
expect(subject.count_syncable).to eq(6)
end
end
describe '#count_synced' do
it 'returns only synced registry' do
create(:container_repository_registry, :synced, container_repository_id: container_repository_1.id) create(:container_repository_registry, :synced, container_repository_id: container_repository_1.id)
create(:container_repository_registry, :sync_failed, container_repository_id: container_repository_3.id) create(:container_repository_registry, :sync_failed, container_repository_id: container_repository_3.id)
expect(subject.count_synced).to eq(1) expect(subject.registry_count).to eq(2)
end end
end end
describe '#count_failed' do describe '#synced_count' do
it 'returns only failed registry' do it 'returns only synced registry' do
create(:container_repository_registry, :synced, container_repository_id: container_repository_1.id) create(:container_repository_registry, :synced, container_repository_id: container_repository_1.id)
create(:container_repository_registry, :sync_failed, container_repository_id: container_repository_3.id) create(:container_repository_registry, :sync_failed, container_repository_id: container_repository_3.id)
expect(subject.count_failed).to eq(1) expect(subject.synced_count).to eq(1)
end end
end end
describe '#count_registry' do describe '#failed_count' do
it 'returns number of all registries' do it 'returns only failed registry' do
create(:container_repository_registry, :synced, container_repository_id: container_repository_1.id) create(:container_repository_registry, :synced, container_repository_id: container_repository_1.id)
create(:container_repository_registry, :sync_failed, container_repository_id: container_repository_3.id) create(:container_repository_registry, :sync_failed, container_repository_id: container_repository_3.id)
expect(subject.count_registry).to eq(2) expect(subject.failed_count).to eq(1)
end end
end end
......
...@@ -21,42 +21,30 @@ RSpec.describe Geo::DesignRegistryFinder, :geo do ...@@ -21,42 +21,30 @@ RSpec.describe Geo::DesignRegistryFinder, :geo do
stub_current_geo_node(secondary) stub_current_geo_node(secondary)
end end
describe '#count_syncable' do describe '#registry_count' do
it 'returns number of designs' do it 'returns number of desgin registries' do
# Two designs for the same project to assert absence of duplicates
create_list(:design, 2, project: project_1)
create(:design, project: project_2)
result = subject.count_syncable
expect(result).to eq(2)
end
end
describe '#count_synced' do
it 'returns number of synced registries' do
create(:geo_design_registry, :synced, project_id: project_1.id) create(:geo_design_registry, :synced, project_id: project_1.id)
create(:geo_design_registry, :sync_failed, project_id: project_2.id) create(:geo_design_registry, :sync_failed, project_id: project_2.id)
expect(subject.count_synced).to eq(1) expect(subject.registry_count).to eq(2)
end end
end end
describe '#count_failed' do describe '#synced_count' do
it 'returns number of failed registries' do it 'returns number of synced registries' do
create(:geo_design_registry, :synced, project_id: project_1.id) create(:geo_design_registry, :synced, project_id: project_1.id)
create(:geo_design_registry, :sync_failed, project_id: project_2.id) create(:geo_design_registry, :sync_failed, project_id: project_2.id)
expect(subject.count_failed).to eq(1) expect(subject.synced_count).to eq(1)
end end
end end
describe '#count_registry' do describe '#failed_count' do
it 'returns number of all registries' do it 'returns number of failed registries' do
create(:geo_design_registry, :synced, project_id: project_1.id) create(:geo_design_registry, :synced, project_id: project_1.id)
create(:geo_design_registry, :sync_failed, project_id: project_2.id) create(:geo_design_registry, :sync_failed, project_id: project_2.id)
expect(subject.count_registry).to eq(2) expect(subject.failed_count).to eq(1)
end end
end end
......
...@@ -6,7 +6,7 @@ RSpec.describe Geo::FileRegistryFinder, :geo do ...@@ -6,7 +6,7 @@ RSpec.describe Geo::FileRegistryFinder, :geo do
context 'with abstract methods' do context 'with abstract methods' do
%w[ %w[
replicables replicables
syncable registry_class
].each do |required_method| ].each do |required_method|
it "requires subclasses to implement #{required_method}" do it "requires subclasses to implement #{required_method}" do
expect { subject.send(required_method) }.to raise_error(NotImplementedError) expect { subject.send(required_method) }.to raise_error(NotImplementedError)
......
...@@ -30,7 +30,7 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -30,7 +30,7 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
subject { described_class.new(current_node_id: secondary.id) } subject { described_class.new(current_node_id: secondary.id) }
describe '#count_syncable' do describe '#registry_count' do
it 'counts registries for job artifacts' do it 'counts registries for job artifacts' do
create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_1.id) create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_1.id)
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_2.id, missing_on_primary: true) create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_2.id, missing_on_primary: true)
...@@ -41,26 +41,11 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -41,26 +41,11 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_remote_2.id, missing_on_primary: true) create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_remote_2.id, missing_on_primary: true)
create(:geo_job_artifact_registry, :never_synced, artifact_id: ci_job_artifact_remote_3.id) create(:geo_job_artifact_registry, :never_synced, artifact_id: ci_job_artifact_remote_3.id)
expect(subject.count_syncable).to eq 8 expect(subject.registry_count).to eq 8
end end
end end
describe '#count_registry' do describe '#synced_count' do
it 'counts registries for job artifacts' do
create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_1.id)
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_2.id, missing_on_primary: true)
create(:geo_job_artifact_registry, :never_synced, artifact_id: ci_job_artifact_3.id)
create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_4.id)
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_5.id, missing_on_primary: true, retry_at: 1.day.ago)
create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_remote_1.id)
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_remote_2.id, missing_on_primary: true)
create(:geo_job_artifact_registry, :never_synced, artifact_id: ci_job_artifact_remote_3.id)
expect(subject.count_registry).to eq 8
end
end
describe '#count_synced' do
it 'counts registries that has been synced' do it 'counts registries that has been synced' do
create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_1.id) create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_1.id)
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_2.id, missing_on_primary: true) create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_2.id, missing_on_primary: true)
...@@ -71,11 +56,11 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -71,11 +56,11 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_remote_2.id, missing_on_primary: true) create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_remote_2.id, missing_on_primary: true)
create(:geo_job_artifact_registry, :never_synced, artifact_id: ci_job_artifact_remote_3.id) create(:geo_job_artifact_registry, :never_synced, artifact_id: ci_job_artifact_remote_3.id)
expect(subject.count_synced).to eq 3 expect(subject.synced_count).to eq 3
end end
end end
describe '#count_failed' do describe '#failed_count' do
it 'counts registries that sync has failed' do it 'counts registries that sync has failed' do
create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_1.id) create(:geo_job_artifact_registry, :failed, artifact_id: ci_job_artifact_1.id)
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_2.id, missing_on_primary: true) create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_2.id, missing_on_primary: true)
...@@ -86,7 +71,7 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do ...@@ -86,7 +71,7 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_remote_2.id, missing_on_primary: true) create(:geo_job_artifact_registry, artifact_id: ci_job_artifact_remote_2.id, missing_on_primary: true)
create(:geo_job_artifact_registry, :never_synced, artifact_id: ci_job_artifact_remote_3.id) create(:geo_job_artifact_registry, :never_synced, artifact_id: ci_job_artifact_remote_3.id)
expect(subject.count_failed).to eq 3 expect(subject.failed_count).to eq 3
end end
end end
......
...@@ -20,7 +20,7 @@ RSpec.describe Geo::LfsObjectRegistryFinder, :geo do ...@@ -20,7 +20,7 @@ RSpec.describe Geo::LfsObjectRegistryFinder, :geo do
subject { described_class.new(current_node_id: secondary.id) } subject { described_class.new(current_node_id: secondary.id) }
describe '#count_syncable' do describe '#registry_count' do
it 'counts registries for LFS objects' do it 'counts registries for LFS objects' do
create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_1.id) create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_1.id)
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_2.id, missing_on_primary: true) create(:geo_lfs_object_registry, lfs_object_id: lfs_object_2.id, missing_on_primary: true)
...@@ -31,26 +31,11 @@ RSpec.describe Geo::LfsObjectRegistryFinder, :geo do ...@@ -31,26 +31,11 @@ RSpec.describe Geo::LfsObjectRegistryFinder, :geo do
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_remote_2.id, missing_on_primary: true) create(:geo_lfs_object_registry, lfs_object_id: lfs_object_remote_2.id, missing_on_primary: true)
create(:geo_lfs_object_registry, :never_synced, lfs_object_id: lfs_object_remote_3.id) create(:geo_lfs_object_registry, :never_synced, lfs_object_id: lfs_object_remote_3.id)
expect(subject.count_syncable).to eq 8 expect(subject.registry_count).to eq 8
end end
end end
describe '#count_registry' do describe '#synced_count' do
it 'counts registries for LFS objects' do
create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_1.id)
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_2.id, missing_on_primary: true)
create(:geo_lfs_object_registry, :never_synced, lfs_object_id: lfs_object_3.id)
create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_4.id)
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_5.id, missing_on_primary: true, retry_at: 1.day.ago)
create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_remote_1.id)
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_remote_2.id, missing_on_primary: true)
create(:geo_lfs_object_registry, :never_synced, lfs_object_id: lfs_object_remote_3.id)
expect(subject.count_registry).to eq 8
end
end
describe '#count_synced' do
it 'counts registries that has been synced' do it 'counts registries that has been synced' do
create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_1.id) create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_1.id)
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_2.id, missing_on_primary: true) create(:geo_lfs_object_registry, lfs_object_id: lfs_object_2.id, missing_on_primary: true)
...@@ -61,11 +46,11 @@ RSpec.describe Geo::LfsObjectRegistryFinder, :geo do ...@@ -61,11 +46,11 @@ RSpec.describe Geo::LfsObjectRegistryFinder, :geo do
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_remote_2.id, missing_on_primary: true) create(:geo_lfs_object_registry, lfs_object_id: lfs_object_remote_2.id, missing_on_primary: true)
create(:geo_lfs_object_registry, :never_synced, lfs_object_id: lfs_object_remote_3.id) create(:geo_lfs_object_registry, :never_synced, lfs_object_id: lfs_object_remote_3.id)
expect(subject.count_synced).to eq 3 expect(subject.synced_count).to eq 3
end end
end end
describe '#count_failed' do describe '#failed_count' do
it 'counts registries that sync has failed' do it 'counts registries that sync has failed' do
create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_1.id) create(:geo_lfs_object_registry, :failed, lfs_object_id: lfs_object_1.id)
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_2.id, missing_on_primary: true) create(:geo_lfs_object_registry, lfs_object_id: lfs_object_2.id, missing_on_primary: true)
...@@ -76,7 +61,7 @@ RSpec.describe Geo::LfsObjectRegistryFinder, :geo do ...@@ -76,7 +61,7 @@ RSpec.describe Geo::LfsObjectRegistryFinder, :geo do
create(:geo_lfs_object_registry, lfs_object_id: lfs_object_remote_2.id, missing_on_primary: true) create(:geo_lfs_object_registry, lfs_object_id: lfs_object_remote_2.id, missing_on_primary: true)
create(:geo_lfs_object_registry, :never_synced, lfs_object_id: lfs_object_remote_3.id) create(:geo_lfs_object_registry, :never_synced, lfs_object_id: lfs_object_remote_3.id)
expect(subject.count_failed).to eq 3 expect(subject.failed_count).to eq 3
end end
end end
......
...@@ -117,9 +117,20 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -117,9 +117,20 @@ RSpec.describe GeoNodeStatus, :geo do
end end
describe '#projects_count' do describe '#projects_count' do
it 'counts the number of projects' do it 'counts the number of projects on a primary node' do
stub_current_geo_node(primary)
expect(subject.projects_count).to eq 4 expect(subject.projects_count).to eq 4
end end
it 'counts the number of projects on a secondary node' do
stub_current_geo_node(secondary)
create(:geo_project_registry, :synced, project: project_1)
create(:geo_project_registry, project: project_3)
expect(subject.projects_count).to eq 2
end
end end
describe '#attachments_synced_count' do describe '#attachments_synced_count' do
...@@ -374,18 +385,14 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -374,18 +385,14 @@ RSpec.describe GeoNodeStatus, :geo do
expect(subject.repositories_synced_in_percentage).to eq(0) expect(subject.repositories_synced_in_percentage).to eq(0)
end end
it 'returns the right percentage with no group restrictions' do it 'returns the right percentage' do
create(:geo_project_registry, :synced, project: project_1) create(:geo_project_registry, :synced, project: project_1)
create(:geo_project_registry, project: project_2)
create(:geo_project_registry, project: project_3)
create(:geo_project_registry, project: project_4)
expect(subject.repositories_synced_in_percentage).to be_within(0.0001).of(25) expect(subject.repositories_synced_in_percentage).to be_within(0.0001).of(25)
end end
it 'returns the right percentage with group restrictions' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [group])
create(:geo_project_registry, :synced, project: project_1)
expect(subject.repositories_synced_in_percentage).to be_within(0.0001).of(50)
end
end end
describe '#wikis_synced_in_percentage' do describe '#wikis_synced_in_percentage' do
...@@ -399,18 +406,14 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -399,18 +406,14 @@ RSpec.describe GeoNodeStatus, :geo do
expect(subject.wikis_synced_in_percentage).to eq(0) expect(subject.wikis_synced_in_percentage).to eq(0)
end end
it 'returns the right percentage with no group restrictions' do it 'returns the right percentage' do
create(:geo_project_registry, :synced, project: project_1) create(:geo_project_registry, :synced, project: project_1)
create(:geo_project_registry, project: project_2)
create(:geo_project_registry, project: project_3)
create(:geo_project_registry, project: project_4)
expect(subject.wikis_synced_in_percentage).to be_within(0.0001).of(25) expect(subject.wikis_synced_in_percentage).to be_within(0.0001).of(25)
end end
it 'returns the right percentage with group restrictions' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [group])
create(:geo_project_registry, :synced, project: project_1)
expect(subject.wikis_synced_in_percentage).to be_within(0.0001).of(50)
end
end end
describe '#replication_slots_used_count' do describe '#replication_slots_used_count' do
...@@ -583,16 +586,18 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -583,16 +586,18 @@ RSpec.describe GeoNodeStatus, :geo do
end end
describe '#container_repositories_count' do describe '#container_repositories_count' do
let!(:container_1) { create(:container_repository) } let!(:container_1) { create(:container_repository_registry, :synced) }
let!(:container_2) { create(:container_repository) } let!(:container_2) { create(:container_repository_registry, :sync_failed) }
let!(:container_3) { create(:container_repository_registry, :sync_failed) }
let!(:container_4) { create(:container_repository) }
context 'when container repositories replication is active' do context 'when container repositories replication is active' do
before do before do
stub_geo_setting(registry_replication: { enabled: true }) stub_geo_setting(registry_replication: { enabled: true })
end end
it 'counts all the repositories' do it 'counts number of registries for repositories' do
expect(subject.container_repositories_count).to eq(2) expect(subject.container_repositories_count).to eq(3)
end end
end end
...@@ -687,10 +692,6 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -687,10 +692,6 @@ RSpec.describe GeoNodeStatus, :geo do
end end
describe '#container_repositories_synced_in_percentage' do describe '#container_repositories_synced_in_percentage' do
let!(:container_repository_1) { create(:container_repository, project: project_1) }
let!(:container_repository_2) { create(:container_repository, project: project_1) }
let!(:container_list) { create_list(:container_repository, 2, project: project_3) }
context 'when container repositories replication is active' do context 'when container repositories replication is active' do
before do before do
stub_geo_setting(registry_replication: { enabled: true }) stub_geo_setting(registry_replication: { enabled: true })
...@@ -700,34 +701,32 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -700,34 +701,32 @@ RSpec.describe GeoNodeStatus, :geo do
expect(subject.container_repositories_synced_in_percentage).to eq(0) expect(subject.container_repositories_synced_in_percentage).to eq(0)
end end
it 'returns the right percentage with no group restrictions' do it 'returns the right percentage' do
create(:container_repository_registry, :synced, container_repository: container_repository_1) create(:container_repository_registry, :synced)
create(:container_repository_registry)
create(:container_repository_registry)
create(:container_repository_registry)
expect(subject.container_repositories_synced_in_percentage).to be_within(0.0001).of(25) expect(subject.container_repositories_synced_in_percentage).to be_within(0.0001).of(25)
end end
it 'returns the right percentage with group restrictions' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [group])
create(:container_repository_registry, :synced, container_repository: container_repository_1)
expect(subject.container_repositories_synced_in_percentage).to be_within(0.0001).of(50)
end
end end
it 'when container repositories replication is inactive returns 0' do it 'when container repositories replication is inactive returns 0' do
stub_geo_setting(registry_replication: { enabled: false }) stub_geo_setting(registry_replication: { enabled: false })
create(:container_repository_registry, :synced, container_repository: container_repository_1)
create(:container_repository_registry, :synced)
expect(subject.container_repositories_synced_in_percentage).to eq(0) expect(subject.container_repositories_synced_in_percentage).to eq(0)
end end
end end
describe '#design_repositories_count' do describe '#design_repositories_count' do
it 'counts all the designs' do it 'counts number of registries for repositories' do
create(:design) create(:geo_design_registry, :sync_failed)
create(:design) create(:geo_design_registry)
create(:geo_design_registry, :synced)
expect(subject.design_repositories_count).to eq(2) expect(subject.design_repositories_count).to eq(3)
end end
end end
...@@ -764,23 +763,12 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -764,23 +763,12 @@ RSpec.describe GeoNodeStatus, :geo do
expect(subject.design_repositories_synced_in_percentage).to eq(0) expect(subject.design_repositories_synced_in_percentage).to eq(0)
end end
it 'returns the right percentage with no group restrictions' do it 'returns the right percentage' do
create(:geo_design_registry, :synced) create(:geo_design_registry, :synced)
create(:geo_design_registry, :sync_failed) create(:geo_design_registry, :sync_failed)
expect(subject.design_repositories_synced_in_percentage).to be_within(0.0001).of(50) expect(subject.design_repositories_synced_in_percentage).to be_within(0.0001).of(50)
end end
it 'returns the right percentage with group restrictions' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [group])
create(:geo_design_registry, :synced, project: project_1)
create(:geo_design_registry, :sync_failed, project: project_2)
create(:geo_design_registry, :sync_failed, project: project_3)
create(:geo_design_registry, :sync_failed, project: project_4)
expect(subject.design_repositories_synced_in_percentage).to be_within(0.0001).of(50)
end
end end
describe '#repositories_verified_count' do describe '#repositories_verified_count' do
...@@ -1006,7 +994,9 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -1006,7 +994,9 @@ RSpec.describe GeoNodeStatus, :geo do
describe '#[]' do describe '#[]' do
it 'returns values for each attribute' do it 'returns values for each attribute' do
expect(subject[:projects_count]).to eq(4) create(:geo_project_registry, project: project_1)
expect(subject[:projects_count]).to eq(1)
expect(subject[:repositories_synced_count]).to eq(0) expect(subject[:repositories_synced_count]).to eq(0)
end end
...@@ -1243,40 +1233,40 @@ RSpec.describe GeoNodeStatus, :geo do ...@@ -1243,40 +1233,40 @@ RSpec.describe GeoNodeStatus, :geo do
stub_current_geo_node(primary) stub_current_geo_node(primary)
end end
it 'does not call LfsObjectRegistryFinder#count_syncable' do it 'does not call LfsObjectRegistryFinder#registry_count' do
expect_any_instance_of(Geo::LfsObjectRegistryFinder).not_to receive(:count_syncable) expect_any_instance_of(Geo::LfsObjectRegistryFinder).not_to receive(:registry_count)
subject subject
end end
it 'does not call AttachmentRegistryFinder#count_syncable' do it 'does not call AttachmentRegistryFinder#registry_count' do
expect_any_instance_of(Geo::AttachmentRegistryFinder).not_to receive(:count_syncable) expect_any_instance_of(Geo::AttachmentRegistryFinder).not_to receive(:registry_count)
subject subject
end end
it 'does not call JobArtifactRegistryFinder#count_syncable' do it 'does not call JobArtifactRegistryFinder#registry_count' do
expect_any_instance_of(Geo::JobArtifactRegistryFinder).not_to receive(:count_syncable) expect_any_instance_of(Geo::JobArtifactRegistryFinder).not_to receive(:registry_count)
subject subject
end end
end end
context 'on the secondary' do context 'on the secondary' do
it 'calls LfsObjectRegistryFinder#count_syncable' do it 'calls LfsObjectRegistryFinder#registry_count' do
expect_any_instance_of(Geo::LfsObjectRegistryFinder).to receive(:count_syncable) expect_any_instance_of(Geo::LfsObjectRegistryFinder).to receive(:registry_count).twice
subject subject
end end
it 'calls AttachmentRegistryFinder#count_syncable' do it 'calls AttachmentRegistryFinder#registry_count' do
expect_any_instance_of(Geo::AttachmentRegistryFinder).to receive(:count_syncable) expect_any_instance_of(Geo::AttachmentRegistryFinder).to receive(:registry_count).twice
subject subject
end end
it 'calls JobArtifactRegistryFinder#count_syncable' do it 'calls JobArtifactRegistryFinder#registry_count' do
expect_any_instance_of(Geo::JobArtifactRegistryFinder).to receive(:count_syncable) expect_any_instance_of(Geo::JobArtifactRegistryFinder).to receive(:registry_count).twice
subject subject
end end
......
...@@ -3,12 +3,11 @@ ...@@ -3,12 +3,11 @@
RSpec.shared_examples 'a file registry finder' do RSpec.shared_examples 'a file registry finder' do
it 'responds to file registry finder methods' do it 'responds to file registry finder methods' do
file_registry_finder_methods = %i{ file_registry_finder_methods = %i{
syncable registry_class
count_syncable registry_count
count_synced synced_count
count_failed failed_count
count_synced_missing_on_primary count_synced_missing_on_primary
count_registry
find_retryable_failed_registries find_retryable_failed_registries
find_retryable_synced_missing_on_primary_registries find_retryable_synced_missing_on_primary_registries
} }
......
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