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
e61ae8ae
Commit
e61ae8ae
authored
Mar 08, 2022
by
Allison Browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes based on code review
Add specs to cover more statuses
parent
13d51985
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
app/models/concerns/ci/has_status.rb
app/models/concerns/ci/has_status.rb
+3
-0
spec/lib/gitlab/ci/pipeline/chain/cancel_pending_pipelines_spec.rb
...gitlab/ci/pipeline/chain/cancel_pending_pipelines_spec.rb
+31
-8
No files found.
app/models/concerns/ci/has_status.rb
View file @
e61ae8ae
...
...
@@ -7,6 +7,9 @@ module Ci
DEFAULT_STATUS
=
'created'
BLOCKED_STATUS
=
%w[manual scheduled]
.
freeze
AVAILABLE_STATUSES
=
%w[created waiting_for_resource preparing pending running success failed canceled skipped manual scheduled]
.
freeze
# TODO: replace STARTED_STATUSES with data from BUILD_STARTED_RUNNING_STATUSES in https://gitlab.com/gitlab-org/gitlab/-/issues/273378
# see https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82149#note_865508501
BUILD_STARTED_RUNNING_STATUSES
=
%w[running success failed]
.
freeze
STARTED_STATUSES
=
%w[running success failed skipped manual scheduled]
.
freeze
ACTIVE_STATUSES
=
%w[waiting_for_resource preparing pending running]
.
freeze
COMPLETED_STATUSES
=
%w[success failed canceled skipped]
.
freeze
...
...
spec/lib/gitlab/ci/pipeline/chain/cancel_pending_pipelines_spec.rb
View file @
e61ae8ae
...
...
@@ -55,7 +55,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::CancelPendingPipelines do
context
'when the previous pipeline has a child pipeline'
do
let
(
:child_pipeline
)
{
create
(
:ci_pipeline
,
child_of:
prev_pipeline
)
}
context
'when the child pipeline has
only
interruptible running jobs'
do
context
'when the child pipeline has interruptible running jobs'
do
before
do
create
(
:ci_build
,
:interruptible
,
:running
,
pipeline:
child_pipeline
)
create
(
:ci_build
,
:interruptible
,
:running
,
pipeline:
child_pipeline
)
...
...
@@ -88,7 +88,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::CancelPendingPipelines do
context
'when the child pipeline has started non-interruptible job'
do
before
do
create
(
:ci_build
,
:interruptible
,
:running
,
pipeline:
child_pipeline
)
# non-iterruptible started
# non-i
n
terruptible started
create
(
:ci_build
,
:success
,
pipeline:
child_pipeline
)
end
...
...
@@ -104,16 +104,39 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::CancelPendingPipelines do
context
'when the child pipeline has non-interruptible non-started job'
do
before
do
create
(
:ci_build
,
:interruptible
,
:running
,
pipeline:
child_pipeline
)
# non-iterruptible but non-started
create
(
:ci_build
,
:created
,
pipeline:
child_pipeline
)
end
it
'cancels all child pipeline builds'
do
expect
(
build_statuses
(
child_pipeline
)).
to
contain_exactly
(
'running'
,
'created'
)
not_started_statuses
=
Ci
::
HasStatus
::
AVAILABLE_STATUSES
-
Ci
::
HasStatus
::
BUILD_STARTED_RUNNING_STATUSES
context
'when the jobs are cancelable'
do
cancelable_not_started_statuses
=
Set
.
new
(
not_started_statuses
).
intersection
(
Ci
::
HasStatus
::
CANCELABLE_STATUSES
)
cancelable_not_started_statuses
.
each
do
|
status
|
it
'cancels all child pipeline builds'
do
# non-interruptible but non-started
create
(
:ci_build
,
status
.
to_sym
,
pipeline:
child_pipeline
)
perform
expect
(
build_statuses
(
child_pipeline
)).
to
contain_exactly
(
'running'
,
status
)
expect
(
build_statuses
(
child_pipeline
)).
to
contain_exactly
(
'canceled'
,
'canceled'
)
perform
expect
(
build_statuses
(
child_pipeline
)).
to
contain_exactly
(
'canceled'
,
'canceled'
)
end
end
end
context
'when the jobs are not cancelable'
do
not_cancelable_not_started_statuses
=
not_started_statuses
-
Ci
::
HasStatus
::
CANCELABLE_STATUSES
not_cancelable_not_started_statuses
.
each
do
|
status
|
it
'does not cancel child pipeline builds'
do
# non-interruptible but non-started
create
(
:ci_build
,
status
.
to_sym
,
pipeline:
child_pipeline
)
expect
(
build_statuses
(
child_pipeline
)).
to
contain_exactly
(
'running'
,
status
)
perform
expect
(
build_statuses
(
child_pipeline
)).
to
contain_exactly
(
'canceled'
,
status
)
end
end
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