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
3c487e45
Commit
3c487e45
authored
Dec 18, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for upstream pipeline status interactions
parent
2c5f1aeb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
2 deletions
+84
-2
ee/app/models/ee/ci/bridge.rb
ee/app/models/ee/ci/bridge.rb
+1
-1
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+5
-1
ee/spec/models/ci/pipeline_spec.rb
ee/spec/models/ci/pipeline_spec.rb
+78
-0
No files found.
ee/app/models/ee/ci/bridge.rb
View file @
3c487e45
...
...
@@ -20,7 +20,7 @@ module EE
end
def
schedule_downstream_pipeline!
CreateCrossProjectPipelineWorker
.
perform_async
(
self
.
id
)
::
Ci
::
CreateCrossProjectPipelineWorker
.
perform_async
(
self
.
id
)
end
def
target_user
...
...
ee/app/models/ee/ci/pipeline.rb
View file @
3c487e45
...
...
@@ -5,6 +5,8 @@ module EE
module
Pipeline
extend
ActiveSupport
::
Concern
BridgeStatusError
=
Class
.
new
(
StandardError
)
EE_FAILURE_REASONS
=
{
activity_limit_exceeded:
20
,
size_limit_exceeded:
21
...
...
@@ -21,6 +23,7 @@ module EE
has_many
:sourced_pipelines
,
class_name:
::
Ci
::
Sources
::
Pipeline
,
foreign_key: :source_pipeline_id
has_one
:triggered_by_pipeline
,
through: :source_pipeline
,
source: :source_pipeline
has_one
:source_job
,
through: :source_pipeline
,
source: :source_job
has_one
:source_bridge
,
through: :source_pipeline
,
source: :source_bridge
has_many
:triggered_pipelines
,
through: :sourced_pipelines
,
source: :pipeline
...
...
@@ -110,7 +113,8 @@ module EE
end
def
update_bridge_status!
raise
HasStatus
::
UnknownStatusError
if
source_bridge
.
complete?
raise
ArgumentError
unless
bridge_triggered?
raise
BridgeStatusError
unless
source_bridge
.
active?
source_bridge
.
success!
end
...
...
ee/spec/models/ci/pipeline_spec.rb
View file @
3c487e45
...
...
@@ -393,4 +393,82 @@ describe Ci::Pipeline do
end
end
end
describe
'upstream status interactions'
do
context
'when a pipeline has an upstream status'
do
context
'when an upstream status is a bridge'
do
let
(
:bridge
)
{
create
(
:ci_bridge
,
status: :pending
)
}
before
do
create
(
:ci_sources_pipeline
,
pipeline:
pipeline
,
source_job:
bridge
)
end
describe
'#bridge_triggered?'
do
it
'is a pipeline triggered by a bridge'
do
expect
(
pipeline
).
to
be_bridge_triggered
end
end
describe
'#source_job'
do
it
'has a correct source job'
do
expect
(
pipeline
.
source_job
).
to
eq
bridge
end
end
describe
'#source_bridge'
do
it
'has a correct bridge source'
do
expect
(
pipeline
.
source_bridge
).
to
eq
bridge
end
end
describe
'#update_bridge_status!'
do
it
'can update bridge status if it is running'
do
pipeline
.
update_bridge_status!
expect
(
bridge
.
reload
).
to
be_success
end
it
'can not update bridge status if is not active'
do
bridge
.
success!
expect
{
pipeline
.
update_bridge_status!
}
.
to
raise_error
EE
::
Ci
::
Pipeline
::
BridgeStatusError
end
end
end
context
'when an upstream status is a build'
do
let
(
:build
)
{
create
(
:ci_build
)
}
before
do
create
(
:ci_sources_pipeline
,
pipeline:
pipeline
,
source_job:
build
)
end
describe
'#bridge_triggered?'
do
it
'is a pipeline that has not been triggered by a bridge'
do
expect
(
pipeline
).
not_to
be_bridge_triggered
end
end
describe
'#source_job'
do
it
'has a correct source job'
do
expect
(
pipeline
.
source_job
).
to
eq
build
end
end
describe
'#source_bridge'
do
it
'has does not have a bridge source'
do
expect
(
pipeline
.
source_bridge
).
to
be_nil
end
end
describe
'#update_bridge_status!'
do
it
'can not update upstream job status'
do
expect
{
pipeline
.
update_bridge_status!
}
.
to
raise_error
ArgumentError
end
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