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
ca2a8ce4
Commit
ca2a8ce4
authored
Nov 27, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for Geo::ProjectRegistryFinder
parent
7e68a460
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
spec/finders/geo/project_registry_finder_spec.rb
spec/finders/geo/project_registry_finder_spec.rb
+118
-0
No files found.
spec/finders/geo/project_registry_finder_spec.rb
0 → 100644
View file @
ca2a8ce4
require
'spec_helper'
# Disable transactions via :truncate method because a foreign table
# can't see changes inside a transaction of a different connection.
describe
Geo
::
ProjectRegistryFinder
,
:geo
,
:truncate
do
include
::
EE
::
GeoHelpers
let
(
:secondary
)
{
create
(
:geo_node
)
}
let
(
:synced_group
)
{
create
(
:group
)
}
let!
(
:project_not_synced
)
{
create
(
:project
)
}
let
(
:project_repository_dirty
)
{
create
(
:project
)
}
let
(
:project_wiki_dirty
)
{
create
(
:project
)
}
subject
{
described_class
.
new
(
current_node:
secondary
)
}
before
do
stub_current_geo_node
(
secondary
)
end
context
'FDW'
do
before
do
skip
(
'FDW is not configured'
)
if
Gitlab
::
Database
.
postgresql?
&&
!
Gitlab
::
Geo
.
fdw?
end
describe
'#find_unsynced_projects'
do
it
'delegates to #fdw_find_unsynced_projects'
do
expect
(
subject
).
to
receive
(
:fdw_find_unsynced_projects
).
and_call_original
subject
.
find_unsynced_projects
(
batch_size:
10
)
end
it
'delegates to #legacy_find_unsynced_projects when node has selective sync'
do
secondary
.
update_attribute
(
:namespaces
,
[
synced_group
])
expect
(
subject
).
to
receive
(
:legacy_find_unsynced_projects
).
and_call_original
subject
.
find_unsynced_projects
(
batch_size:
10
)
end
it
'returns projects without an entry on the tracking database'
do
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_repository_dirty
)
projects
=
subject
.
find_unsynced_projects
(
batch_size:
10
)
expect
(
projects
.
count
).
to
eq
(
1
)
expect
(
projects
.
first
.
id
).
to
eq
(
project_not_synced
.
id
)
end
end
describe
'#find_projects_updated_recently'
do
it
'delegates to #fdw_find_projects_updated_recently'
do
expect
(
subject
).
to
receive
(
:fdw_find_projects_updated_recently
).
and_call_original
subject
.
find_projects_updated_recently
(
batch_size:
10
)
end
it
'delegates to #legacy_find_projects_updated_recently when node has selective sync'
do
secondary
.
update_attribute
(
:namespaces
,
[
synced_group
])
expect
(
subject
).
to
receive
(
:legacy_find_projects_updated_recently
).
and_call_original
subject
.
find_projects_updated_recently
(
batch_size:
10
)
end
it
'returns projects with a dirty entry on the tracking database'
do
project_not_synced
=
create
(
:project
)
project_repository_dirty
=
create
(
:project
)
project_wiki_dirty
=
create
(
:project
)
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_repository_dirty
)
create
(
:geo_project_registry
,
:synced
,
:wiki_dirty
,
project:
project_wiki_dirty
)
projects
=
subject
.
find_projects_updated_recently
(
batch_size:
10
)
expect
(
projects
.
pluck
(
:id
)).
to
match_array
([
project_repository_dirty
.
id
,
project_wiki_dirty
.
id
])
end
end
end
context
'Legacy'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:fdw?
).
and_return
(
false
)
end
describe
'#find_unsynced_projects'
do
it
'delegates to #legacy_find_unsynced_projects'
do
expect
(
subject
).
to
receive
(
:legacy_find_unsynced_projects
).
and_call_original
subject
.
find_unsynced_projects
(
batch_size:
10
)
end
it
'returns projects without an entry on the tracking database'
do
create
(
:geo_project_registry
,
:synced
,
:repository_dirty
,
project:
project_repository_dirty
)
projects
=
subject
.
find_unsynced_projects
(
batch_size:
10
)
expect
(
projects
).
to
match_array
([
project_not_synced
])
end
end
describe
'#find_projects_updated_recently'
do
it
'delegates to #legacy_find_projects_updated_recently'
do
expect
(
subject
).
to
receive
(
:legacy_find_projects_updated_recently
).
and_call_original
subject
.
find_projects_updated_recently
(
batch_size:
10
)
end
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
,
:wiki_dirty
,
project:
project_wiki_dirty
)
projects
=
subject
.
find_projects_updated_recently
(
batch_size:
10
)
expect
(
projects
.
pluck
(
:id
)).
to
match_array
([
project_repository_dirty
.
id
,
project_wiki_dirty
.
id
])
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