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
27be1000
Commit
27be1000
authored
Apr 02, 2020
by
Matthias Kaeppler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store correlation ID when starting import
parent
31fbda6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
app/models/project_import_state.rb
app/models/project_import_state.rb
+7
-1
spec/models/project_import_state_spec.rb
spec/models/project_import_state_spec.rb
+12
-4
No files found.
app/models/project_import_state.rb
View file @
27be1000
...
...
@@ -10,6 +10,8 @@ class ProjectImportState < ApplicationRecord
validates
:project
,
presence:
true
alias_attribute
:correlation_id
,
:correlation_id_value
state_machine
:status
,
initial: :none
do
event
:schedule
do
transition
[
:none
,
:finished
,
:failed
]
=>
:scheduled
...
...
@@ -39,7 +41,11 @@ class ProjectImportState < ApplicationRecord
after_transition
[
:none
,
:finished
,
:failed
]
=>
:scheduled
do
|
state
,
_
|
state
.
run_after_commit
do
job_id
=
project
.
add_import_job
update
(
jid:
job_id
)
if
job_id
if
job_id
correlation_id
=
Labkit
::
Correlation
::
CorrelationId
.
current_or_new_id
update
(
jid:
job_id
,
correlation_id_value:
correlation_id
)
end
end
end
...
...
spec/models/project_import_state_spec.rb
View file @
27be1000
...
...
@@ -14,8 +14,8 @@ describe ProjectImportState, type: :model do
end
describe
'Project import job'
do
let
(
:import_state
)
{
create
(
:import_state
,
import_url:
generate
(
:url
))
}
let
(
:project
)
{
import_state
.
project
}
let
_it_be
(
:import_state
)
{
create
(
:import_state
,
import_url:
generate
(
:url
))
}
let
_it_be
(
:project
)
{
import_state
.
project
}
before
do
allow_any_instance_of
(
Gitlab
::
GitalyClient
::
RepositoryService
).
to
receive
(
:import_repository
)
...
...
@@ -29,8 +29,16 @@ describe ProjectImportState, type: :model do
it
'imports a project'
,
:sidekiq_might_not_need_inline
do
expect
(
RepositoryImportWorker
).
to
receive
(
:perform_async
).
and_call_original
expect
{
import_state
.
schedule
}.
to
change
{
import_state
.
jid
}
expect
(
import_state
.
status
).
to
eq
(
'finished'
)
expect
{
import_state
.
schedule
}.
to
change
{
import_state
.
status
}.
from
(
'none'
).
to
(
'finished'
)
end
it
'records job and correlation IDs'
,
:sidekiq_might_not_need_inline
do
allow
(
Labkit
::
Correlation
::
CorrelationId
).
to
receive
(
:current_or_new_id
).
and_return
(
'abc'
)
import_state
.
schedule
expect
(
import_state
.
jid
).
to
be_an_instance_of
(
String
)
expect
(
import_state
.
correlation_id
).
to
eq
(
'abc'
)
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