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
de63b9c3
Commit
de63b9c3
authored
Nov 22, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix exclusive lease specs fro hashed storage migration
parent
499e85d6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
app/workers/project_migrate_hashed_storage_worker.rb
app/workers/project_migrate_hashed_storage_worker.rb
+6
-6
spec/workers/project_migrate_hashed_storage_worker_spec.rb
spec/workers/project_migrate_hashed_storage_worker_spec.rb
+9
-3
No files found.
app/workers/project_migrate_hashed_storage_worker.rb
View file @
de63b9c3
...
...
@@ -8,23 +8,23 @@ class ProjectMigrateHashedStorageWorker
project
=
Project
.
find_by
(
id:
project_id
)
return
if
project
.
nil?
||
project
.
pending_delete?
uuid
=
try_obtain_lease_for
(
project_id
)
uuid
=
lease_for
(
project_id
).
try_obtain
if
uuid
::
Projects
::
HashedStorageMigrationService
.
new
(
project
,
logger
).
execute
else
false
end
rescue
=>
ex
cancel_lease_for
(
project_id
,
uuid
)
cancel_lease_for
(
project_id
,
uuid
)
if
uuid
raise
ex
end
private
def
try_obtain_lease_for
(
project_id
)
Gitlab
::
ExclusiveLease
.
new
(
lease_key
(
project_id
),
timeout:
LEASE_TIMEOUT
).
try_obtain
def
lease_for
(
project_id
)
Gitlab
::
ExclusiveLease
.
new
(
lease_key
(
project_id
),
timeout:
LEASE_TIMEOUT
)
end
private
def
lease_key
(
project_id
)
"project_migrate_hashed_storage_worker:
#{
project_id
}
"
end
...
...
spec/workers/project_migrate_hashed_storage_worker_spec.rb
View file @
de63b9c3
require
'spec_helper'
describe
ProjectMigrateHashedStorageWorker
do
describe
ProjectMigrateHashedStorageWorker
,
:clean_gitlab_redis_shared_state
do
describe
'#perform'
do
let
(
:project
)
{
create
(
:project
,
:empty_repo
)
}
let
(
:pending_delete_project
)
{
create
(
:project
,
:empty_repo
,
pending_delete:
true
)
}
context
'when have exclusive lease'
do
before
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
).
and_return
(
true
)
lease
=
subject
.
lease_for
(
project
.
id
)
allow
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:new
).
and_return
(
lease
)
allow
(
lease
).
to
receive
(
:try_obtain
).
and_return
(
true
)
end
it
'skips when project no longer exists'
do
...
...
@@ -34,7 +37,10 @@ describe ProjectMigrateHashedStorageWorker do
context
'when dont have exclusive lease'
do
before
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
).
and_return
(
false
)
lease
=
subject
.
lease_for
(
project
.
id
)
allow
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:new
).
and_return
(
lease
)
allow
(
lease
).
to
receive
(
:try_obtain
).
and_return
(
false
)
end
it
'skips when dont have lease'
do
...
...
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