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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
5a135264
Commit
5a135264
authored
Mar 08, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds queue option to push bulk in authorized projects worker
parent
130fd255
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
app/workers/authorized_projects_worker.rb
app/workers/authorized_projects_worker.rb
+1
-1
changelogs/unreleased/29137-bulk-perform-async-should-specify-queue.yml
...eleased/29137-bulk-perform-async-should-specify-queue.yml
+4
-0
spec/workers/authorized_projects_worker_spec.rb
spec/workers/authorized_projects_worker_spec.rb
+20
-5
No files found.
app/workers/authorized_projects_worker.rb
View file @
5a135264
...
@@ -10,7 +10,7 @@ class AuthorizedProjectsWorker
...
@@ -10,7 +10,7 @@ class AuthorizedProjectsWorker
end
end
def
self
.
bulk_perform_async
(
args_list
)
def
self
.
bulk_perform_async
(
args_list
)
Sidekiq
::
Client
.
push_bulk
(
'class'
=>
self
,
'args'
=>
args_list
)
Sidekiq
::
Client
.
push_bulk
(
'class'
=>
self
,
'
queue'
=>
sidekiq_options
[
'queue'
],
'
args'
=>
args_list
)
end
end
def
perform
(
user_id
)
def
perform
(
user_id
)
...
...
changelogs/unreleased/29137-bulk-perform-async-should-specify-queue.yml
0 → 100644
View file @
5a135264
---
title
:
Make authorized projects worker use a specific queue instead of the default one
merge_request
:
9813
author
:
spec/workers/authorized_projects_worker_spec.rb
View file @
5a135264
require
'spec_helper'
require
'spec_helper'
describe
AuthorizedProjectsWorker
do
describe
AuthorizedProjectsWorker
do
let
(
:
worker
)
{
described_class
.
new
}
let
(
:
project
)
{
create
(
:empty_project
)
}
describe
'.bulk_perform_and_wait'
do
describe
'.bulk_perform_and_wait'
do
it
'schedules the ids and waits for the jobs to complete'
do
it
'schedules the ids and waits for the jobs to complete'
do
project
=
create
(
:project
)
project
.
owner
.
project_authorizations
.
delete_all
project
.
owner
.
project_authorizations
.
delete_all
described_class
.
bulk_perform_and_wait
([[
project
.
owner
.
id
]])
described_class
.
bulk_perform_and_wait
([[
project
.
owner
.
id
]])
...
@@ -15,20 +13,37 @@ describe AuthorizedProjectsWorker do
...
@@ -15,20 +13,37 @@ describe AuthorizedProjectsWorker do
end
end
end
end
describe
'.bulk_perform_async'
do
it
"uses it's respective sidekiq queue"
do
args
=
[[
project
.
owner
.
id
]]
push_bulk_args
=
{
'class'
=>
described_class
,
'queue'
=>
described_class
.
sidekiq_options
[
'queue'
],
'args'
=>
args
}
expect
(
Sidekiq
::
Client
).
to
receive
(
:push_bulk
).
with
(
push_bulk_args
).
once
described_class
.
bulk_perform_async
(
args
)
end
end
describe
'#perform'
do
describe
'#perform'
do
subject
{
described_class
.
new
}
it
"refreshes user's authorized projects"
do
it
"refreshes user's authorized projects"
do
user
=
create
(
:user
)
user
=
create
(
:user
)
expect_any_instance_of
(
User
).
to
receive
(
:refresh_authorized_projects
)
expect_any_instance_of
(
User
).
to
receive
(
:refresh_authorized_projects
)
worker
.
perform
(
user
.
id
)
subject
.
perform
(
user
.
id
)
end
end
context
"when the user is not found"
do
context
"when the user is not found"
do
it
"does nothing"
do
it
"does nothing"
do
expect_any_instance_of
(
User
).
not_to
receive
(
:refresh_authorized_projects
)
expect_any_instance_of
(
User
).
not_to
receive
(
:refresh_authorized_projects
)
described_class
.
new
.
perform
(
-
1
)
subject
.
perform
(
-
1
)
end
end
end
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