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
0c8948dd
Commit
0c8948dd
authored
Sep 28, 2021
by
Kassio Borges
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable BulkImports::PipelineWorker to re-run started trackers
parent
337e2845
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
26 deletions
+45
-26
app/models/bulk_imports/tracker.rb
app/models/bulk_imports/tracker.rb
+2
-0
app/workers/bulk_imports/pipeline_worker.rb
app/workers/bulk_imports/pipeline_worker.rb
+1
-1
spec/workers/bulk_imports/pipeline_worker_spec.rb
spec/workers/bulk_imports/pipeline_worker_spec.rb
+42
-25
No files found.
app/models/bulk_imports/tracker.rb
View file @
0c8948dd
...
...
@@ -50,6 +50,8 @@ class BulkImports::Tracker < ApplicationRecord
event
:start
do
transition
created: :started
# To avoid errors when re-starting a pipeline in case of network errors
transition
started: :started
end
event
:finish
do
...
...
app/workers/bulk_imports/pipeline_worker.rb
View file @
0c8948dd
...
...
@@ -16,7 +16,7 @@ module BulkImports
def
perform
(
pipeline_tracker_id
,
stage
,
entity_id
)
pipeline_tracker
=
::
BulkImports
::
Tracker
.
with_status
(
:created
)
.
with_status
(
:created
,
:started
)
.
find_by_id
(
pipeline_tracker_id
)
if
pipeline_tracker
.
present?
...
...
spec/workers/bulk_imports/pipeline_worker_spec.rb
View file @
0c8948dd
...
...
@@ -27,42 +27,59 @@ RSpec.describe BulkImports::PipelineWorker do
.
and_return
([[
0
,
pipeline_class
]])
end
it
'runs the given pipeline successfully'
do
pipeline_tracker
=
create
(
:bulk_import_tracker
,
entity:
entity
,
pipeline_name:
'FakePipeline'
)
expect_next_instance_of
(
Gitlab
::
Import
::
Logger
)
do
|
logger
|
expect
(
logger
)
.
to
receive
(
:info
)
.
with
(
worker:
described_class
.
name
,
pipeline_name:
'FakePipeline'
,
entity_id:
entity
.
id
)
end
shared_examples
'successfully runs the pipeline'
do
it
'runs the given pipeline successfully'
do
expect_next_instance_of
(
Gitlab
::
Import
::
Logger
)
do
|
logger
|
expect
(
logger
)
.
to
receive
(
:info
)
.
with
(
worker:
described_class
.
name
,
pipeline_name:
'FakePipeline'
,
entity_id:
entity
.
id
)
end
expect
(
BulkImports
::
EntityWorker
)
.
to
receive
(
:perform_async
)
.
with
(
entity
.
id
,
pipeline_tracker
.
stage
)
expect
(
BulkImports
::
EntityWorker
)
.
to
receive
(
:perform_async
)
.
with
(
entity
.
id
,
pipeline_tracker
.
stage
)
expect
(
subject
).
to
receive
(
:jid
).
and_return
(
'jid'
)
expect
(
subject
).
to
receive
(
:jid
).
and_return
(
'jid'
)
subject
.
perform
(
pipeline_tracker
.
id
,
pipeline_tracker
.
stage
,
entity
.
id
)
subject
.
perform
(
pipeline_tracker
.
id
,
pipeline_tracker
.
stage
,
entity
.
id
)
pipeline_tracker
.
reload
pipeline_tracker
.
reload
expect
(
pipeline_tracker
.
status_name
).
to
eq
(
:finished
)
expect
(
pipeline_tracker
.
jid
).
to
eq
(
'jid'
)
expect
(
pipeline_tracker
.
status_name
).
to
eq
(
:finished
)
expect
(
pipeline_tracker
.
jid
).
to
eq
(
'jid'
)
end
end
it_behaves_like
'successfully runs the pipeline'
do
let
(
:pipeline_tracker
)
do
create
(
:bulk_import_tracker
,
entity:
entity
,
pipeline_name:
'FakePipeline'
)
end
end
it_behaves_like
'successfully runs the pipeline'
do
let
(
:pipeline_tracker
)
do
create
(
:bulk_import_tracker
,
:started
,
entity:
entity
,
pipeline_name:
'FakePipeline'
)
end
end
context
'when the pipeline cannot be found'
do
it
'logs the error'
do
pipeline_tracker
=
create
(
:bulk_import_tracker
,
:
start
ed
,
:
finish
ed
,
entity:
entity
,
pipeline_name:
'FakePipeline'
)
...
...
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