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
72d8760c
Commit
72d8760c
authored
Jun 08, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Geo::RepositorySyncService when can't obtain a lease to sync a repo
parent
dbc7bbc3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
app/services/geo/repository_sync_service.rb
app/services/geo/repository_sync_service.rb
+1
-1
spec/services/geo/repository_sync_service_spec.rb
spec/services/geo/repository_sync_service_spec.rb
+18
-12
No files found.
app/services/geo/repository_sync_service.rb
View file @
72d8760c
...
...
@@ -66,7 +66,7 @@ module Geo
log
(
'Trying to obtain lease to sync repository'
)
repository_lease
=
Gitlab
::
ExclusiveLease
.
new
(
lease_key
,
timeout:
LEASE_TIMEOUT
).
try_obtain
if
repository_lease
.
nil?
unless
repository_lease
log
(
'Could not obtain lease to sync repository'
)
return
end
...
...
spec/services/geo/repository_sync_service_spec.rb
View file @
72d8760c
...
...
@@ -2,9 +2,19 @@ require 'spec_helper'
describe
Geo
::
RepositorySyncService
,
services:
true
do
let!
(
:primary
)
{
create
(
:geo_node
,
:primary
,
host:
'primary-geo-node'
)
}
let
(
:lease
)
{
double
(
try_obtain:
true
)
}
subject
{
described_class
.
new
(
project
.
id
)
}
before
do
allow
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:new
)
.
with
(
subject
.
__send__
(
:lease_key
),
anything
)
.
and_return
(
lease
)
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
)
.
and_return
(
true
)
end
describe
'#execute'
do
context
'when repository is empty'
do
let
(
:project
)
{
create
(
:project_empty_repo
)
}
...
...
@@ -22,8 +32,6 @@ describe Geo::RepositorySyncService, services: true do
end
it
'expires repository caches'
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
)
{
true
}
expect_any_instance_of
(
Repository
).
to
receive
(
:expire_all_method_caches
).
once
expect_any_instance_of
(
Repository
).
to
receive
(
:expire_branch_cache
).
once
expect_any_instance_of
(
Repository
).
to
receive
(
:expire_content_cache
).
once
...
...
@@ -38,14 +46,20 @@ describe Geo::RepositorySyncService, services: true do
subject
.
execute
end
it
'does not fetch project repositories if cannot obtain a lease'
do
allow
(
lease
).
to
receive
(
:try_obtain
)
{
false
}
expect_any_instance_of
(
Repository
).
not_to
receive
(
:fetch_geo_mirror
)
subject
.
execute
end
context
'tracking database'
do
it
'tracks repository sync'
do
expect
{
subject
.
execute
}.
to
change
(
Geo
::
ProjectRegistry
,
:count
).
by
(
1
)
end
it
'stores last_repository_successful_sync_at when succeed'
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
)
{
true
}
subject
.
execute
registry
=
Geo
::
ProjectRegistry
.
find_by
(
project_id:
project
.
id
)
...
...
@@ -86,8 +100,6 @@ describe Geo::RepositorySyncService, services: true do
end
it
'stores last_repository_successful_sync_at when succeed'
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
)
{
true
}
subject
.
execute
registry
=
Geo
::
ProjectRegistry
.
find_by
(
project_id:
project
.
id
)
...
...
@@ -137,8 +149,6 @@ describe Geo::RepositorySyncService, services: true do
end
it
'updates registry when succeed'
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
)
{
true
}
subject
.
execute
registry
.
reload
...
...
@@ -184,10 +194,6 @@ describe Geo::RepositorySyncService, services: true do
end
context
'tracking database'
do
before
do
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_geo_mirror
)
{
true
}
end
it
'does not create a new registry'
do
expect
{
subject
.
execute
}.
not_to
change
(
Geo
::
ProjectRegistry
,
:count
)
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