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
57fba881
Commit
57fba881
authored
Feb 21, 2022
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for post-migration scheduling
parent
0ee6c61d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
db/post_migrate/20220204194347_encrypt_integration_properties.rb
..._migrate/20220204194347_encrypt_integration_properties.rb
+8
-3
spec/migrations/20220204194347_encrypt_integration_properties_spec.rb
...ons/20220204194347_encrypt_integration_properties_spec.rb
+40
-0
No files found.
db/post_migrate/20220204194347_encrypt_integration_properties.rb
View file @
57fba881
...
...
@@ -3,13 +3,18 @@
class
EncryptIntegrationProperties
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
MIGRATION
=
'EncryptIntegrationProperties'
BATCH_SIZE
=
5_000
INTERVAL
=
2
.
minutes
.
to_i
def
up
requiring_update
=
define_batchable_model
(
'integrations'
).
where
.
not
(
properties:
nil
)
queue_background_migration_jobs_by_range_at_intervals
(
define_batchable_model
(
'integrations'
).
where
.
not
(
properties:
nil
)
,
requiring_update
,
MIGRATION
,
2
.
minutes
.
to_i
,
track_jobs:
true
INTERVAL
,
track_jobs:
true
,
batch_size:
BATCH_SIZE
)
end
...
...
spec/migrations/20220204194347_encrypt_integration_properties_spec.rb
0 → 100644
View file @
57fba881
# frozen_string_literal: true
require
'spec_helper'
require_migration!
RSpec
.
describe
EncryptIntegrationProperties
,
:migration
,
schema:
20220204193000
do
subject
(
:migration
)
{
described_class
.
new
}
let
(
:integrations
)
{
table
(
:integrations
)
}
before
do
stub_const
(
"
#{
described_class
.
name
}
::BATCH_SIZE"
,
2
)
end
it
'correctly schedules background migrations'
,
:aggregate_failures
do
# update required
record1
=
integrations
.
create!
(
properties:
some_props
)
record2
=
integrations
.
create!
(
properties:
some_props
)
record3
=
integrations
.
create!
(
properties:
some_props
)
# no update required
integrations
.
create!
(
properties:
nil
)
Sidekiq
::
Testing
.
fake!
do
freeze_time
do
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
record1
.
id
,
record2
.
id
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_migration
(
record3
.
id
,
record3
.
id
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
(
2
)
end
end
end
def
some_props
{
iid:
generate
(
:iid
),
url:
generate
(
:url
),
username:
generate
(
:username
)
}.
to_json
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