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
a27940e9
Commit
a27940e9
authored
Feb 05, 2020
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for scheduling migration
parent
f45fa930
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
db/post_migrate/20200127111840_fix_projects_without_project_feature.rb
...te/20200127111840_fix_projects_without_project_feature.rb
+2
-1
spec/migrations/fix_projects_without_project_feature_spec.rb
spec/migrations/fix_projects_without_project_feature_spec.rb
+42
-0
No files found.
db/post_migrate/20200127111840_fix_projects_without_project_feature.rb
View file @
a27940e9
...
...
@@ -4,6 +4,7 @@ class FixProjectsWithoutProjectFeature < ActiveRecord::Migration[5.2]
include
Gitlab
::
Database
::
MigrationHelpers
BATCH_SIZE
=
50_000
MIGRATION
=
'FixProjectsWithoutProjectFeature'
disable_ddl_transaction!
...
...
@@ -12,7 +13,7 @@ class FixProjectsWithoutProjectFeature < ActiveRecord::Migration[5.2]
end
def
up
queue_background_migration_jobs_by_range_at_intervals
(
Project
,
'FixProjectsWithoutProjectFeature'
,
2
.
minutes
,
batch_size:
BATCH_SIZE
)
queue_background_migration_jobs_by_range_at_intervals
(
Project
,
MIGRATION
,
2
.
minutes
,
batch_size:
BATCH_SIZE
)
end
def
down
...
...
spec/migrations/fix_projects_without_project_feature_spec.rb
0 → 100644
View file @
a27940e9
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20200127111840_fix_projects_without_project_feature.rb'
)
describe
FixProjectsWithoutProjectFeature
,
:migration
do
let
(
:namespace
)
{
table
(
:namespaces
).
create
(
name:
'gitlab'
,
path:
'gitlab-org'
)
}
let!
(
:projects
)
do
[
table
(
:projects
).
create
(
namespace_id:
namespace
.
id
,
name:
'foo 1'
),
table
(
:projects
).
create
(
namespace_id:
namespace
.
id
,
name:
'foo 2'
),
table
(
:projects
).
create
(
namespace_id:
namespace
.
id
,
name:
'foo 3'
)
]
end
before
do
stub_const
(
"
#{
described_class
.
name
}
::BATCH_SIZE"
,
2
)
end
around
do
|
example
|
Sidekiq
::
Testing
.
fake!
do
Timecop
.
freeze
do
example
.
call
end
end
end
it
'schedules jobs for ranges of projects'
do
migrate!
expect
(
described_class
::
MIGRATION
)
.
to
be_scheduled_delayed_migration
(
2
.
minutes
,
projects
[
0
].
id
,
projects
[
1
].
id
)
expect
(
described_class
::
MIGRATION
)
.
to
be_scheduled_delayed_migration
(
4
.
minutes
,
projects
[
2
].
id
,
projects
[
2
].
id
)
end
it
'schedules jobs according to the configured batch size'
do
expect
{
migrate!
}.
to
change
{
BackgroundMigrationWorker
.
jobs
.
size
}.
by
(
2
)
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