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
3ab5af14
Commit
3ab5af14
authored
Dec 19, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if specific type of background migration are done
Useful for checking progress.
parent
1d2ef4c6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
+57
-0
lib/gitlab/background_migration.rb
lib/gitlab/background_migration.rb
+13
-0
spec/lib/gitlab/background_migration_spec.rb
spec/lib/gitlab/background_migration_spec.rb
+44
-0
No files found.
lib/gitlab/background_migration.rb
View file @
3ab5af14
...
@@ -51,6 +51,19 @@ module Gitlab
...
@@ -51,6 +51,19 @@ module Gitlab
migration_class_for
(
class_name
).
new
.
perform
(
*
arguments
)
migration_class_for
(
class_name
).
new
.
perform
(
*
arguments
)
end
end
def
self
.
exists?
(
migration_class
)
enqueued
=
Sidekiq
::
Queue
.
new
(
self
.
queue
)
scheduled
=
Sidekiq
::
ScheduledSet
.
new
[
enqueued
,
scheduled
].
each
do
|
queue
|
queue
.
each
do
|
job
|
return
true
if
job
.
queue
==
self
.
queue
&&
job
.
args
.
first
==
migration_class
end
end
false
end
def
self
.
migration_class_for
(
class_name
)
def
self
.
migration_class_for
(
class_name
)
const_get
(
class_name
)
const_get
(
class_name
)
end
end
...
...
spec/lib/gitlab/background_migration_spec.rb
View file @
3ab5af14
...
@@ -119,4 +119,48 @@ describe Gitlab::BackgroundMigration do
...
@@ -119,4 +119,48 @@ describe Gitlab::BackgroundMigration do
described_class
.
perform
(
'Foo'
,
[
10
,
20
])
described_class
.
perform
(
'Foo'
,
[
10
,
20
])
end
end
end
end
describe
'.exists?'
do
context
'when there are enqueued jobs present'
do
let
(
:queue
)
do
[
double
(
args:
[
'Foo'
,
[
10
,
20
]],
queue:
described_class
.
queue
)]
end
before
do
allow
(
Sidekiq
::
Queue
).
to
receive
(
:new
)
.
with
(
described_class
.
queue
)
.
and_return
(
queue
)
end
it
'returns true if specific job exists'
do
expect
(
described_class
.
exists?
(
'Foo'
)).
to
eq
(
true
)
end
it
'returns false if specific job does not exist'
do
expect
(
described_class
.
exists?
(
'Bar'
)).
to
eq
(
false
)
end
end
context
'when there are scheduled jobs present'
,
:sidekiq
,
:redis
do
before
do
Sidekiq
::
Testing
.
disable!
do
BackgroundMigrationWorker
.
perform_in
(
10
.
minutes
,
'Foo'
)
expect
(
Sidekiq
::
ScheduledSet
.
new
).
to
be_one
end
end
after
do
Sidekiq
::
ScheduledSet
.
new
.
clear
end
it
'returns true if specific job exists'
do
expect
(
described_class
.
exists?
(
'Foo'
)).
to
eq
(
true
)
end
it
'returns false if specific job does not exist'
do
expect
(
described_class
.
exists?
(
'Bar'
)).
to
eq
(
false
)
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