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
707ab6ed
Commit
707ab6ed
authored
Nov 19, 2020
by
Eugenia Grieff
Committed by
Bob Van Landuyt
Nov 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add worker for import csv requirements
- Add job to queues - Add specs
parent
0a4a6591
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
0 deletions
+70
-0
config/sidekiq_queues.yml
config/sidekiq_queues.yml
+2
-0
ee/app/workers/all_queues.yml
ee/app/workers/all_queues.yml
+8
-0
ee/app/workers/requirements_management/import_requirements_csv_worker.rb
...requirements_management/import_requirements_csv_worker.rb
+28
-0
ee/changelogs/unreleased/249182-create-a-sidekiq-job-for-requirements-management-importer.yml
...te-a-sidekiq-job-for-requirements-management-importer.yml
+5
-0
ee/spec/workers/requirements_management/import_requirements_csv_worker_spec.rb
...rements_management/import_requirements_csv_worker_spec.rb
+27
-0
No files found.
config/sidekiq_queues.yml
View file @
707ab6ed
...
...
@@ -288,6 +288,8 @@
-
1
-
-
repository_update_remote_mirror
-
1
-
-
requirements_management_import_requirements_csv
-
1
-
-
requirements_management_process_requirements_reports
-
1
-
-
security_scans
...
...
ee/app/workers/all_queues.yml
View file @
707ab6ed
...
...
@@ -741,6 +741,14 @@
:weight:
1
:idempotent:
:tags: []
-
:name: requirements_management_import_requirements_csv
:feature_category: :requirements_management
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight:
1
:idempotent:
true
:tags: []
-
:name: requirements_management_process_requirements_reports
:feature_category: :requirements_management
:has_external_dependencies:
...
...
ee/app/workers/requirements_management/import_requirements_csv_worker.rb
0 → 100644
View file @
707ab6ed
# frozen_string_literal: true
module
RequirementsManagement
class
ImportRequirementsCsvWorker
include
ApplicationWorker
include
Gitlab
::
Utils
::
StrongMemoize
idempotent!
feature_category
:requirements_management
# TODO: Set worker_resource_boundary.
# https://gitlab.com/gitlab-org/gitlab/-/issues/281173
sidekiq_retries_exhausted
do
|
job
|
Upload
.
find
(
job
[
'args'
][
2
]).
destroy
end
def
perform
(
current_user_id
,
project_id
,
upload_id
)
upload
=
Upload
.
find
(
upload_id
)
user
=
User
.
find
(
current_user_id
)
project
=
Project
.
find
(
project_id
)
RequirementsManagement
::
ImportCsvService
.
new
(
user
,
project
,
upload
.
retrieve_uploader
).
execute
upload
.
destroy!
rescue
ActiveRecord
::
RecordNotFound
# Resources have been removed, job should not be retried
end
end
end
ee/changelogs/unreleased/249182-create-a-sidekiq-job-for-requirements-management-importer.yml
0 → 100644
View file @
707ab6ed
---
title
:
Add Sidekiq job for importing csv requirements async
merge_request
:
46429
author
:
type
:
added
ee/spec/workers/requirements_management/import_requirements_csv_worker_spec.rb
0 → 100644
View file @
707ab6ed
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
RequirementsManagement
::
ImportRequirementsCsvWorker
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:upload
)
{
create
(
:upload
,
:with_file
)
}
subject
{
described_class
.
new
.
perform
(
user
.
id
,
project
.
id
,
upload
.
id
)
}
describe
'#perform'
do
it
'calls #execute on Requirements::ImportCsvService and destroys upload'
do
expect_next_instance_of
(
RequirementsManagement
::
ImportCsvService
)
do
|
instance
|
expect
(
instance
).
to
receive
(
:execute
).
and_return
({
success:
5
,
error_lines:
[],
parse_error:
false
})
end
subject
expect
{
upload
.
reload
}.
to
raise_error
ActiveRecord
::
RecordNotFound
end
it_behaves_like
'an idempotent worker'
do
let
(
:job_args
)
{
[
user
.
id
,
project
.
id
,
upload
.
id
]
}
end
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