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
060fbb9e
Commit
060fbb9e
authored
Jul 24, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove feature flag from design registry finder
parent
bcc3ed8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
151 deletions
+49
-151
ee/app/finders/geo/design_registry_finder.rb
ee/app/finders/geo/design_registry_finder.rb
+12
-15
ee/spec/finders/geo/design_registry_finder_spec.rb
ee/spec/finders/geo/design_registry_finder_spec.rb
+37
-136
No files found.
ee/app/finders/geo/design_registry_finder.rb
View file @
060fbb9e
...
@@ -3,15 +3,15 @@
...
@@ -3,15 +3,15 @@
module
Geo
module
Geo
class
DesignRegistryFinder
<
RegistryFinder
class
DesignRegistryFinder
<
RegistryFinder
def
count_syncable
def
count_syncable
current_node
(
fdw:
false
).
designs
.
count
designs
.
count
end
end
def
count_synced
def
count_synced
registries
.
merge
(
Geo
::
DesignRegistry
.
synced
)
.
count
registries
.
synced
.
count
end
end
def
count_failed
def
count_failed
registries
.
merge
(
Geo
::
DesignRegistry
.
failed
)
.
count
registries
.
failed
.
count
end
end
def
count_registry
def
count_registry
...
@@ -19,8 +19,8 @@ module Geo
...
@@ -19,8 +19,8 @@ module Geo
end
end
def
find_registry_differences
(
range
)
def
find_registry_differences
(
range
)
source_ids
=
Gitlab
::
Geo
.
current_node
.
designs
.
id_in
(
range
).
pluck_primary_key
source_ids
=
designs
.
id_in
(
range
).
pluck_primary_key
tracked_ids
=
Geo
::
DesignRegistry
.
pluck_model_ids_in_range
(
range
)
tracked_ids
=
registries
.
pluck_model_ids_in_range
(
range
)
untracked_ids
=
source_ids
-
tracked_ids
untracked_ids
=
source_ids
-
tracked_ids
unused_tracked_ids
=
tracked_ids
-
source_ids
unused_tracked_ids
=
tracked_ids
-
source_ids
...
@@ -46,7 +46,7 @@ module Geo
...
@@ -46,7 +46,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
::
DesignRegistry
registries
.
never_synced
.
never_synced
.
model_id_not_in
(
except_ids
)
.
model_id_not_in
(
except_ids
)
.
limit
(
batch_size
)
.
limit
(
batch_size
)
...
@@ -55,7 +55,7 @@ module Geo
...
@@ -55,7 +55,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
::
DesignRegistry
registries
.
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,15 +65,12 @@ module Geo
...
@@ -65,15 +65,12 @@ module Geo
private
private
def
designs
current_node_non_fdw
.
designs
end
def
registries
def
registries
if
Geo
::
DesignRegistry
.
registry_consistency_worker_enabled?
Geo
::
DesignRegistry
Geo
::
DesignRegistry
.
all
else
current_node
(
fdw:
true
)
.
projects
.
with_designs
.
inner_join_design_registry
end
end
end
end
end
end
end
ee/spec/finders/geo/design_registry_finder_spec.rb
View file @
060fbb9e
...
@@ -4,158 +4,63 @@ require 'spec_helper'
...
@@ -4,158 +4,63 @@ require 'spec_helper'
RSpec
.
describe
Geo
::
DesignRegistryFinder
,
:geo
do
RSpec
.
describe
Geo
::
DesignRegistryFinder
,
:geo
do
include
::
EE
::
GeoHelpers
include
::
EE
::
GeoHelpers
let
(
:secondary
)
{
create
(
:geo_node
)
}
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
let
(
:project_1
)
{
create
(
:project
)
}
let_it_be
(
:synced_group
)
{
create
(
:group
)
}
let
(
:project_2
)
{
create
(
:project
)
}
let_it_be
(
:nested_group
)
{
create
(
:group
,
parent:
synced_group
)
}
let
(
:project_3
)
{
create
(
:project
)
}
let_it_be
(
:project_1
)
{
create
(
:project
,
group:
synced_group
)
}
let
(
:project_4
)
{
create
(
:project
)
}
let_it_be
(
:project_2
)
{
create
(
:project
,
group:
nested_group
)
}
let
(
:project_5
)
{
create
(
:project
)
}
let_it_be
(
:project_3
)
{
create
(
:project
)
}
let
(
:project_6
)
{
create
(
:project
)
}
let_it_be
(
:project_4
)
{
create
(
:project
)
}
let_it_be
(
:project_5
)
{
create
(
:project
,
:broken_storage
)
}
let_it_be
(
:project_6
)
{
create
(
:project
,
:broken_storage
)
}
let_it_be
(
:project_7
)
{
create
(
:project
)
}
subject
{
described_class
.
new
(
current_node_id:
secondary
.
id
)
}
subject
{
described_class
.
new
(
current_node_id:
secondary
.
id
)
}
context
'when geo_design_registry_ssot_sync is disabled'
,
:geo_fdw
do
before
do
let!
(
:failed_registry
)
{
create
(
:geo_design_registry
,
:sync_failed
)
}
stub_current_geo_node
(
secondary
)
let!
(
:synced_registry
)
{
create
(
:geo_design_registry
,
:synced
)
}
end
before
do
stub_feature_flags
(
geo_design_registry_ssot_sync:
false
)
end
describe
'#count_syncable'
do
it
'returns number of design repositories'
do
# One more design for the same project to assert absence of duplicates
create
(
:design
,
project:
synced_registry
.
project
)
expect
(
subject
.
count_syncable
).
to
eq
(
2
)
end
end
describe
'#count_synced'
do
it
'returns only synced registry'
do
expect
(
subject
.
count_synced
).
to
eq
(
1
)
end
end
describe
'#count_failed'
do
it
'returns only failed registry'
do
expect
(
subject
.
count_failed
).
to
eq
(
1
)
end
end
describe
'#count_registry'
do
it
'returns number of all registries'
do
expect
(
subject
.
count_registry
).
to
eq
(
2
)
end
end
context
'selective sync'
do
let
(
:synced_group
)
{
create
(
:group
)
}
let
(
:unsynced_group
)
{
create
(
:group
)
}
let
(
:synced_project
)
{
create
(
:project
,
group:
synced_group
)
}
let
(
:unsynced_project
)
{
create
(
:project
,
:broken_storage
,
group:
unsynced_group
)
}
let
(
:unsynced_project2
)
{
create
(
:project
,
group:
unsynced_group
)
}
let
(
:synced_project2
)
{
create
(
:project
,
group:
synced_group
)
}
before
do
create
(
:geo_design_registry
,
:synced
,
project:
synced_project
)
create
(
:geo_design_registry
,
:sync_failed
,
project:
synced_project2
)
create
(
:geo_design_registry
,
:synced
,
project:
unsynced_project
)
create
(
:geo_design_registry
,
:sync_failed
,
project:
unsynced_project2
)
secondary
.
update!
(
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
end
context
'count all the things'
do
describe
'#count_syncable'
do
it
'returns number of design repositories'
do
result
=
subject
.
count_syncable
expect
(
result
).
to
eq
(
2
)
end
end
describe
'#count_synced'
do
it
'returns only synced registry'
do
result
=
subject
.
count_synced
expect
(
result
).
to
eq
(
1
)
end
end
describe
'#count_failed'
do
it
'returns only failed registry'
do
result
=
subject
.
count_failed
expect
(
result
).
to
eq
(
1
)
describe
'#count_syncable'
do
end
it
'returns number of designs'
do
end
# Two designs for the same project to assert absence of duplicates
create_list
(
:design
,
2
,
project:
project_1
)
create
(
:design
,
project:
project_2
)
describe
'#count_registry'
do
result
=
subject
.
count_syncable
it
'returns number of all registries'
do
result
=
subject
.
count_registry
expect
(
result
).
to
eq
(
2
)
expect
(
result
).
to
eq
(
2
)
end
end
end
end
end
end
end
context
'when geo_design_registry_ssot_sync is enabled'
do
describe
'#count_synced'
do
let!
(
:registry_project_1
)
{
create
(
:geo_design_registry
,
:synced
,
project_id:
project_1
.
id
)
}
it
'returns number of synced registries'
do
let!
(
:registry_project_2
)
{
create
(
:geo_design_registry
,
:sync_failed
,
project_id:
project_2
.
id
)
}
create
(
:geo_design_registry
,
:synced
,
project_id:
project_1
.
id
)
let!
(
:registry_project_3
)
{
create
(
:geo_design_registry
,
project_id:
project_3
.
id
,
last_synced_at:
nil
)
}
create
(
:geo_design_registry
,
:sync_failed
,
project_id:
project_2
.
id
)
let!
(
:registry_project_4
)
{
create
(
:geo_design_registry
,
project_id:
project_4
.
id
,
last_synced_at:
3
.
days
.
ago
,
retry_at:
2
.
days
.
ago
)
}
let!
(
:registry_project_5
)
{
create
(
:geo_design_registry
,
project_id:
project_5
.
id
,
last_synced_at:
6
.
days
.
ago
)
}
let!
(
:registry_project_6
)
{
create
(
:geo_design_registry
,
project_id:
project_6
.
id
,
last_synced_at:
nil
)
}
before
do
expect
(
subject
.
count_synced
).
to
eq
(
1
)
stub_feature_flags
(
geo_design_registry_ssot_sync:
true
)
end
end
end
describe
'#count_syncable'
do
describe
'#count_failed'
do
it
'returns number of design repositories'
do
it
'returns number of failed registries'
do
# One more design for the same project to assert absence of duplicates
create
(
:geo_design_registry
,
:synced
,
project_id:
project_1
.
id
)
create
(
:design
,
project:
project_1
)
create
(
:geo_design_registry
,
:sync_failed
,
project_id:
project_2
.
id
)
result
=
subject
.
count_syncable
expect
(
result
).
to
eq
(
6
)
expect
(
subject
.
count_failed
).
to
eq
(
1
)
end
end
end
end
describe
'#count_synced'
do
describe
'#count_registry'
do
it
'returns only synced registry'
do
it
'returns number of all registries'
do
expect
(
subject
.
count_synced
).
to
eq
(
1
)
create
(
:geo_design_registry
,
:synced
,
project_id:
project_1
.
id
)
end
create
(
:geo_design_registry
,
:sync_failed
,
project_id:
project_2
.
id
)
end
describe
'#count_failed'
do
expect
(
subject
.
count_registry
).
to
eq
(
2
)
it
'returns only failed registry'
do
expect
(
subject
.
count_failed
).
to
eq
(
1
)
end
end
describe
'#count_registry'
do
it
'returns number of all registries'
do
expect
(
subject
.
count_registry
).
to
eq
(
6
)
end
end
end
end
end
describe
'#find_registry_differences'
do
describe
'#find_registry_differences'
do
let_it_be
(
:secondary
)
{
create
(
:geo_node
)
}
let_it_be
(
:synced_group
)
{
create
(
:group
)
}
let_it_be
(
:nested_group
)
{
create
(
:group
,
parent:
synced_group
)
}
let_it_be
(
:project_1
)
{
create
(
:project
,
group:
synced_group
)
}
let_it_be
(
:project_2
)
{
create
(
:project
,
group:
nested_group
)
}
let_it_be
(
:project_3
)
{
create
(
:project
)
}
let_it_be
(
:project_4
)
{
create
(
:project
)
}
let_it_be
(
:project_5
)
{
create
(
:project
,
:broken_storage
)
}
let_it_be
(
:project_6
)
{
create
(
:project
,
:broken_storage
)
}
let_it_be
(
:project_7
)
{
create
(
:project
)
}
before_all
do
before_all
do
create
(
:design
,
project:
project_1
)
create
(
:design
,
project:
project_1
)
create
(
:design
,
project:
project_2
)
create
(
:design
,
project:
project_2
)
...
@@ -165,10 +70,6 @@ RSpec.describe Geo::DesignRegistryFinder, :geo do
...
@@ -165,10 +70,6 @@ RSpec.describe Geo::DesignRegistryFinder, :geo do
create
(
:design
,
project:
project_6
)
create
(
:design
,
project:
project_6
)
end
end
before
do
stub_current_geo_node
(
secondary
)
end
context
'untracked IDs'
do
context
'untracked IDs'
do
before
do
before
do
create
(
:geo_design_registry
,
project_id:
project_1
.
id
)
create
(
:geo_design_registry
,
project_id:
project_1
.
id
)
...
...
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