Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
41f48dbb
Commit
41f48dbb
authored
Jun 11, 2019
by
Douglas Barbosa Alexandre
Committed by
Ash McKenzie
Jun 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Geo::ProjectRegistryFinder class
parent
0adc0efe
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
448 deletions
+103
-448
ee/app/finders/geo/project_registry_finder.rb
ee/app/finders/geo/project_registry_finder.rb
+0
-125
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+47
-16
ee/app/workers/geo/repository_shard_sync_worker.rb
ee/app/workers/geo/repository_shard_sync_worker.rb
+14
-6
ee/app/workers/geo/repository_verification/secondary/shard_worker.rb
...ers/geo/repository_verification/secondary/shard_worker.rb
+4
-8
ee/lib/api/geo_nodes.rb
ee/lib/api/geo_nodes.rb
+15
-18
ee/spec/finders/geo/project_registry_finder_spec.rb
ee/spec/finders/geo/project_registry_finder_spec.rb
+0
-245
ee/spec/models/geo_node_status_spec.rb
ee/spec/models/geo_node_status_spec.rb
+6
-12
ee/spec/workers/geo/repository_verification/secondary/shard_worker_spec.rb
...eo/repository_verification/secondary/shard_worker_spec.rb
+17
-18
No files found.
ee/app/finders/geo/project_registry_finder.rb
deleted
100644 → 0
View file @
0adc0efe
# frozen_string_literal: true
module
Geo
class
ProjectRegistryFinder
<
RegistryFinder
def
count_projects
current_node
.
projects
.
count
end
def
count_synced_repositories
registries_for_synced_projects
(
:repository
).
count
end
def
count_synced_wikis
registries_for_synced_projects
(
:wiki
).
count
end
def
count_failed_repositories
registries_for_failed_projects
(
:repository
).
count
end
def
count_failed_wikis
registries_for_failed_projects
(
:wiki
).
count
end
def
find_failed_project_registries
(
type
=
nil
)
registries_for_failed_projects
(
type
)
end
def
count_verified_repositories
registries_for_verified_projects
(
:repository
).
count
end
def
count_verified_wikis
registries_for_verified_projects
(
:wiki
).
count
end
def
count_verification_failed_repositories
registries_for_verification_failed_projects
(
:repository
).
count
end
def
count_verification_failed_wikis
registries_for_verification_failed_projects
(
:wiki
).
count
end
def
find_verification_failed_project_registries
(
type
=
nil
)
registries_for_verification_failed_projects
(
type
)
end
def
count_repositories_checksum_mismatch
registries_for_mismatch_projects
(
:repository
).
count
end
def
count_wikis_checksum_mismatch
registries_for_mismatch_projects
(
:wiki
).
count
end
def
find_checksum_mismatch_project_registries
(
type
=
nil
)
registries_for_mismatch_projects
(
type
)
end
def
count_repositories_retrying_verification
registries_retrying_verification
(
:repository
).
count
end
def
count_wikis_retrying_verification
registries_retrying_verification
(
:wiki
).
count
end
def
find_registries_to_verify
(
shard_name
:,
batch_size
:)
Geo
::
ProjectRegistryPendingVerificationFinder
.
new
(
current_node:
current_node
,
shard_name:
shard_name
,
batch_size:
batch_size
)
.
execute
end
def
find_unsynced_projects
(
shard_name
:,
batch_size
:)
Geo
::
ProjectUnsyncedFinder
.
new
(
current_node:
current_node
,
shard_name:
shard_name
,
batch_size:
batch_size
)
.
execute
end
def
find_projects_updated_recently
(
shard_name
:,
batch_size
:)
Geo
::
ProjectUpdatedRecentlyFinder
.
new
(
current_node:
current_node
,
shard_name:
shard_name
,
batch_size:
batch_size
)
.
execute
end
private
def
registries_for_synced_projects
(
type
)
Geo
::
ProjectRegistrySyncedFinder
.
new
(
current_node:
current_node
,
type:
type
)
.
execute
end
def
registries_for_failed_projects
(
type
)
Geo
::
ProjectRegistrySyncFailedFinder
.
new
(
current_node:
current_node
,
type:
type
)
.
execute
end
def
registries_for_verified_projects
(
type
)
Geo
::
ProjectRegistryVerifiedFinder
.
new
(
current_node:
current_node
,
type:
type
)
.
execute
end
def
registries_for_verification_failed_projects
(
type
)
Geo
::
ProjectRegistryVerificationFailedFinder
.
new
(
current_node:
current_node
,
type:
type
)
.
execute
end
def
registries_retrying_verification
(
type
)
Geo
::
ProjectRegistryRetryingVerificationFinder
.
new
(
current_node:
current_node
,
type:
type
)
.
execute
end
def
registries_for_mismatch_projects
(
type
)
Geo
::
ProjectRegistryMismatchFinder
.
new
(
current_node:
current_node
,
type:
type
)
.
execute
end
end
end
ee/app/models/geo_node_status.rb
View file @
41f48dbb
...
...
@@ -173,6 +173,7 @@ class GeoNodeStatus < ApplicationRecord
self
.
job_artifact_deleted_max_id
=
Geo
::
JobArtifactDeletedEvent
.
maximum
(
:id
)
self
.
hashed_storage_migrated_max_id
=
Geo
::
HashedStorageMigratedEvent
.
maximum
(
:id
)
self
.
hashed_storage_attachments_max_id
=
Geo
::
HashedStorageAttachmentsEvent
.
maximum
(
:id
)
self
.
projects_count
=
geo_node
.
projects
.
count
load_primary_data
load_secondary_data
...
...
@@ -182,7 +183,6 @@ class GeoNodeStatus < ApplicationRecord
def
load_primary_data
if
Gitlab
::
Geo
.
primary?
self
.
projects_count
=
geo_node
.
projects
.
count
self
.
lfs_objects_count
=
LfsObject
.
syncable
.
count
self
.
job_artifacts_count
=
Ci
::
JobArtifact
.
syncable
.
count
self
.
attachments_count
=
Upload
.
syncable
.
count
...
...
@@ -208,11 +208,10 @@ class GeoNodeStatus < ApplicationRecord
self
.
db_replication_lag_seconds
=
Gitlab
::
Geo
::
HealthCheck
.
new
.
db_replication_lag_seconds
self
.
cursor_last_event_id
=
current_cursor_last_event_id
self
.
cursor_last_event_date
=
Geo
::
EventLog
.
find_by
(
id:
self
.
cursor_last_event_id
)
&
.
created_at
self
.
projects_count
=
projects_finder
.
count_projects
self
.
repositories_synced_count
=
projects_finder
.
count_synced_repositories
self
.
repositories_failed_count
=
projects_finder
.
count_failed_repositories
self
.
wikis_synced_count
=
projects_finder
.
count_synced_wikis
self
.
wikis_failed_count
=
projects_finder
.
count_failed_wikis
self
.
repositories_synced_count
=
registries_for_synced_projects
(
:repository
).
count
self
.
repositories_failed_count
=
registries_for_failed_projects
(
:repository
).
count
self
.
wikis_synced_count
=
registries_for_synced_projects
(
:wiki
).
count
self
.
wikis_failed_count
=
registries_for_failed_projects
(
:wiki
).
count
self
.
lfs_objects_count
=
lfs_objects_finder
.
count_syncable
self
.
lfs_objects_synced_count
=
lfs_objects_finder
.
count_synced
self
.
lfs_objects_failed_count
=
lfs_objects_finder
.
count_failed
...
...
@@ -238,14 +237,14 @@ class GeoNodeStatus < ApplicationRecord
def
load_verification_data
if
repository_verification_enabled
self
.
repositories_verified_count
=
projects_finder
.
count_verified_repositories
self
.
repositories_verification_failed_count
=
projects_finder
.
count_verification_failed_repositories
self
.
repositories_checksum_mismatch_count
=
projects_finder
.
count_repositories_checksum_mismatch
self
.
wikis_verified_count
=
projects_finder
.
count_verified_wikis
self
.
wikis_verification_failed_count
=
projects_finder
.
count_verification_failed_wikis
self
.
wikis_checksum_mismatch_count
=
projects_finder
.
count_wikis_checksum_mismatch
self
.
repositories_retrying_verification_count
=
projects_finder
.
count_repositories_retrying_verification
self
.
wikis_retrying_verification_count
=
projects_finder
.
count_wikis_retrying_verification
self
.
repositories_verified_count
=
registries_for_verified_projects
(
:repository
).
count
self
.
repositories_verification_failed_count
=
registries_for_verification_failed_projects
(
:repository
).
count
self
.
repositories_checksum_mismatch_count
=
registries_for_mismatch_projects
(
:repository
).
count
self
.
wikis_verified_count
=
registries_for_verified_projects
(
:wiki
).
count
self
.
wikis_verification_failed_count
=
registries_for_verification_failed_projects
(
:wiki
).
count
self
.
wikis_checksum_mismatch_count
=
registries_for_mismatch_projects
(
:wiki
).
count
self
.
repositories_retrying_verification_count
=
registries_retrying_verification
(
:repository
).
count
self
.
wikis_retrying_verification_count
=
registries_retrying_verification
(
:wiki
).
count
end
end
...
...
@@ -381,8 +380,40 @@ class GeoNodeStatus < ApplicationRecord
@job_artifacts_finder
||=
Geo
::
JobArtifactRegistryFinder
.
new
(
current_node:
geo_node
)
end
def
projects_finder
@projects_finder
||=
Geo
::
ProjectRegistryFinder
.
new
(
current_node:
geo_node
)
def
registries_for_synced_projects
(
type
)
Geo
::
ProjectRegistrySyncedFinder
.
new
(
current_node:
geo_node
,
type:
type
)
.
execute
end
def
registries_for_failed_projects
(
type
)
Geo
::
ProjectRegistrySyncFailedFinder
.
new
(
current_node:
geo_node
,
type:
type
)
.
execute
end
def
registries_for_verified_projects
(
type
)
Geo
::
ProjectRegistryVerifiedFinder
.
new
(
current_node:
geo_node
,
type:
type
)
.
execute
end
def
registries_for_verification_failed_projects
(
type
)
Geo
::
ProjectRegistryVerificationFailedFinder
.
new
(
current_node:
geo_node
,
type:
type
)
.
execute
end
def
registries_for_mismatch_projects
(
type
)
Geo
::
ProjectRegistryMismatchFinder
.
new
(
current_node:
geo_node
,
type:
type
)
.
execute
end
def
registries_retrying_verification
(
type
)
Geo
::
ProjectRegistryRetryingVerificationFinder
.
new
(
current_node:
geo_node
,
type:
type
)
.
execute
end
def
repository_verification_finder
...
...
ee/app/workers/geo/repository_shard_sync_worker.rb
View file @
41f48dbb
...
...
@@ -60,10 +60,6 @@ module Geo
scheduled_jobs
.
map
{
|
data
|
data
[
:project_id
]
}
end
def
finder
@finder
||=
ProjectRegistryFinder
.
new
(
current_node:
current_node
)
end
def
load_pending_resources
resources
=
find_project_ids_not_synced
(
batch_size:
db_retrieve_batch_size
)
remaining_capacity
=
db_retrieve_batch_size
-
resources
.
size
...
...
@@ -77,20 +73,32 @@ module Geo
# rubocop: disable CodeReuse/ActiveRecord
def
find_project_ids_not_synced
(
batch_size
:)
find
er
.
find_unsynced_projects
(
shard_name:
shard_name
,
batch_size:
batch_size
)
find
_unsynced_projects
(
batch_size:
batch_size
)
.
id_not_in
(
scheduled_project_ids
)
.
reorder
(
last_repository_updated_at: :desc
)
.
pluck_primary_key
end
# rubocop: enable CodeReuse/ActiveRecord
def
find_unsynced_projects
(
batch_size
:)
Geo
::
ProjectUnsyncedFinder
.
new
(
current_node:
current_node
,
shard_name:
shard_name
,
batch_size:
batch_size
)
.
execute
end
# rubocop: disable CodeReuse/ActiveRecord
def
find_project_ids_updated_recently
(
batch_size
:)
find
er
.
find_projects_updated_recently
(
shard_name:
shard_name
,
batch_size:
batch_size
)
find
_projects_updated_recently
(
batch_size:
batch_size
)
.
id_not_in
(
scheduled_project_ids
)
.
order
(
'project_registry.last_repository_synced_at ASC NULLS FIRST, projects.last_repository_updated_at ASC'
)
.
pluck_primary_key
end
# rubocop: enable CodeReuse/ActiveRecord
def
find_projects_updated_recently
(
batch_size
:)
Geo
::
ProjectUpdatedRecentlyFinder
.
new
(
current_node:
current_node
,
shard_name:
shard_name
,
batch_size:
batch_size
)
.
execute
end
end
end
ee/app/workers/geo/repository_verification/secondary/shard_worker.rb
View file @
41f48dbb
...
...
@@ -33,22 +33,18 @@ module Geo
current_node
.
verification_max_capacity
end
# rubocop: disable CodeReuse/ActiveRecord
def
load_pending_resources
finder
.
find_registries_to_verify
(
shard_name:
shard_name
,
batch_size:
db_retrieve_batch_size
)
.
pluck
(
:id
)
Geo
::
ProjectRegistryPendingVerificationFinder
.
new
(
current_node:
current_node
,
shard_name:
shard_name
,
batch_size:
db_retrieve_batch_size
)
.
execute
.
pluck_primary_key
end
# rubocop: enable CodeReuse/ActiveRecord
def
schedule_job
(
registry_id
)
job_id
=
Geo
::
RepositoryVerification
::
Secondary
::
SingleWorker
.
perform_async
(
registry_id
)
{
id:
registry_id
,
job_id:
job_id
}
if
job_id
end
def
finder
@finder
||=
Geo
::
ProjectRegistryFinder
.
new
(
current_node:
current_node
)
end
end
end
end
...
...
ee/lib/api/geo_nodes.rb
View file @
41f48dbb
...
...
@@ -49,24 +49,21 @@ module API
use
:pagination
end
get
'/current/failures'
do
geo_node
=
Gitlab
::
Geo
.
current_node
forbidden!
(
'Failures can only be requested from a secondary node'
)
unless
geo_node
.
secondary?
not_found!
(
'Geo node not found'
)
unless
geo_node
finder
=
::
Geo
::
ProjectRegistryFinder
.
new
(
current_node:
geo_node
)
project_registries
=
case
params
[
:failure_type
]
when
'sync'
finder
.
find_failed_project_registries
(
params
[
:type
])
when
'verification'
finder
.
find_verification_failed_project_registries
(
params
[
:type
])
when
'checksum_mismatch'
finder
.
find_checksum_mismatch_project_registries
(
params
[
:type
])
else
not_found!
(
'Failure type unknown'
)
end
not_found!
(
'Geo node not found'
)
unless
Gitlab
::
Geo
.
current_node
forbidden!
(
'Failures can only be requested from a secondary node'
)
unless
Gitlab
::
Geo
.
current_node
.
secondary?
finder_klass
=
case
params
[
:failure_type
]
when
'sync'
::
Geo
::
ProjectRegistrySyncFailedFinder
when
'verification'
::
Geo
::
ProjectRegistryVerificationFailedFinder
when
'checksum_mismatch'
::
Geo
::
ProjectRegistryMismatchFinder
else
not_found!
(
'Failure type unknown'
)
end
project_registries
=
finder_klass
.
new
(
current_node:
Gitlab
::
Geo
.
current_node
,
type:
params
[
:type
]).
execute
present
paginate
(
project_registries
),
with:
::
GeoProjectRegistryEntity
end
...
...
ee/spec/finders/geo/project_registry_finder_spec.rb
deleted
100644 → 0
View file @
0adc0efe
require
'spec_helper'
describe
Geo
::
ProjectRegistryFinder
,
:geo
,
:geo_fdw
do
include
::
EE
::
GeoHelpers
# Using let() instead of set() because set() does not work properly when
# using the :delete DatabaseCleaner strategy, which is required for FDW
# tests because a foreign table can't see changes inside a transaction
# of a different connection.
let
(
:secondary
)
{
create
(
:geo_node
)
}
subject
{
described_class
.
new
(
current_node:
secondary
)
}
before
do
stub_current_geo_node
(
secondary
)
end
describe
'#count_synced_repositories'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistrySyncedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_synced_repositories
end
it
'returns an integer'
do
expect
(
subject
.
count_synced_repositories
).
to
be_a
(
Integer
)
end
end
describe
'#count_synced_wikis'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistrySyncedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_synced_wikis
end
it
'returns an integer'
do
expect
(
subject
.
count_synced_wikis
).
to
be_a
(
Integer
)
end
end
describe
'#count_failed_repositories'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistrySyncFailedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_failed_repositories
end
it
'returns an integer'
do
expect
(
subject
.
count_failed_repositories
).
to
be_a
(
Integer
)
end
end
describe
'#count_failed_wikis'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistrySyncFailedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_failed_wikis
end
it
'returns an integer'
do
expect
(
subject
.
count_failed_wikis
).
to
be_a
(
Integer
)
end
end
describe
'#count_verified_repositories'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryVerifiedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_verified_repositories
end
it
'returns an integer'
do
expect
(
subject
.
count_verified_repositories
).
to
be_a
(
Integer
)
end
end
describe
'#count_verified_wikis'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryVerifiedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_verified_wikis
end
it
'returns an integer'
do
expect
(
subject
.
count_verified_wikis
).
to
be_a
(
Integer
)
end
end
describe
'#count_verification_failed_repositories'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryVerificationFailedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_verification_failed_repositories
end
it
'returns an integer'
do
expect
(
subject
.
count_verification_failed_repositories
).
to
be_a
(
Integer
)
end
end
describe
'#count_verification_failed_wikis'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryVerificationFailedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_verification_failed_wikis
end
it
'returns an integer'
do
expect
(
subject
.
count_verification_failed_wikis
).
to
be_a
(
Integer
)
end
end
describe
'#count_repositories_retrying_verification'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryRetryingVerificationFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_repositories_retrying_verification
end
it
'returns an integer'
do
expect
(
subject
.
count_repositories_retrying_verification
).
to
be_a
(
Integer
)
end
end
describe
'#count_wikis_retrying_verification'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryRetryingVerificationFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_wikis_retrying_verification
end
it
'returns an integer'
do
expect
(
subject
.
count_wikis_retrying_verification
).
to
be_a
(
Integer
)
end
end
describe
'#count_repositories_checksum_mismatch'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryMismatchFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_repositories_checksum_mismatch
end
it
'returns an integer'
do
expect
(
subject
.
count_repositories_checksum_mismatch
).
to
be_a
(
Integer
)
end
end
describe
'#count_wikis_checksum_mismatch'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryMismatchFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
.
and_call_original
end
subject
.
count_wikis_checksum_mismatch
end
it
'returns an integer'
do
expect
(
subject
.
count_wikis_checksum_mismatch
).
to
be_a
(
Integer
)
end
end
describe
'#find_unsynced_projects'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectUnsyncedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_unsynced_projects
(
shard_name:
'default'
,
batch_size:
100
)
end
end
describe
'#find_projects_updated_recently'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectUpdatedRecentlyFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_projects_updated_recently
(
shard_name:
'default'
,
batch_size:
100
)
end
end
describe
'#find_failed_project_registries'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistrySyncFailedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_failed_project_registries
(
'repository'
)
end
end
describe
'#find_registries_to_verify'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryPendingVerificationFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_registries_to_verify
(
shard_name:
'default'
,
batch_size:
100
)
end
end
describe
'#find_verification_failed_project_registries'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryVerificationFailedFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_verification_failed_project_registries
(
'repository'
)
end
end
describe
'#find_checksum_mismatch_project_registries'
do
it
'delegates to the proper finder'
do
expect_next_instance_of
(
Geo
::
ProjectRegistryMismatchFinder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_checksum_mismatch_project_registries
(
'repository'
)
end
end
end
ee/spec/models/geo_node_status_spec.rb
View file @
41f48dbb
...
...
@@ -122,6 +122,12 @@ describe GeoNodeStatus, :geo, :geo_fdw do
end
end
describe
'#projects_count'
do
it
'counts the number of projects'
do
expect
(
subject
.
projects_count
).
to
eq
4
end
end
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'
))
...
...
@@ -997,12 +1003,6 @@ describe GeoNodeStatus, :geo, :geo_fdw do
stub_current_geo_node
(
primary
)
end
it
'does not call ProjectRegistryFinder#count_projects'
do
expect_any_instance_of
(
Geo
::
ProjectRegistryFinder
).
not_to
receive
(
:count_projects
)
subject
end
it
'does not call LfsObjectRegistryFinder#count_syncable'
do
expect_any_instance_of
(
Geo
::
LfsObjectRegistryFinder
).
not_to
receive
(
:count_syncable
)
...
...
@@ -1023,12 +1023,6 @@ describe GeoNodeStatus, :geo, :geo_fdw do
end
context
'on the secondary'
do
it
'calls ProjectRegistryFinder#count_projects'
do
expect_any_instance_of
(
Geo
::
ProjectRegistryFinder
).
to
receive
(
:count_projects
)
subject
end
it
'calls LfsObjectRegistryFinder#count_syncable'
do
expect_any_instance_of
(
Geo
::
AttachmentRegistryFinder
).
to
receive
(
:count_syncable
)
...
...
ee/spec/workers/geo/repository_verification/secondary/shard_worker_spec.rb
View file @
41f48dbb
require
'spec_helper'
describe
Geo
::
RepositoryVerification
::
Secondary
::
ShardWorker
,
:
postgresql
,
:clean_gitlab_redis_cache
do
describe
Geo
::
RepositoryVerification
::
Secondary
::
ShardWorker
,
:
geo
,
:geo_fdw
,
:clean_gitlab_redis_cache
do
include
::
EE
::
GeoHelpers
include
ExclusiveLeaseHelpers
let!
(
:secondary
)
{
create
(
:geo_node
)
}
let
(
:shard_name
)
{
Gitlab
.
config
.
repositories
.
storages
.
keys
.
first
}
let
(
:secondary_singleworker
)
{
Geo
::
RepositoryVerification
::
Secondary
::
SingleWorker
}
set
(
:project
)
{
create
(
:project
)
}
let
(
:secondary_single_worker
)
{
Geo
::
RepositoryVerification
::
Secondary
::
SingleWorker
}
let!
(
:project
)
{
create
(
:project
)
}
before
do
stub_current_geo_node
(
secondary
)
...
...
@@ -37,7 +36,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
create
(
:geo_project_registry
,
:synced
,
:repository_verification_outdated
,
project:
project
)
create
(
:geo_project_registry
,
:synced
,
:repository_verification_outdated
,
project:
other_project
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
twice
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
twice
subject
.
perform
(
shard_name
)
end
...
...
@@ -46,7 +45,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
create
(
:repository_state
,
:repository_verified
,
:wiki_verified
,
project:
project
)
missing_repository_verification
=
create
(
:geo_project_registry
,
:synced
,
:wiki_verified
,
project:
project
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
with
(
missing_repository_verification
.
id
)
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
with
(
missing_repository_verification
.
id
)
subject
.
perform
(
shard_name
)
end
...
...
@@ -55,7 +54,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
create
(
:repository_state
,
:repository_verified
,
:wiki_verified
,
project:
project
)
missing_wiki_verification
=
create
(
:geo_project_registry
,
:synced
,
:repository_verified
,
project:
project
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
with
(
missing_wiki_verification
.
id
)
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
with
(
missing_wiki_verification
.
id
)
subject
.
perform
(
shard_name
)
end
...
...
@@ -66,7 +65,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
create
(
:repository_state
,
:repository_verified
,
:wiki_verified
,
project:
project_other_shard
)
registry_other_shard
=
create
(
:geo_project_registry
,
:synced
,
:wiki_verified
,
project:
project_other_shard
)
expect
(
secondary_singleworker
).
not_to
receive
(
:perform_async
).
with
(
registry_other_shard
.
id
)
expect
(
secondary_single
_
worker
).
not_to
receive
(
:perform_async
).
with
(
registry_other_shard
.
id
)
subject
.
perform
(
shard_name
)
end
...
...
@@ -78,7 +77,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
create
(
:geo_project_registry
,
:synced
,
project:
project
,
repository_missing_on_primary:
true
)
create
(
:geo_project_registry
,
:synced
,
project:
other_project
,
wiki_missing_on_primary:
true
)
expect
(
secondary_singleworker
).
not_to
receive
(
:perform_async
)
expect
(
secondary_single
_
worker
).
not_to
receive
(
:perform_async
)
subject
.
perform
(
shard_name
)
end
...
...
@@ -101,13 +100,13 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
reg1
=
create
(
:geo_project_registry
,
:synced
,
:repository_verification_outdated
,
project:
project1_repo_verified
)
reg2
=
create
(
:geo_project_registry
,
:synced
,
:repository_verification_outdated
,
project:
project2_repo_verified
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
with
(
reg1
.
id
).
once
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
with
(
reg1
.
id
).
once
subject
.
perform
(
shard_name
)
reg1
.
update!
(
repository_verification_checksum_sha:
project1_repo_verified
.
repository_state
.
repository_verification_checksum
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
with
(
reg2
.
id
).
once
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
with
(
reg2
.
id
).
once
subject
.
perform
(
shard_name
)
end
...
...
@@ -120,25 +119,25 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
create
(
:geo_project_registry
,
:synced
,
:repository_verification_failed
,
:wiki_verification_failed
,
project:
project5_both_verified
)
reg6
=
create
(
:geo_project_registry
,
:synced
,
project:
project6_both_verified
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
with
(
reg1
.
id
).
once
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
with
(
reg1
.
id
).
once
subject
.
perform
(
shard_name
)
reg1
.
update!
(
repository_verification_checksum_sha:
project1_repo_verified
.
repository_state
.
repository_verification_checksum
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
with
(
reg2
.
id
).
once
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
with
(
reg2
.
id
).
once
subject
.
perform
(
shard_name
)
reg2
.
update!
(
repository_verification_checksum_sha:
project2_repo_verified
.
repository_state
.
repository_verification_checksum
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
with
(
reg4
.
id
).
once
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
with
(
reg4
.
id
).
once
subject
.
perform
(
shard_name
)
reg4
.
update!
(
last_wiki_verification_failure:
'Failed!'
)
expect
(
secondary_singleworker
).
to
receive
(
:perform_async
).
with
(
reg6
.
id
).
once
expect
(
secondary_single
_
worker
).
to
receive
(
:perform_async
).
with
(
reg6
.
id
).
once
subject
.
perform
(
shard_name
)
end
...
...
@@ -149,7 +148,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
Gitlab
::
ShardHealthCache
.
update
([])
expect
(
secondary_singleworker
).
not_to
receive
(
:perform_async
)
expect
(
secondary_single
_
worker
).
not_to
receive
(
:perform_async
)
subject
.
perform
(
shard_name
)
end
...
...
@@ -157,7 +156,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
it
'does not schedule jobs when no geo database is configured'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:geo_database_configured?
)
{
false
}
expect
(
secondary_singleworker
).
not_to
receive
(
:perform_async
)
expect
(
secondary_single
_
worker
).
not_to
receive
(
:perform_async
)
subject
.
perform
(
shard_name
)
...
...
@@ -169,7 +168,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
it
'does not schedule jobs when not running on a secondary'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
false
}
expect
(
secondary_singleworker
).
not_to
receive
(
:perform_async
)
expect
(
secondary_single
_
worker
).
not_to
receive
(
:perform_async
)
subject
.
perform
(
shard_name
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment