BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
5b32a4aa
Commit
5b32a4aa
authored
Oct 10, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backports EE 38771 changes to CE.
parent
43b692cb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
2 deletions
+52
-2
project_start_import.rb
app/workers/concerns/project_start_import.rb
+9
-0
repository_fork_worker.rb
app/workers/repository_fork_worker.rb
+2
-1
repository_import_worker.rb
app/workers/repository_import_worker.rb
+2
-1
repository_fork_worker_spec.rb
spec/workers/repository_fork_worker_spec.rb
+22
-0
repository_import_worker_spec.rb
spec/workers/repository_import_worker_spec.rb
+17
-0
No files found.
app/workers/concerns/project_start_import.rb
0 → 100644
View file @
5b32a4aa
module
ProjectStartImport
def
start
(
project
)
if
project
.
import_started?
&&
project
.
import_jid
==
self
.
jid
return
true
end
project
.
import_start
end
end
app/workers/repository_fork_worker.rb
View file @
5b32a4aa
...
...
@@ -4,6 +4,7 @@ class RepositoryForkWorker
include
Sidekiq
::
Worker
include
Gitlab
::
ShellAdapter
include
DedicatedSidekiqQueue
include
ProjectStartImport
sidekiq_options
status_expiration:
StuckImportJobsWorker
::
IMPORT_JOBS_EXPIRATION
...
...
@@ -37,7 +38,7 @@ class RepositoryForkWorker
private
def
start_fork
(
project
)
return
true
if
project
.
import_start
return
true
if
start
(
project
)
Rails
.
logger
.
info
(
"Project
#{
project
.
full_path
}
was in inconsistent state (
#{
project
.
import_status
}
) while forking."
)
false
...
...
app/workers/repository_import_worker.rb
View file @
5b32a4aa
...
...
@@ -4,6 +4,7 @@ class RepositoryImportWorker
include
Sidekiq
::
Worker
include
DedicatedSidekiqQueue
include
ExceptionBacktrace
include
ProjectStartImport
sidekiq_options
status_expiration:
StuckImportJobsWorker
::
IMPORT_JOBS_EXPIRATION
...
...
@@ -34,7 +35,7 @@ class RepositoryImportWorker
private
def
start_import
(
project
)
return
true
if
project
.
import_start
return
true
if
start
(
project
)
Rails
.
logger
.
info
(
"Project
#{
project
.
full_path
}
was in inconsistent state (
#{
project
.
import_status
}
) while importing."
)
false
...
...
spec/workers/repository_fork_worker_spec.rb
View file @
5b32a4aa
...
...
@@ -12,6 +12,28 @@ describe RepositoryForkWorker do
end
describe
"#perform"
do
describe
'when a worker was reset without cleanup'
do
let
(
:jid
)
{
'12345678'
}
let
(
:started_project
)
{
create
(
:project
,
:repository
,
:import_started
)
}
it
'creates a new repository from a fork'
do
allow
(
subject
).
to
receive
(
:jid
).
and_return
(
jid
)
expect
(
shell
).
to
receive
(
:fork_repository
).
with
(
'/test/path'
,
project
.
full_path
,
project
.
repository_storage_path
,
fork_project
.
namespace
.
full_path
).
and_return
(
true
)
subject
.
perform
(
project
.
id
,
'/test/path'
,
project
.
full_path
,
fork_project
.
namespace
.
full_path
)
end
end
it
"creates a new repository from a fork"
do
expect
(
shell
).
to
receive
(
:fork_repository
).
with
(
'/test/path'
,
...
...
spec/workers/repository_import_worker_spec.rb
View file @
5b32a4aa
...
...
@@ -6,6 +6,23 @@ describe RepositoryImportWorker do
subject
{
described_class
.
new
}
describe
'#perform'
do
context
'when worker was reset without cleanup'
do
let
(
:jid
)
{
'12345678'
}
let
(
:started_project
)
{
create
(
:project
,
:import_started
,
import_jid:
jid
)
}
it
'imports the project successfully'
do
allow
(
subject
).
to
receive
(
:jid
).
and_return
(
jid
)
expect_any_instance_of
(
Projects
::
ImportService
).
to
receive
(
:execute
)
.
and_return
({
status: :ok
})
expect_any_instance_of
(
Repository
).
to
receive
(
:expire_emptiness_caches
)
expect_any_instance_of
(
Project
).
to
receive
(
:import_finish
)
subject
.
perform
(
project
.
id
)
end
end
context
'when the import was successful'
do
it
'imports a project'
do
expect_any_instance_of
(
Projects
::
ImportService
).
to
receive
(
:execute
)
...
...
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