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
388abbd1
Commit
388abbd1
authored
Jul 11, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract background migratons queue class method
parent
c17b1d5f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
background_migration.rb
lib/gitlab/background_migration.rb
+5
-2
background_migration_spec.rb
spec/lib/gitlab/background_migration_spec.rb
+14
-9
No files found.
lib/gitlab/background_migration.rb
View file @
388abbd1
module
Gitlab
module
BackgroundMigration
def
self
.
queue
BackgroundMigrationWorker
.
sidekiq_options
[
'queue'
]
end
# Begins stealing jobs from the background migrations queue, blocking the
# caller until all jobs have been completed.
#
# steal_class - The name of the class for which to steal jobs.
def
self
.
steal
(
steal_class
)
queue
=
Sidekiq
::
Queue
.
new
(
BackgroundMigrationWorker
.
sidekiq_options
[
'queue'
])
queue
=
Sidekiq
::
Queue
.
new
(
self
.
queue
)
queue
.
each
do
|
job
|
migration_class
,
migration_args
=
job
.
args
...
...
spec/lib/gitlab/background_migration_spec.rb
View file @
388abbd1
require
'spec_helper'
describe
Gitlab
::
BackgroundMigration
do
describe
'.queue'
do
it
'returns background migration worker queue'
do
expect
(
described_class
.
queue
)
.
to
eq
BackgroundMigrationWorker
.
sidekiq_options
[
'queue'
]
end
end
describe
'.steal'
do
it
'steals jobs from a queue
'
do
queue
=
[
double
(
:job
,
args:
[
'Foo'
,
[
10
,
20
]])]
context
'when there are enqueued jobs present
'
do
let
(
:queue
)
{
[
double
(
:job
,
args:
[
'Foo'
,
[
10
,
20
]])]
}
before
do
allow
(
Sidekiq
::
Queue
).
to
receive
(
:new
)
.
with
(
BackgroundMigrationWorker
.
sidekiq_options
[
'queue'
]
)
.
with
(
described_class
.
queue
)
.
and_return
(
queue
)
end
it
'steals jobs from a queue'
do
expect
(
queue
[
0
]).
to
receive
(
:delete
)
expect
(
described_class
).
to
receive
(
:perform
).
with
(
'Foo'
,
[
10
,
20
])
...
...
@@ -17,12 +27,6 @@ describe Gitlab::BackgroundMigration do
end
it
'does not steal jobs for a different migration'
do
queue
=
[
double
(
:job
,
args:
[
'Foo'
,
[
10
,
20
]])]
allow
(
Sidekiq
::
Queue
).
to
receive
(
:new
)
.
with
(
BackgroundMigrationWorker
.
sidekiq_options
[
'queue'
])
.
and_return
(
queue
)
expect
(
described_class
).
not_to
receive
(
:perform
)
expect
(
queue
[
0
]).
not_to
receive
(
:delete
)
...
...
@@ -30,6 +34,7 @@ describe Gitlab::BackgroundMigration do
described_class
.
steal
(
'Bar'
)
end
end
end
describe
'.perform'
do
it
'performs a background migration'
do
...
...
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