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
Boxiang Sun
gitlab-ce
Commits
cff9504a
Commit
cff9504a
authored
8 years ago
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend specs for build and pipeline retry services
parent
82e6efb8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
16 deletions
+87
-16
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+25
-0
spec/services/ci/retry_pipeline_service_spec.rb
spec/services/ci/retry_pipeline_service_spec.rb
+62
-16
No files found.
spec/services/ci/retry_build_service_spec.rb
View file @
cff9504a
...
...
@@ -53,4 +53,29 @@ describe Ci::RetryBuildService, :services do
end
end
end
describe
'#reprocess'
do
let
(
:new_build
)
{
service
.
reprocess
(
build
)
}
context
'when user has ability to execute build'
do
before
do
project
.
team
<<
[
user
,
:developer
]
end
it
'creates a new build that represents the old one'
do
expect
(
new_build
.
name
).
to
eq
build
.
name
end
it
'does not enqueue the new build'
do
expect
(
new_build
).
to
be_created
end
end
context
'when user does not have ability to execute build'
do
it
'raises an error'
do
expect
{
service
.
reprocess
(
build
)
}
.
to
raise_error
Gitlab
::
Access
::
AccessDeniedError
end
end
end
end
This diff is collapsed.
Click to expand it.
spec/services/ci/retry_pipeline_service_spec.rb
View file @
cff9504a
...
...
@@ -30,7 +30,7 @@ describe Ci::RetryPipelineService, '#execute', :services do
create_build
(
'rspec 1'
,
:failed
,
0
)
create_build
(
'rspec 2'
,
:canceled
,
0
)
create_build
(
'rspec 3'
,
:canceled
,
1
)
create_build
(
'
deploy
1'
,
:canceled
,
2
)
create_build
(
'
spinach
1'
,
:canceled
,
2
)
end
it
'retries builds failed builds and marks subsequent for processing'
do
...
...
@@ -39,7 +39,7 @@ describe Ci::RetryPipelineService, '#execute', :services do
expect
(
build
(
'rspec 1'
)).
to
be_pending
expect
(
build
(
'rspec 2'
)).
to
be_pending
expect
(
build
(
'rspec 3'
)).
to
be_created
expect
(
build
(
'
deploy
1'
)).
to
be_created
expect
(
build
(
'
spinach
1'
)).
to
be_created
expect
(
pipeline
.
reload
).
to
be_running
end
end
...
...
@@ -52,7 +52,7 @@ describe Ci::RetryPipelineService, '#execute', :services do
create_build
(
'report 1'
,
:failed
,
2
)
end
it
'retries builds
failed builds and marks subsequent for processing
'
do
it
'retries builds
only in the first stage
'
do
service
.
execute
(
pipeline
)
expect
(
build
(
'rspec 1'
)).
to
be_pending
...
...
@@ -65,12 +65,12 @@ describe Ci::RetryPipelineService, '#execute', :services do
it
'creates a new job for report job in this case'
do
service
.
execute
(
pipeline
)
# TODO, expect to be_retried
expect
(
statuses
.
where
(
name:
'report 1'
).
count
).
to
eq
2
expect
(
statuses
.
where
(
name:
'report 1'
).
first
).
to
be_retried
end
end
context
'when there is canceled manual build in first stage'
do
context
'when pipeline contains manual actions'
do
context
'when there is a canceled manual action in first stage'
do
before
do
create_build
(
'rspec 1'
,
:failed
,
0
)
create_build
(
'staging'
,
:canceled
,
0
,
:manual
)
...
...
@@ -86,6 +86,52 @@ describe Ci::RetryPipelineService, '#execute', :services do
expect
(
pipeline
.
reload
).
to
be_running
end
end
context
'when there is a skipped manual action in last stage'
do
before
do
create_build
(
'rspec 1'
,
:canceled
,
0
)
create_build
(
'staging'
,
:skipped
,
1
,
:manual
)
end
it
'retries canceled job and skips manual action'
do
service
.
execute
(
pipeline
)
expect
(
build
(
'rspec 1'
)).
to
be_pending
expect
(
build
(
'staging'
)).
to
be_skipped
expect
(
pipeline
.
reload
).
to
be_running
end
end
context
'when there is a created manual action in the last stage'
do
before
do
create_build
(
'rspec 1'
,
:canceled
,
0
)
create_build
(
'staging'
,
:created
,
1
,
:manual
)
end
it
'retries canceled job and does not update the manual action'
do
service
.
execute
(
pipeline
)
expect
(
build
(
'rspec 1'
)).
to
be_pending
expect
(
build
(
'staging'
)).
to
be_created
expect
(
pipeline
.
reload
).
to
be_running
end
end
context
'when there is a created manual action in the first stage'
do
before
do
create_build
(
'rspec 1'
,
:canceled
,
0
)
create_build
(
'staging'
,
:created
,
0
,
:manual
)
end
it
'retries canceled job and skipps the manual action'
do
service
.
execute
(
pipeline
)
expect
(
build
(
'rspec 1'
)).
to
be_pending
expect
(
build
(
'staging'
)).
to
be_skipped
expect
(
pipeline
.
reload
).
to
be_running
end
end
end
end
context
'when user is not allowed to retry pipeline'
do
...
...
This diff is collapsed.
Click to expand it.
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