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
e7ed280e
Commit
e7ed280e
authored
Apr 01, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor spec for Geo::ProjectRegistryFinder
parent
74eae236
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
185 additions
and
221 deletions
+185
-221
ee/app/finders/geo/project_registry_finder.rb
ee/app/finders/geo/project_registry_finder.rb
+18
-14
ee/spec/finders/geo/project_registry_finder_spec.rb
ee/spec/finders/geo/project_registry_finder_spec.rb
+167
-207
No files found.
ee/app/finders/geo/project_registry_finder.rb
View file @
e7ed280e
...
@@ -163,12 +163,16 @@ module Geo
...
@@ -163,12 +163,16 @@ module Geo
private
private
def
fdw_disabled?
!
Gitlab
::
Geo
::
Fdw
.
enabled?
end
def
use_legacy_queries_for_selective_sync?
def
use_legacy_queries_for_selective_sync?
selective_sync?
&&
!
Gitlab
::
Geo
::
Fdw
.
enabled_for_selective_sync?
fdw_disabled?
||
selective_sync?
&&
!
Gitlab
::
Geo
::
Fdw
.
enabled_for_selective_sync?
end
end
def
finder_klass_for_synced_registries
def
finder_klass_for_synced_registries
if
!
Gitlab
::
Geo
::
Fdw
.
enabled?
||
use_legacy_queries_for_selective_sync?
if
use_legacy_queries_for_selective_sync?
Geo
::
LegacyProjectRegistrySyncedFinder
Geo
::
LegacyProjectRegistrySyncedFinder
else
else
Geo
::
ProjectRegistrySyncedFinder
Geo
::
ProjectRegistrySyncedFinder
...
@@ -182,7 +186,7 @@ module Geo
...
@@ -182,7 +186,7 @@ module Geo
end
end
def
finder_klass_for_failed_registries
def
finder_klass_for_failed_registries
if
!
Gitlab
::
Geo
::
Fdw
.
enabled?
||
use_legacy_queries_for_selective_sync?
if
use_legacy_queries_for_selective_sync?
Geo
::
LegacyProjectRegistrySyncFailedFinder
Geo
::
LegacyProjectRegistrySyncFailedFinder
else
else
Geo
::
ProjectRegistrySyncFailedFinder
Geo
::
ProjectRegistrySyncFailedFinder
...
@@ -196,7 +200,7 @@ module Geo
...
@@ -196,7 +200,7 @@ module Geo
end
end
def
finder_klass_for_verified_registries
def
finder_klass_for_verified_registries
if
!
Gitlab
::
Geo
::
Fdw
.
enabled?
||
use_legacy_queries_for_selective_sync?
if
use_legacy_queries_for_selective_sync?
Geo
::
LegacyProjectRegistryVerifiedFinder
Geo
::
LegacyProjectRegistryVerifiedFinder
else
else
Geo
::
ProjectRegistryVerifiedFinder
Geo
::
ProjectRegistryVerifiedFinder
...
@@ -210,10 +214,10 @@ module Geo
...
@@ -210,10 +214,10 @@ module Geo
end
end
def
finder_klass_for_verification_failed_registries
def
finder_klass_for_verification_failed_registries
if
Gitlab
::
Geo
::
Fdw
.
enabled_for_selective_sync?
if
use_legacy_queries_for_selective_sync?
Geo
::
ProjectRegistryVerificationFailedFinder
else
Geo
::
LegacyProjectRegistryVerificationFailedFinder
Geo
::
LegacyProjectRegistryVerificationFailedFinder
else
Geo
::
ProjectRegistryVerificationFailedFinder
end
end
end
end
...
@@ -224,10 +228,10 @@ module Geo
...
@@ -224,10 +228,10 @@ module Geo
end
end
def
finder_klass_for_registries_retrying_verification
def
finder_klass_for_registries_retrying_verification
if
Gitlab
::
Geo
::
Fdw
.
enabled_for_selective_sync?
if
use_legacy_queries_for_selective_sync?
Geo
::
ProjectRegistryRetryingVerificationFinder
else
Geo
::
LegacyProjectRegistryRetryingVerificationFinder
Geo
::
LegacyProjectRegistryRetryingVerificationFinder
else
Geo
::
ProjectRegistryRetryingVerificationFinder
end
end
end
end
...
@@ -238,10 +242,10 @@ module Geo
...
@@ -238,10 +242,10 @@ module Geo
end
end
def
finder_klass_for_mismatch_registries
def
finder_klass_for_mismatch_registries
if
Gitlab
::
Geo
::
Fdw
.
enabled_for_selective_sync?
if
use_legacy_queries_for_selective_sync?
Geo
::
ProjectRegistryMismatchFinder
else
Geo
::
LegacyProjectRegistryMismatchFinder
Geo
::
LegacyProjectRegistryMismatchFinder
else
Geo
::
ProjectRegistryMismatchFinder
end
end
end
end
...
@@ -252,7 +256,7 @@ module Geo
...
@@ -252,7 +256,7 @@ module Geo
end
end
def
finder_klass_for_registries_pending_verification
def
finder_klass_for_registries_pending_verification
if
!
Gitlab
::
Geo
::
Fdw
.
enabled?
||
use_legacy_queries_for_selective_sync?
if
use_legacy_queries_for_selective_sync?
Geo
::
LegacyProjectRegistryPendingVerificationFinder
Geo
::
LegacyProjectRegistryPendingVerificationFinder
else
else
Geo
::
ProjectRegistryPendingVerificationFinder
Geo
::
ProjectRegistryPendingVerificationFinder
...
...
ee/spec/finders/geo/project_registry_finder_spec.rb
View file @
e7ed280e
...
@@ -11,14 +11,11 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -11,14 +11,11 @@ describe Geo::ProjectRegistryFinder, :geo do
# different connection.
# different connection.
let
(
:secondary
)
{
create
(
:geo_node
)
}
let
(
:secondary
)
{
create
(
:geo_node
)
}
let
(
:synced_group
)
{
create
(
:group
)
}
let
(
:synced_group
)
{
create
(
:group
)
}
let!
(
:project_not_synced
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project_synced
)
{
create
(
:project
)
}
let
(
:project_1_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
let
(
:project_repository_dirty
)
{
create
(
:project
)
}
let
(
:project_2_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
let
(
:project_wiki_dirty
)
{
create
(
:project
)
}
let
(
:project_3_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
let
(
:project_repository_verified
)
{
create
(
:project
)
}
let
(
:project_4_broken_storage
)
{
create
(
:project
,
:broken_storage
)
}
let
(
:project_repository_verification_failed
)
{
create
(
:project
)
}
let
(
:project_wiki_verified
)
{
create
(
:project
)
}
let
(
:project_wiki_verification_failed
)
{
create
(
:project
)
}
subject
{
described_class
.
new
(
current_node:
secondary
)
}
subject
{
described_class
.
new
(
current_node:
secondary
)
}
...
@@ -29,12 +26,7 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -29,12 +26,7 @@ describe Geo::ProjectRegistryFinder, :geo do
shared_examples
'counts all the things'
do
|
method_prefix
|
shared_examples
'counts all the things'
do
|
method_prefix
|
describe
'#count_synced_repositories'
do
describe
'#count_synced_repositories'
do
before
do
before
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:synced
,
project:
project
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_3_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_4_broken_storage
=
create
(
:project
,
:broken_storage
)
create
(
:geo_project_registry
,
:synced
,
project:
project_synced
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3_in_synced_group
)
...
@@ -64,12 +56,7 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -64,12 +56,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe
'#count_synced_wikis'
do
describe
'#count_synced_wikis'
do
before
do
before
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:synced
,
project:
project
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_3_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_4_broken_storage
=
create
(
:project
,
:broken_storage
)
create
(
:geo_project_registry
,
:synced
,
project:
project_synced
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3_in_synced_group
)
...
@@ -99,12 +86,7 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -99,12 +86,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe
'#count_failed_repositories'
do
describe
'#count_failed_repositories'
do
before
do
before
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:synced
,
project:
project
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_3_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_4_broken_storage
=
create
(
:project
,
:broken_storage
)
create
(
:geo_project_registry
,
:synced
,
project:
project_synced
)
create
(
:geo_project_registry
,
:repository_sync_failed
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:repository_sync_failed
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_sync_failed
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_sync_failed
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3_in_synced_group
)
...
@@ -134,12 +116,7 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -134,12 +116,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe
'#count_failed_wikis'
do
describe
'#count_failed_wikis'
do
before
do
before
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:synced
,
project:
project
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_3_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_4_broken_storage
=
create
(
:project
,
:broken_storage
)
create
(
:geo_project_registry
,
:synced
,
project:
project_synced
)
create
(
:geo_project_registry
,
:wiki_sync_failed
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_sync_failed
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:repository_sync_failed
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:repository_sync_failed
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_3_in_synced_group
)
...
@@ -169,12 +146,7 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -169,12 +146,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe
'#count_verified_repositories'
do
describe
'#count_verified_repositories'
do
before
do
before
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:repository_verified
,
:wiki_verified
,
project:
project
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_3_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_4_broken_storage
=
create
(
:project
,
:broken_storage
)
create
(
:geo_project_registry
,
:repository_verified
,
:wiki_verified
,
project:
project_synced
)
create
(
:geo_project_registry
,
:repository_verified
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:repository_verified
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:repository_verified
,
project:
project_4_broken_storage
)
create
(
:geo_project_registry
,
:repository_verified
,
project:
project_4_broken_storage
)
...
@@ -204,12 +176,7 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -204,12 +176,7 @@ describe Geo::ProjectRegistryFinder, :geo do
describe
'#count_verified_wikis'
do
describe
'#count_verified_wikis'
do
before
do
before
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:wiki_verified
,
:wiki_verified
,
project:
project
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_3_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_4_broken_storage
=
create
(
:project
,
:broken_storage
)
create
(
:geo_project_registry
,
:wiki_verified
,
:wiki_verified
,
project:
project_synced
)
create
(
:geo_project_registry
,
:wiki_verified
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_verified
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_verification_failed
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_verification_failed
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_verified
,
project:
project_4_broken_storage
)
create
(
:geo_project_registry
,
:wiki_verified
,
project:
project_4_broken_storage
)
...
@@ -238,47 +205,87 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -238,47 +205,87 @@ describe Geo::ProjectRegistryFinder, :geo do
end
end
describe
'#count_verification_failed_repositories'
do
describe
'#count_verification_failed_repositories'
do
it
'counts projects that verification has failed'
do
before
do
create
(
:geo_project_registry
,
:repository_verified
,
project:
project_repository_verified
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
:wiki_verification_failed
,
project:
project
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
project:
project_repository_verification_failed
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_verified
,
project:
project_wiki_verified
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
project:
project_4_broken_storage
)
create
(
:geo_project_registry
,
:wiki_verification_failed
,
project:
project_wiki_verification_failed
)
create
(
:geo_project_registry
,
:wiki_verification_failed
,
project:
project_2_in_synced_group
)
end
it
'counts registries that repository verification has failed'
do
expect
(
subject
.
count_verification_failed_repositories
).
to
eq
3
end
context
'with selective sync by namespace'
do
it
'counts registries that repository verification has failed where projects belongs to the namespaces'
do
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
expect
(
subject
.
count_verification_failed_repositories
).
to
eq
1
expect
(
subject
.
count_verification_failed_repositories
).
to
eq
1
end
end
end
end
context
'with selective sync by shard'
do
it
'counts registries that repository verification has failed where projects belongs to the shards'
do
secondary
.
update!
(
selective_sync_type:
'shards'
,
selective_sync_shards:
[
'broken'
])
expect
(
subject
.
count_verification_failed_repositories
).
to
eq
1
end
end
end
describe
'#count_verification_failed_wikis'
do
describe
'#count_verification_failed_wikis'
do
it
'counts projects that verification has failed'
do
before
do
create
(
:geo_project_registry
,
:repository_verified
,
project:
project_repository_verified
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
:wiki_verification_failed
,
project:
project
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
project:
project_repository_verification_failed
)
create
(
:geo_project_registry
,
:wiki_verification_failed
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_verified
,
project:
project_wiki_verified
)
create
(
:geo_project_registry
,
:wiki_verification_failed
,
project:
project_4_broken_storage
)
create
(
:geo_project_registry
,
:wiki_verification_failed
,
project:
project_wiki_verification_failed
)
create
(
:geo_project_registry
,
:repository_verification_failed
,
project:
project_2_in_synced_group
)
end
it
'counts registries that wiki verification has failed'
do
expect
(
subject
.
count_verification_failed_wikis
).
to
eq
3
end
context
'with selective sync by namespace'
do
it
'counts registries that wiki verification has failed where projects belongs to the namespaces'
do
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
expect
(
subject
.
count_verification_failed_wikis
).
to
eq
1
expect
(
subject
.
count_verification_failed_wikis
).
to
eq
1
end
end
end
end
context
'with selective sync by shard'
do
it
'counts registries that wiki verification has failed where projects belongs to the shards'
do
secondary
.
update!
(
selective_sync_type:
'shards'
,
selective_sync_shards:
[
'broken'
])
expect
(
subject
.
count_verification_failed_wikis
).
to
eq
1
end
end
end
describe
'#count_repositories_retrying_verification'
do
describe
'#count_repositories_retrying_verification'
do
before
do
before
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
:wiki_retrying_verification
,
project:
project
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
:wiki_retrying_verification
,
project:
project_synced
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
project:
project_4_broken_storage
)
create
(
:geo_project_registry
,
:wiki_retrying_verification
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_retrying_verification
,
project:
project_2_in_synced_group
)
end
end
it
'counts registries that repository retrying verification'
do
it
'counts registries that repository retrying verification'
do
expect
(
subject
.
count_repositories_retrying_verification
).
to
eq
2
expect
(
subject
.
count_repositories_retrying_verification
).
to
eq
3
end
end
context
'with selective sync'
do
context
'with selective sync
by namespace
'
do
before
do
it
'counts registries that repository retrying verification where projects belongs to the namespaces'
do
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
expect
(
subject
.
count_repositories_retrying_verification
).
to
eq
1
end
end
end
it
'counts registries that repository retrying verification'
do
context
'with selective sync by shard'
do
it
'counts registries that repository retrying verification where projects belongs to the shards'
do
secondary
.
update!
(
selective_sync_type:
'shards'
,
selective_sync_shards:
[
'broken'
])
expect
(
subject
.
count_repositories_retrying_verification
).
to
eq
1
expect
(
subject
.
count_repositories_retrying_verification
).
to
eq
1
end
end
end
end
...
@@ -286,70 +293,86 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -286,70 +293,86 @@ describe Geo::ProjectRegistryFinder, :geo do
describe
'#count_wikis_retrying_verification'
do
describe
'#count_wikis_retrying_verification'
do
before
do
before
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
:wiki_retrying_verification
,
project:
project
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
:wiki_retrying_verification
,
project:
project_synced
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:repository_retrying_verification
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_retrying_verification
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_retrying_verification
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:wiki_retrying_verification
,
project:
project_4_broken_storage
)
end
end
it
'counts registries that wiki retrying verification'
do
it
'counts registries that wiki retrying verification'
do
expect
(
subject
.
count_wikis_retrying_verification
).
to
eq
2
expect
(
subject
.
count_wikis_retrying_verification
).
to
eq
3
end
end
context
'with selective sync'
do
context
'with selective sync
by namespace
'
do
before
do
it
'counts registries that wiki retrying verification where projects belongs to the namespaces'
do
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
expect
(
subject
.
count_wikis_retrying_verification
).
to
eq
1
end
end
end
it
'counts registries that wiki retrying verification'
do
context
'with selective sync by shard'
do
it
'counts registries that wiki retrying verification where projects belongs to the shards'
do
secondary
.
update!
(
selective_sync_type:
'shards'
,
selective_sync_shards:
[
'broken'
])
expect
(
subject
.
count_wikis_retrying_verification
).
to
eq
1
expect
(
subject
.
count_wikis_retrying_verification
).
to
eq
1
end
end
end
end
end
end
describe
'#count_repositories_checksum_mismatch'
do
describe
'#count_repositories_checksum_mismatch'
do
let
(
:project_1_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
before
do
let
(
:project_2_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
:wiki_checksum_mismatch
,
project:
project
)
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
project:
project_1_in_synced_group
)
let!
(
:registry_mismatch
)
{
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
:wiki_checksum_mismatch
,
project:
project_synced
)
}
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
:wiki_verified
,
project:
project_4_broken_storage
)
let!
(
:repository_mismatch
)
{
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
project:
project_1_in_synced_group
)
}
create
(
:geo_project_registry
,
:wiki_checksum_mismatch
,
project:
project_2_in_synced_group
)
let!
(
:wiki_mismatch
)
{
create
(
:geo_project_registry
,
:wiki_checksum_mismatch
,
project:
project_2_in_synced_group
)
}
end
it
'counts registries that repository mismatch'
do
it
'counts registries that repository mismatch'
do
expect
(
subject
.
count_repositories_checksum_mismatch
).
to
eq
2
expect
(
subject
.
count_repositories_checksum_mismatch
).
to
eq
3
end
end
context
'with selective sync'
do
context
'with selective sync
by namespace
'
do
before
do
it
'counts mismatch registries where projects belongs to the namespaces'
do
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
expect
(
subject
.
count_repositories_checksum_mismatch
).
to
eq
1
end
end
end
it
'counts projects that sync has failed'
do
context
'with selective sync by shard'
do
it
'counts mismatch registries where projects belongs to the shards'
do
secondary
.
update!
(
selective_sync_type:
'shards'
,
selective_sync_shards:
[
'broken'
])
expect
(
subject
.
count_repositories_checksum_mismatch
).
to
eq
1
expect
(
subject
.
count_repositories_checksum_mismatch
).
to
eq
1
end
end
end
end
end
end
describe
'#count_wikis_checksum_mismatch'
do
describe
'#count_wikis_checksum_mismatch'
do
let
(
:project_1_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
before
do
let
(
:project_2_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
:wiki_checksum_mismatch
,
project:
project
)
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
project:
project_1_in_synced_group
)
let!
(
:registry_mismatch
)
{
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
:wiki_checksum_mismatch
,
project:
project_synced
)
}
create
(
:geo_project_registry
,
:wiki_checksum_mismatch
,
project:
project_2_in_synced_group
)
let!
(
:repository_mismatch
)
{
create
(
:geo_project_registry
,
:repository_checksum_mismatch
,
project:
project_1_in_synced_group
)
}
create
(
:geo_project_registry
,
:repository_verified
,
:wiki_checksum_mismatch
,
project:
project_4_broken_storage
)
let!
(
:wiki_mismatch
)
{
create
(
:geo_project_registry
,
:wiki_checksum_mismatch
,
project:
project_2_in_synced_group
)
}
end
it
'counts
projects that verification has failed
'
do
it
'counts
registries that wiki mismatch
'
do
expect
(
subject
.
count_wikis_checksum_mismatch
).
to
eq
2
expect
(
subject
.
count_wikis_checksum_mismatch
).
to
eq
3
end
end
context
'with selective sync'
do
context
'with selective sync
by namespace
'
do
before
do
it
'counts mismatch registries where projects belongs to the namespaces'
do
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
expect
(
subject
.
count_wikis_checksum_mismatch
).
to
eq
1
end
end
end
it
'counts projects that sync has failed'
do
context
'with selective sync by shard'
do
it
'counts mismatch registries where projects belongs to the shards'
do
secondary
.
update!
(
selective_sync_type:
'shards'
,
selective_sync_shards:
[
'broken'
])
expect
(
subject
.
count_wikis_checksum_mismatch
).
to
eq
1
expect
(
subject
.
count_wikis_checksum_mismatch
).
to
eq
1
end
end
end
end
...
@@ -365,7 +388,8 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -365,7 +388,8 @@ describe Geo::ProjectRegistryFinder, :geo do
end
end
it
'returns projects without an entry on the tracking database'
do
it
'returns projects without an entry on the tracking database'
do
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_repository_dirty
)
project_not_synced
=
create
(
:project
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_1_in_synced_group
)
projects
=
subject
.
find_unsynced_projects
(
batch_size:
10
)
projects
=
subject
.
find_unsynced_projects
(
batch_size:
10
)
...
@@ -384,9 +408,6 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -384,9 +408,6 @@ describe Geo::ProjectRegistryFinder, :geo do
end
end
it
'returns untracked projects in the synced group'
do
it
'returns untracked projects in the synced group'
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:sync_failed
,
project:
project_1_in_synced_group
)
projects
=
subject
.
find_unsynced_projects
(
batch_size:
10
)
projects
=
subject
.
find_unsynced_projects
(
batch_size:
10
)
...
@@ -404,12 +425,12 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -404,12 +425,12 @@ describe Geo::ProjectRegistryFinder, :geo do
end
end
it
'returns projects with a dirty entry on the tracking database'
do
it
'returns projects with a dirty entry on the tracking database'
do
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_
repository_dirty
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_
1_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_
wiki_dirty
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_
2_in_synced_group
)
projects
=
subject
.
find_projects_updated_recently
(
batch_size:
10
)
projects
=
subject
.
find_projects_updated_recently
(
batch_size:
10
)
expect
(
projects
).
to
match_ids
([
project_
repository_dirty
,
project_wiki_dirty
])
expect
(
projects
).
to
match_ids
([
project_
1_in_synced_group
,
project_2_in_synced_group
])
end
end
context
'with selective sync'
do
context
'with selective sync'
do
...
@@ -424,11 +445,7 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -424,11 +445,7 @@ describe Geo::ProjectRegistryFinder, :geo do
end
end
it
'returns dirty projects in the synced group'
do
it
'returns dirty projects in the synced group'
do
project_1_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_2_in_synced_group
=
create
(
:project
,
group:
synced_group
)
project_3_in_synced_group
=
create
(
:project
,
group:
synced_group
)
create
(
:project
,
group:
synced_group
)
create
(
:project
,
group:
synced_group
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_1_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_2_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
project:
project_3_in_synced_group
)
create
(
:geo_project_registry
,
:synced
,
project:
project_3_in_synced_group
)
...
@@ -441,6 +458,35 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -441,6 +458,35 @@ describe Geo::ProjectRegistryFinder, :geo do
end
end
end
end
shared_examples
'delegates to the proper finder'
do
|
legacy_finder_klass
,
finder_klass
,
method
,
args
|
where
(
:selective_sync
,
:fdw_enabled
,
:fdw_for_selective_sync
,
:finder
)
do
false
|
false
|
false
|
legacy_finder_klass
false
|
false
|
true
|
legacy_finder_klass
false
|
true
|
true
|
finder_klass
false
|
true
|
false
|
finder_klass
true
|
false
|
false
|
legacy_finder_klass
true
|
false
|
true
|
legacy_finder_klass
true
|
true
|
true
|
finder_klass
true
|
true
|
false
|
legacy_finder_klass
end
with_them
do
before
do
stub_fdw
(
fdw_enabled
)
stub_feature_flags
(
use_fdw_queries_for_selective_sync:
fdw_for_selective_sync
)
stub_selective_sync
(
secondary
,
selective_sync
)
end
it
'delegates to the proper finder'
do
expect_next_instance_of
(
finder
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
public_send
(
method
,
*
args
)
end
end
end
# Disable transactions via :delete method because a foreign table
# Disable transactions via :delete method because a foreign table
# can't see changes inside a transaction of a different connection.
# can't see changes inside a transaction of a different connection.
context
'FDW'
,
:delete
do
context
'FDW'
,
:delete
do
...
@@ -477,116 +523,30 @@ describe Geo::ProjectRegistryFinder, :geo do
...
@@ -477,116 +523,30 @@ describe Geo::ProjectRegistryFinder, :geo do
end
end
describe
'#find_failed_project_registries'
,
:delete
do
describe
'#find_failed_project_registries'
,
:delete
do
where
(
:selective_sync
,
:fdw_enabled
,
:use_fdw_queries_for_selective_sync
,
:finder
)
do
include_examples
'delegates to the proper finder'
,
false
|
false
|
false
|
Geo
::
LegacyProjectRegistrySyncFailedFinder
Geo
::
LegacyProjectRegistrySyncFailedFinder
,
false
|
false
|
true
|
Geo
::
LegacyProjectRegistrySyncFailedFinder
Geo
::
ProjectRegistrySyncFailedFinder
,
false
|
true
|
true
|
Geo
::
ProjectRegistrySyncFailedFinder
:find_failed_project_registries
,
[
'repository'
]
false
|
true
|
false
|
Geo
::
ProjectRegistrySyncFailedFinder
true
|
false
|
false
|
Geo
::
LegacyProjectRegistrySyncFailedFinder
true
|
false
|
true
|
Geo
::
LegacyProjectRegistrySyncFailedFinder
true
|
true
|
true
|
Geo
::
ProjectRegistrySyncFailedFinder
true
|
true
|
false
|
Geo
::
LegacyProjectRegistrySyncFailedFinder
end
with_them
do
before
do
stub_geo_environment
(
secondary
,
selective_sync
,
fdw_enabled
,
use_fdw_queries_for_selective_sync
)
end
it
'delegates to the correct finder'
do
expect_next_instance_of
(
finder
,
current_node:
secondary
,
type:
'repository'
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_failed_project_registries
(
'repository'
)
end
end
end
end
describe
'#find_registries_to_verify'
,
:delete
do
describe
'#find_registries_to_verify'
,
:delete
do
where
(
:selective_sync
,
:fdw_enabled
,
:use_fdw_queries_for_selective_sync
,
:finder
)
do
include_examples
'delegates to the proper finder'
,
false
|
false
|
false
|
Geo
::
LegacyProjectRegistryPendingVerificationFinder
Geo
::
LegacyProjectRegistryPendingVerificationFinder
,
false
|
false
|
true
|
Geo
::
LegacyProjectRegistryPendingVerificationFinder
Geo
::
ProjectRegistryPendingVerificationFinder
,
false
|
true
|
true
|
Geo
::
ProjectRegistryPendingVerificationFinder
:find_registries_to_verify
,
[
shard_name:
'default'
,
batch_size:
100
]
false
|
true
|
false
|
Geo
::
ProjectRegistryPendingVerificationFinder
true
|
false
|
false
|
Geo
::
LegacyProjectRegistryPendingVerificationFinder
true
|
false
|
true
|
Geo
::
LegacyProjectRegistryPendingVerificationFinder
true
|
true
|
true
|
Geo
::
ProjectRegistryPendingVerificationFinder
true
|
true
|
false
|
Geo
::
LegacyProjectRegistryPendingVerificationFinder
end
with_them
do
before
do
stub_geo_environment
(
secondary
,
selective_sync
,
fdw_enabled
,
use_fdw_queries_for_selective_sync
)
end
it
'delegates to Geo::ProjectRegistryPendingVerificationFinder'
do
expect_next_instance_of
(
finder
,
current_node:
secondary
,
shard_name:
'default'
,
batch_size:
100
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_registries_to_verify
(
shard_name:
'default'
,
batch_size:
100
)
end
end
end
describe
'#find_checksum_mismatch_project_registries'
,
:delete
do
where
(
:selective_sync
,
:fdw_enabled
,
:use_fdw_queries_for_selective_sync
,
:finder
)
do
false
|
false
|
false
|
Geo
::
LegacyProjectRegistryMismatchFinder
false
|
false
|
true
|
Geo
::
LegacyProjectRegistryMismatchFinder
false
|
true
|
true
|
Geo
::
ProjectRegistryMismatchFinder
false
|
true
|
false
|
Geo
::
ProjectRegistryMismatchFinder
true
|
false
|
false
|
Geo
::
LegacyProjectRegistryMismatchFinder
true
|
false
|
true
|
Geo
::
LegacyProjectRegistryMismatchFinder
true
|
true
|
true
|
Geo
::
ProjectRegistryMismatchFinder
true
|
true
|
false
|
Geo
::
LegacyProjectRegistryMismatchFinder
end
with_them
do
before
do
stub_geo_environment
(
secondary
,
selective_sync
,
fdw_enabled
,
use_fdw_queries_for_selective_sync
)
end
it
'delegates to the correct finder'
do
expect_next_instance_of
(
finder
,
current_node:
secondary
,
type:
'repository'
)
do
|
finder
|
expect
(
finder
).
to
receive
(
:execute
).
once
end
subject
.
find_checksum_mismatch_project_registries
(
'repository'
)
end
end
end
end
describe
'#find_verification_failed_project_registries'
,
:delete
do
describe
'#find_verification_failed_project_registries'
,
:delete
do
where
(
:selective_sync
,
:fdw_enabled
,
:use_fdw_queries_for_selective_sync
,
:finder
)
do
include_examples
'delegates to the proper finder'
,
false
|
false
|
false
|
Geo
::
LegacyProjectRegistryVerificationFailedFinder
Geo
::
LegacyProjectRegistryVerificationFailedFinder
,
false
|
false
|
true
|
Geo
::
LegacyProjectRegistryVerificationFailedFinder
Geo
::
ProjectRegistryVerificationFailedFinder
,
false
|
true
|
true
|
Geo
::
ProjectRegistryVerificationFailedFinder
:find_verification_failed_project_registries
,
[
'repository'
]
false
|
true
|
false
|
Geo
::
ProjectRegistryVerificationFailedFinder
true
|
false
|
false
|
Geo
::
LegacyProjectRegistryVerificationFailedFinder
true
|
false
|
true
|
Geo
::
LegacyProjectRegistryVerificationFailedFinder
true
|
true
|
true
|
Geo
::
ProjectRegistryVerificationFailedFinder
true
|
true
|
false
|
Geo
::
LegacyProjectRegistryVerificationFailedFinder
end
with_them
do
before
do
stub_geo_environment
(
secondary
,
selective_sync
,
fdw_enabled
,
use_fdw_queries_for_selective_sync
)
end
end
it
'delegates to the correct finder'
do
describe
'#find_checksum_mismatch_project_registries'
,
:delete
do
expect_next_instance_of
(
finder
,
current_node:
secondary
,
type:
'repository'
)
do
|
finder
|
include_examples
'delegates to the proper finder'
,
expect
(
finder
).
to
receive
(
:execute
).
once
Geo
::
LegacyProjectRegistryMismatchFinder
,
end
Geo
::
ProjectRegistryMismatchFinder
,
:find_checksum_mismatch_project_registries
,
[
'repository'
]
subject
.
find_verification_failed_project_registries
(
'repository'
)
end
end
end
def
stub_geo_environment
(
node
,
selective_sync
,
fdw_enabled
,
use_fdw_queries_for_selective_sync
)
stub_fdw
(
fdw_enabled
)
stub_feature_flags
(
use_fdw_queries_for_selective_sync:
use_fdw_queries_for_selective_sync
)
stub_selective_sync
(
node
,
selective_sync
)
end
end
end
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