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
9e5be685
Commit
9e5be685
authored
Jun 06, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests for dependent pipelines
parent
163983e0
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
123 additions
and
7 deletions
+123
-7
app/models/ci/sources/pipeline.rb
app/models/ci/sources/pipeline.rb
+7
-0
changelogs/unreleased-ee/add-relation-between-pipelines.yml
changelogs/unreleased-ee/add-relation-between-pipelines.yml
+4
-0
db/fixtures/development/14_pipelines.rb
db/fixtures/development/14_pipelines.rb
+7
-7
spec/factories/ci/sources/pipelines.rb
spec/factories/ci/sources/pipelines.rb
+17
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+4
-0
spec/models/ci/sources/pipeline_spec.rb
spec/models/ci/sources/pipeline_spec.rb
+17
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-0
spec/serializers/pipeline_details_entity_spec.rb
spec/serializers/pipeline_details_entity_spec.rb
+35
-0
spec/workers/expire_pipeline_cache_worker_spec.rb
spec/workers/expire_pipeline_cache_worker_spec.rb
+29
-0
No files found.
app/models/ci/sources/pipeline.rb
View file @
9e5be685
...
...
@@ -9,6 +9,13 @@ module Ci
belongs_to
:source_project
,
class_name:
Project
,
foreign_key: :source_project_id
belongs_to
:source_job
,
class_name:
Ci
::
Build
,
foreign_key: :source_job_id
belongs_to
:source_pipeline
,
class_name:
Ci
::
Pipeline
,
foreign_key: :source_pipeline_id
validates
:project
,
presence:
true
validates
:pipeline
,
presence:
true
validates
:source_project
,
presence:
true
validates
:source_job
,
presence:
true
validates
:source_pipeline
,
presence:
true
end
end
end
changelogs/unreleased-ee/add-relation-between-pipelines.yml
0 → 100644
View file @
9e5be685
---
title
:
Add relation between Pipelines
merge_request
:
author
:
db/fixtures/development/14_pipelines.rb
View file @
9e5be685
...
...
@@ -75,11 +75,11 @@ class Gitlab::Seeder::Pipelines
def
create_master_pipelines
@project
.
repository
.
commits
(
'master'
,
limit:
4
).
map
do
|
commit
|
create_pipeline!
(
@project
,
'master'
,
commit
,
triggerer_pipeline
).
tap
do
|
pipeline
|
triggerer_pipeline
.
tap
do
|
triggerer
_pipeline
|
triggere
r
_pipeline
.
sourced_pipelines
.
create
(
source_job:
triggere
r
_pipeline
.
builds
.
all
.
sample
,
source_project:
triggere
r
_pipeline
.
project
,
create_pipeline!
(
@project
,
'master'
,
commit
).
tap
do
|
pipeline
|
random_pipeline
.
tap
do
|
triggered_by
_pipeline
|
triggere
d_by
_pipeline
.
sourced_pipelines
.
create
(
source_job:
triggere
d_by
_pipeline
.
builds
.
all
.
sample
,
source_project:
triggere
d_by
_pipeline
.
project
,
project:
pipeline
.
project
,
pipeline:
pipeline
)
end
...
...
@@ -104,7 +104,7 @@ class Gitlab::Seeder::Pipelines
[]
end
def
create_pipeline!
(
project
,
ref
,
commit
,
triggerer
=
nil
)
def
create_pipeline!
(
project
,
ref
,
commit
)
project
.
pipelines
.
create
(
sha:
commit
.
id
,
ref:
ref
,
source: :push
)
end
...
...
@@ -158,7 +158,7 @@ class Gitlab::Seeder::Pipelines
@project
.
team
.
users
.
sample
end
def
triggerer
_pipeline
def
random
_pipeline
Ci
::
Pipeline
.
limit
(
4
).
all
.
sample
end
...
...
spec/factories/ci/sources/pipelines.rb
0 → 100644
View file @
9e5be685
FactoryGirl
.
define
do
factory
:ci_sources_pipeline
,
class:
Ci
::
Sources
::
Pipeline
do
after
(
:build
)
do
|
source
|
source
.
project
||=
source
.
pipeline
.
project
source
.
source_pipeline
||=
source
.
source_job
.
pipeline
source
.
source_project
||=
source
.
source_pipeline
.
project
end
trait
:create_source
do
source_job
factory: :ci_build
end
trait
:create_target
do
pipeline
factory: :ci_empty_pipeline
end
end
end
spec/models/ci/build_spec.rb
View file @
9e5be685
...
...
@@ -17,6 +17,7 @@ describe Ci::Build, :models do
it
{
is_expected
.
to
belong_to
(
:trigger_request
)
}
it
{
is_expected
.
to
belong_to
(
:erased_by
)
}
it
{
is_expected
.
to
have_many
(
:deployments
)
}
it
{
is_expected
.
to
have_many
(
:sourced_pipelines
)
}
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
respond_to
(
:has_trace?
)
}
it
{
is_expected
.
to
respond_to
(
:trace
)
}
...
...
spec/models/ci/pipeline_spec.rb
View file @
9e5be685
...
...
@@ -20,6 +20,10 @@ describe Ci::Pipeline, models: true do
it
{
is_expected
.
to
have_many
(
:builds
)
}
it
{
is_expected
.
to
have_many
(
:auto_canceled_pipelines
)
}
it
{
is_expected
.
to
have_many
(
:auto_canceled_jobs
)
}
it
{
is_expected
.
to
have_one
(
:source_pipeline
)
}
it
{
is_expected
.
to
have_many
(
:sourced_pipelines
)
}
it
{
is_expected
.
to
have_many
(
:triggered_by_pipeline
)
}
it
{
is_expected
.
to
have_many
(
:triggered_pipelines
)
}
it
{
is_expected
.
to
validate_presence_of
(
:sha
)
}
it
{
is_expected
.
to
validate_presence_of
(
:status
)
}
...
...
spec/models/ci/sources/pipeline_spec.rb
0 → 100644
View file @
9e5be685
require
'spec_helper'
describe
Ci
::
Sources
::
Pipeline
,
models:
true
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:pipeline
)
}
it
{
is_expected
.
to
belong_to
(
:source_project
)
}
it
{
is_expected
.
to
belong_to
(
:source_job
)
}
it
{
is_expected
.
to
belong_to
(
:source_pipeline
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:pipeline
)
}
it
{
is_expected
.
to
validate_presence_of
(
:source_project
)
}
it
{
is_expected
.
to
validate_presence_of
(
:source_job
)
}
it
{
is_expected
.
to
validate_presence_of
(
:source_pipeline
)
}
end
spec/models/project_spec.rb
View file @
9e5be685
...
...
@@ -77,6 +77,8 @@ describe Project, models: true do
it
{
is_expected
.
to
have_many
(
:approver_groups
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:pipeline_schedules
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:sourced_pipelines
)
}
it
{
is_expected
.
to
have_many
(
:source_pipelines
)
}
context
'after initialized'
do
it
"has a project_feature"
do
...
...
spec/serializers/pipeline_details_entity_spec.rb
View file @
9e5be685
...
...
@@ -116,5 +116,40 @@ describe PipelineDetailsEntity do
expect
(
subject
[
:flags
][
:yaml_errors
]).
to
be
false
end
end
context
'when pipeline is triggered by other pipeline'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
before
do
create
(
:ci_sources_pipeline
,
:create_source
,
pipeline:
pipeline
)
end
it
'contains an information about depedent pipeline'
do
expect
(
subject
[
:triggered_by
]).
to
be_a
(
Hash
)
expect
(
subject
[
:triggered_by
][
:path
]).
not_to
be_nil
expect
(
subject
[
:triggered_by
][
:details
]).
not_to
be_nil
expect
(
subject
[
:triggered_by
][
:details
][
:status
]).
not_to
be_nil
expect
(
subject
[
:triggered_by
][
:project
]).
not_to
be_nil
end
end
context
'when pipeline triggered other pipeline'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
create
(
:ci_sources_pipeline
,
:create_target
,
source_job:
build
)
create
(
:ci_sources_pipeline
,
:create_target
,
source_job:
build
)
end
it
'contains an information about depedent pipeline'
do
expect
(
subject
[
:triggered
]).
to
be_a
(
Array
)
expect
(
subject
[
:triggered
].
length
).
to
eq
(
2
)
expect
(
subject
[
:triggered
].
first
[
:path
]).
not_to
be_nil
expect
(
subject
[
:triggered
].
first
[
:details
]).
not_to
be_nil
expect
(
subject
[
:triggered
].
first
[
:details
][
:status
]).
not_to
be_nil
expect
(
subject
[
:triggered
].
first
[
:project
]).
not_to
be_nil
end
end
end
end
spec/workers/expire_pipeline_cache_worker_spec.rb
View file @
9e5be685
...
...
@@ -42,5 +42,34 @@ describe ExpirePipelineCacheWorker do
subject
.
perform
(
pipeline
.
id
)
end
context
'when pipeline is triggered by other pipeline'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:source
)
{
create
(
:ci_sources_pipeline
,
:create_source
,
pipeline:
pipeline
)
}
it
'updates the cache of dependent pipeline'
do
dependent_pipeline_path
=
"/
#{
source
.
source_project
.
full_path
}
/pipelines/
#{
source
.
source_pipeline
.
id
}
.json"
allow_any_instance_of
(
Gitlab
::
EtagCaching
::
Store
).
to
receive
(
:touch
)
expect_any_instance_of
(
Gitlab
::
EtagCaching
::
Store
).
to
receive
(
:touch
).
with
(
dependent_pipeline_path
)
subject
.
perform
(
pipeline
.
id
)
end
end
context
'when pipeline triggered other pipeline'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:source
)
{
create
(
:ci_sources_pipeline
,
:create_target
,
source_job:
build
)
}
it
'updates the cache of dependent pipeline'
do
dependent_pipeline_path
=
"/
#{
source
.
project
.
full_path
}
/pipelines/
#{
source
.
pipeline
.
id
}
.json"
allow_any_instance_of
(
Gitlab
::
EtagCaching
::
Store
).
to
receive
(
:touch
)
expect_any_instance_of
(
Gitlab
::
EtagCaching
::
Store
).
to
receive
(
:touch
).
with
(
dependent_pipeline_path
)
subject
.
perform
(
pipeline
.
id
)
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