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
476a3da1
Commit
476a3da1
authored
Jul 10, 2020
by
Allison Browne
Committed by
Douglas Barbosa Alexandre
Jul 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add schemas for matching to dag pipelines
Test dag pipeline schemas via a serializer
parent
2c966430
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
0 deletions
+89
-0
spec/fixtures/api/schemas/entities/dag_job.json
spec/fixtures/api/schemas/entities/dag_job.json
+10
-0
spec/fixtures/api/schemas/entities/dag_job_group.json
spec/fixtures/api/schemas/entities/dag_job_group.json
+13
-0
spec/fixtures/api/schemas/entities/dag_pipeline.json
spec/fixtures/api/schemas/entities/dag_pipeline.json
+11
-0
spec/fixtures/api/schemas/entities/dag_stage.json
spec/fixtures/api/schemas/entities/dag_stage.json
+11
-0
spec/serializers/ci/dag_job_entity_spec.rb
spec/serializers/ci/dag_job_entity_spec.rb
+16
-0
spec/serializers/ci/dag_job_group_entity_spec.rb
spec/serializers/ci/dag_job_group_entity_spec.rb
+8
-0
spec/serializers/ci/dag_pipeline_entity_spec.rb
spec/serializers/ci/dag_pipeline_entity_spec.rb
+12
-0
spec/serializers/ci/dag_pipeline_serializer_spec.rb
spec/serializers/ci/dag_pipeline_serializer_spec.rb
+4
-0
spec/serializers/ci/dag_stage_entity_spec.rb
spec/serializers/ci/dag_stage_entity_spec.rb
+4
-0
No files found.
spec/fixtures/api/schemas/entities/dag_job.json
0 → 100644
View file @
476a3da1
{
"type"
:
"object"
,
"required"
:
[
"name"
,
"scheduling_type"
],
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"scheduling_type"
:
{
"type"
:
[
"string"
,
null
]
},
"needs"
:
{
"type"
:
"array"
}
},
"additionalProperties"
:
false
}
spec/fixtures/api/schemas/entities/dag_job_group.json
0 → 100644
View file @
476a3da1
{
"type"
:
"object"
,
"required"
:
[
"name"
,
"size"
,
"jobs"
],
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"size"
:
{
"type"
:
"integer"
},
"jobs"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"dag_job.json"
}
}
},
"additionalProperties"
:
false
}
spec/fixtures/api/schemas/entities/dag_pipeline.json
0 → 100644
View file @
476a3da1
{
"type"
:
"object"
,
"required"
:
[
"stages"
],
"properties"
:
{
"stages"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"dag_stage.json"
}
}
},
"additionalProperties"
:
false
}
spec/fixtures/api/schemas/entities/dag_stage.json
0 → 100644
View file @
476a3da1
{
"type"
:
"object"
,
"required"
:
[
"name"
,
"groups"
],
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"groups"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"dag_job_group.json"
}
}
}
}
spec/serializers/ci/dag_job_entity_spec.rb
View file @
476a3da1
...
@@ -11,10 +11,18 @@ RSpec.describe Ci::DagJobEntity do
...
@@ -11,10 +11,18 @@ RSpec.describe Ci::DagJobEntity do
describe
'#as_json'
do
describe
'#as_json'
do
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
RSpec
.
shared_examples
"matches schema"
do
it
"matches schema"
do
expect
(
subject
.
to_json
).
to
match_schema
(
'entities/dag_job'
)
end
end
it
'contains the name'
do
it
'contains the name'
do
expect
(
subject
[
:name
]).
to
eq
'dag_job'
expect
(
subject
[
:name
]).
to
eq
'dag_job'
end
end
it_behaves_like
"matches schema"
context
'when job is stage scheduled'
do
context
'when job is stage scheduled'
do
it
'contains the name scheduling_type'
do
it
'contains the name scheduling_type'
do
expect
(
subject
[
:scheduling_type
]).
to
eq
'stage'
expect
(
subject
[
:scheduling_type
]).
to
eq
'stage'
...
@@ -23,6 +31,8 @@ RSpec.describe Ci::DagJobEntity do
...
@@ -23,6 +31,8 @@ RSpec.describe Ci::DagJobEntity do
it
'does not expose needs'
do
it
'does not expose needs'
do
expect
(
subject
).
not_to
include
(
:needs
)
expect
(
subject
).
not_to
include
(
:needs
)
end
end
it_behaves_like
"matches schema"
end
end
context
'when job is dag scheduled'
do
context
'when job is dag scheduled'
do
...
@@ -32,18 +42,24 @@ RSpec.describe Ci::DagJobEntity do
...
@@ -32,18 +42,24 @@ RSpec.describe Ci::DagJobEntity do
expect
(
subject
[
:scheduling_type
]).
to
eq
'dag'
expect
(
subject
[
:scheduling_type
]).
to
eq
'dag'
end
end
it_behaves_like
"matches schema"
context
'when job has needs'
do
context
'when job has needs'
do
let!
(
:need
)
{
create
(
:ci_build_need
,
build:
job
,
name:
'compile'
)
}
let!
(
:need
)
{
create
(
:ci_build_need
,
build:
job
,
name:
'compile'
)
}
it
'exposes the array of needs'
do
it
'exposes the array of needs'
do
expect
(
subject
[
:needs
]).
to
eq
[
'compile'
]
expect
(
subject
[
:needs
]).
to
eq
[
'compile'
]
end
end
it_behaves_like
"matches schema"
end
end
context
'when job has empty needs'
do
context
'when job has empty needs'
do
it
'exposes an empty array of needs'
do
it
'exposes an empty array of needs'
do
expect
(
subject
[
:needs
]).
to
eq
[]
expect
(
subject
[
:needs
]).
to
eq
[]
end
end
it_behaves_like
"matches schema"
end
end
end
end
end
end
...
...
spec/serializers/ci/dag_job_group_entity_spec.rb
View file @
476a3da1
...
@@ -31,6 +31,10 @@ RSpec.describe Ci::DagJobGroupEntity do
...
@@ -31,6 +31,10 @@ RSpec.describe Ci::DagJobGroupEntity do
expect
(
exposed_jobs
.
size
).
to
eq
1
expect
(
exposed_jobs
.
size
).
to
eq
1
expect
(
exposed_jobs
.
first
.
fetch
(
:name
)).
to
eq
'test'
expect
(
exposed_jobs
.
first
.
fetch
(
:name
)).
to
eq
'test'
end
end
it
'matches schema'
do
expect
(
subject
.
to_json
).
to
match_schema
(
'entities/dag_job_group'
)
end
end
end
context
'when group contains multiple parallel jobs'
do
context
'when group contains multiple parallel jobs'
do
...
@@ -53,6 +57,10 @@ RSpec.describe Ci::DagJobGroupEntity do
...
@@ -53,6 +57,10 @@ RSpec.describe Ci::DagJobGroupEntity do
expect
(
exposed_jobs
.
first
.
fetch
(
:name
)).
to
eq
'test 1/2'
expect
(
exposed_jobs
.
first
.
fetch
(
:name
)).
to
eq
'test 1/2'
expect
(
exposed_jobs
.
last
.
fetch
(
:name
)).
to
eq
'test 2/2'
expect
(
exposed_jobs
.
last
.
fetch
(
:name
)).
to
eq
'test 2/2'
end
end
it
'matches schema'
do
expect
(
subject
.
to_json
).
to
match_schema
(
'entities/dag_job_group'
)
end
end
end
end
end
end
end
spec/serializers/ci/dag_pipeline_entity_spec.rb
View file @
476a3da1
...
@@ -11,12 +11,20 @@ RSpec.describe Ci::DagPipelineEntity do
...
@@ -11,12 +11,20 @@ RSpec.describe Ci::DagPipelineEntity do
describe
'#as_json'
do
describe
'#as_json'
do
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
RSpec
.
shared_examples
"matches schema"
do
it
'matches schema'
do
expect
(
subject
.
to_json
).
to
match_schema
(
'entities/dag_pipeline'
)
end
end
context
'when pipeline is empty'
do
context
'when pipeline is empty'
do
it
'contains stages'
do
it
'contains stages'
do
expect
(
subject
).
to
include
(
:stages
)
expect
(
subject
).
to
include
(
:stages
)
expect
(
subject
[
:stages
]).
to
be_empty
expect
(
subject
[
:stages
]).
to
be_empty
end
end
it_behaves_like
"matches schema"
end
end
context
'when pipeline has jobs'
do
context
'when pipeline has jobs'
do
...
@@ -30,6 +38,8 @@ RSpec.describe Ci::DagPipelineEntity do
...
@@ -30,6 +38,8 @@ RSpec.describe Ci::DagPipelineEntity do
expect
(
stages
.
size
).
to
eq
3
expect
(
stages
.
size
).
to
eq
3
expect
(
stages
.
map
{
|
s
|
s
[
:name
]
}).
to
contain_exactly
(
'build'
,
'test'
,
'deploy'
)
expect
(
stages
.
map
{
|
s
|
s
[
:name
]
}).
to
contain_exactly
(
'build'
,
'test'
,
'deploy'
)
end
end
it_behaves_like
"matches schema"
end
end
context
'when pipeline has parallel jobs, DAG needs and GenericCommitStatus'
do
context
'when pipeline has parallel jobs, DAG needs and GenericCommitStatus'
do
...
@@ -138,6 +148,8 @@ RSpec.describe Ci::DagPipelineEntity do
...
@@ -138,6 +148,8 @@ RSpec.describe Ci::DagPipelineEntity do
expect
(
subject
.
fetch
(
:stages
)[
2
].
fetch
(
:name
)).
to
eq
'deploy'
expect
(
subject
.
fetch
(
:stages
)[
2
].
fetch
(
:name
)).
to
eq
'deploy'
expect
(
subject
.
fetch
(
:stages
)[
2
]).
to
eq
expected_result
.
fetch
(
:stages
)[
2
]
expect
(
subject
.
fetch
(
:stages
)[
2
]).
to
eq
expected_result
.
fetch
(
:stages
)[
2
]
end
end
it_behaves_like
"matches schema"
end
end
end
end
end
end
spec/serializers/ci/dag_pipeline_serializer_spec.rb
View file @
476a3da1
...
@@ -13,5 +13,9 @@ RSpec.describe Ci::DagPipelineSerializer do
...
@@ -13,5 +13,9 @@ RSpec.describe Ci::DagPipelineSerializer do
expect
(
subject
[
:stages
]).
to
be_present
expect
(
subject
[
:stages
]).
to
be_present
expect
(
subject
[
:stages
].
size
).
to
eq
1
expect
(
subject
[
:stages
].
size
).
to
eq
1
end
end
it
'matches schema'
do
expect
(
subject
.
to_json
).
to
match_schema
(
'entities/dag_pipeline'
)
end
end
end
end
end
spec/serializers/ci/dag_stage_entity_spec.rb
View file @
476a3da1
...
@@ -27,5 +27,9 @@ RSpec.describe Ci::DagStageEntity do
...
@@ -27,5 +27,9 @@ RSpec.describe Ci::DagStageEntity do
expect
(
job_group
[
:size
]).
to
eq
1
expect
(
job_group
[
:size
]).
to
eq
1
expect
(
job_group
[
:jobs
]).
not_to
be_empty
expect
(
job_group
[
:jobs
]).
not_to
be_empty
end
end
it
"matches schema"
do
expect
(
subject
.
to_json
).
to
match_schema
(
'entities/dag_stage'
)
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