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
e178135d
Commit
e178135d
authored
Feb 06, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more specs for unique stages index migration
parent
066d4dea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
...igrate/20180119121225_remove_redundant_pipeline_stages.rb
+4
-1
spec/migrations/remove_redundant_pipeline_stages_spec.rb
spec/migrations/remove_redundant_pipeline_stages_spec.rb
+16
-5
No files found.
db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
View file @
e178135d
...
...
@@ -11,7 +11,10 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration
add_unique_index!
rescue
ActiveRecord
::
RecordNotUnique
retry
if
(
attempts
-=
1
)
>
0
raise
raise
StandardError
,
<<~
EOS
Failed to add an unique index to ci_stages, despite retrying the
migration 100 times. See gitlab-org/gitlab-ce!16580.
EOS
end
def
down
...
...
spec/migrations/remove_redundant_pipeline_stages_spec.rb
View file @
e178135d
...
...
@@ -37,12 +37,23 @@ describe RemoveRedundantPipelineStages, :migration do
expect
(
builds
.
all
.
pluck
(
:stage_id
).
compact
).
to
eq
[
102
]
end
it
'retries when duplicated stages are being created during migration'
do
it
'retries when incorrectly added index exception is caught'
do
allow_any_instance_of
(
described_class
)
.
to
receive
(
:remove_redundant_pipeline_stages!
)
expect_any_instance_of
(
described_class
)
.
to
receive
(
:remove_outdated_index!
)
.
exactly
(
100
).
times
.
and_call_original
expect
{
migrate!
}
.
to
raise_error
StandardError
,
/Failed to add an unique index/
end
it
'does not retry when unknown exception is being raised'
do
allow
(
subject
).
to
receive
(
:remove_outdated_index!
)
expect
(
subject
).
to
receive
(
:remove_redundant_pipeline_stages!
).
exactly
(
3
).
times
allow
(
subject
).
to
receive
(
:add_unique_index!
)
.
and_raise
(
ActiveRecord
::
RecordNotUnique
.
new
(
'Duplicated stages present!'
))
expect
(
subject
).
to
receive
(
:remove_redundant_pipeline_stages!
).
once
allow
(
subject
).
to
receive
(
:add_unique_index!
).
and_raise
(
StandardError
)
expect
{
subject
.
up
(
attempts:
3
)
}.
to
raise_error
ActiveRecord
::
RecordNotUnique
expect
{
subject
.
up
(
attempts:
3
)
}.
to
raise_error
StandardError
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