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
8ba3de12
Commit
8ba3de12
authored
Oct 06, 2020
by
Jarka Košanová
Committed by
James Lopez
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix scheduling epic migration
parent
1036f80c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
1 deletion
+71
-1
db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb
...e/20190926180443_schedule_epic_issues_after_epics_move.rb
+1
-1
ee/spec/migrations/20190926180443_schedule_epic_issues_after_epics_move_spec.rb
...90926180443_schedule_epic_issues_after_epics_move_spec.rb
+70
-0
No files found.
db/post_migrate/20190926180443_schedule_epic_issues_after_epics_move.rb
View file @
8ba3de12
...
...
@@ -25,7 +25,7 @@ class ScheduleEpicIssuesAfterEpicsMove < ActiveRecord::Migration[5.2]
Epic
.
each_batch
(
of:
BATCH_SIZE
)
do
|
batch
,
index
|
range
=
batch
.
pluck
(
'MIN(id)'
,
'MAX(id)'
).
first
delay
=
index
*
INTERVAL
BackgroundMigrationWorker
.
perform_in
(
delay
,
MIGRATION
,
*
range
)
BackgroundMigrationWorker
.
perform_in
(
delay
,
MIGRATION
,
range
)
end
end
...
...
ee/spec/migrations/20190926180443_schedule_epic_issues_after_epics_move_spec.rb
0 → 100644
View file @
8ba3de12
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20190926180443_schedule_epic_issues_after_epics_move.rb'
)
RSpec
.
describe
ScheduleEpicIssuesAfterEpicsMove
do
let
(
:users
)
{
table
(
:users
)
}
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:epics
)
{
table
(
:epics
)
}
let
(
:issues
)
{
table
(
:issues
)
}
let
(
:epic_issues
)
{
table
(
:epic_issues
)
}
let
(
:user
)
{
users
.
create!
(
name:
'test'
,
email:
'test@example.com'
,
projects_limit:
5
)
}
let
(
:group
)
{
namespaces
.
create!
(
name:
'gitlab'
,
path:
'gitlab-org'
)
}
let
(
:project
)
{
projects
.
create!
(
namespace_id:
group
.
id
,
name:
'foo'
)
}
let
(
:epic_params
)
do
{
title:
'Epic'
,
title_html:
'Epic'
,
group_id:
group
.
id
,
author_id:
user
.
id
}
end
let
(
:issue_params
)
do
{
title:
'Issue'
,
title_html:
'Issue'
,
project_id:
project
.
id
,
author_id:
user
.
id
}
end
let!
(
:epic_1
)
{
epics
.
create!
(
epic_params
.
merge
(
iid:
1
,
relative_position:
100
))
}
let!
(
:epic_2
)
{
epics
.
create!
(
epic_params
.
merge
(
iid:
2
,
relative_position:
200
))
}
let!
(
:epic_3
)
{
epics
.
create!
(
epic_params
.
merge
(
iid:
3
,
relative_position:
300
))
}
let
(
:issue
)
{
issues
.
create!
(
issue_params
.
merge
(
iid:
1
))
}
let!
(
:epic_issue
)
{
epic_issues
.
create!
(
issue_id:
issue
.
id
,
epic_id:
epic_1
.
id
,
relative_position:
1
)
}
before
do
stub_const
(
"
#{
described_class
}
::BATCH_SIZE"
,
2
)
end
it
'schedules background migrations at correct time'
,
:aggregate_failures
do
Sidekiq
::
Testing
.
fake!
do
Timecop
.
freeze
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
(
be_scheduled_delayed_migration
(
5
.
minutes
,
epic_1
.
id
,
epic_2
.
id
)
)
expect
(
described_class
::
MIGRATION
).
to
(
be_scheduled_delayed_migration
(
10
.
minutes
,
epic_3
.
id
,
epic_3
.
id
)
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
(
2
)
end
end
end
it
'processes scheduled background migrations'
,
:sidekiq_inline
do
perform_enqueued_jobs
do
expect
(
epic_issue
.
relative_position
).
to
eq
(
1
)
migrate!
expect
(
epic_issue
.
reload
.
relative_position
).
to
be
>
300
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