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
4bca92dd
Commit
4bca92dd
authored
Jul 06, 2020
by
Maxime Orefice
Committed by
Robert Speicher
Jul 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose tests total count in PipelineEntity
parent
e0e69938
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
4 deletions
+81
-4
app/serializers/pipeline_entity.rb
app/serializers/pipeline_entity.rb
+4
-0
spec/controllers/projects/pipelines_controller_spec.rb
spec/controllers/projects/pipelines_controller_spec.rb
+23
-2
spec/serializers/pipeline_entity_spec.rb
spec/serializers/pipeline_entity_spec.rb
+24
-0
spec/serializers/pipeline_serializer_spec.rb
spec/serializers/pipeline_serializer_spec.rb
+30
-2
No files found.
app/serializers/pipeline_entity.rb
View file @
4bca92dd
...
...
@@ -85,6 +85,10 @@ class PipelineEntity < Grape::Entity
pipeline
.
failed_builds
end
expose
:tests_total_count
,
if:
->
(
pipeline
,
_
)
{
Feature
.
enabled?
(
:build_report_summary
,
pipeline
.
project
)
}
do
|
pipeline
|
pipeline
.
test_report_summary
.
total_count
end
private
alias_method
:pipeline
,
:object
...
...
spec/controllers/projects/pipelines_controller_spec.rb
View file @
4bca92dd
...
...
@@ -46,6 +46,26 @@ RSpec.describe Projects::PipelinesController do
end
end
it
'executes N+1 queries'
do
get_pipelines_index_json
control_count
=
ActiveRecord
::
QueryRecorder
.
new
do
get_pipelines_index_json
end
.
count
create_all_pipeline_types
# There appears to be one extra query for Pipelines#has_warnings? for some reason
expect
{
get_pipelines_index_json
}.
not_to
exceed_query_limit
(
control_count
+
7
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'pipelines'
].
count
).
to
eq
12
end
context
'with build_report_summary turned off'
do
before
do
stub_feature_flags
(
build_report_summary:
false
)
end
it
'does not execute N+1 queries'
do
get_pipelines_index_json
...
...
@@ -61,6 +81,7 @@ RSpec.describe Projects::PipelinesController do
expect
(
json_response
[
'pipelines'
].
count
).
to
eq
12
end
end
end
it
'does not include coverage data for the pipelines'
do
get_pipelines_index_json
...
...
spec/serializers/pipeline_entity_spec.rb
View file @
4bca92dd
...
...
@@ -261,5 +261,29 @@ RSpec.describe PipelineEntity do
end
end
end
context
'when pipeline has build report results'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:with_report_results
,
project:
project
,
user:
user
)
}
context
'when feature is enabled'
do
before
do
stub_feature_flags
(
build_report_summary:
true
)
end
it
'exposes tests total count'
do
expect
(
subject
[
:tests_total_count
]).
to
eq
(
2
)
end
end
context
'when feature is disabled'
do
before
do
stub_feature_flags
(
build_report_summary:
false
)
end
it
'do not expose tests total count'
do
expect
(
subject
).
not_to
include
(
:tests_total_count
)
end
end
end
end
end
spec/serializers/pipeline_serializer_spec.rb
View file @
4bca92dd
...
...
@@ -153,6 +153,19 @@ RSpec.describe PipelineSerializer do
context
'with the same ref'
do
let
(
:ref
)
{
'feature'
}
it
'verifies number of queries'
,
:request_store
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expected_queries
=
Gitlab
.
ee?
?
46
:
43
expect
(
recorded
.
count
).
to
be_within
(
2
).
of
(
expected_queries
)
expect
(
recorded
.
cached_count
).
to
eq
(
0
)
end
context
'with the :build_report_summary flag turned off'
do
before
do
stub_feature_flags
(
build_report_summary:
false
)
end
it
'verifies number of queries'
,
:request_store
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expected_queries
=
Gitlab
.
ee?
?
43
:
40
...
...
@@ -161,6 +174,7 @@ RSpec.describe PipelineSerializer do
expect
(
recorded
.
cached_count
).
to
eq
(
0
)
end
end
end
context
'with different refs'
do
def
ref
...
...
@@ -176,12 +190,26 @@ RSpec.describe PipelineSerializer do
# pipeline. With the same ref this check is cached but if refs are
# different then there is an extra query per ref
# https://gitlab.com/gitlab-org/gitlab-foss/issues/46368
expected_queries
=
Gitlab
.
ee?
?
49
:
46
expect
(
recorded
.
count
).
to
be_within
(
2
).
of
(
expected_queries
)
expect
(
recorded
.
cached_count
).
to
eq
(
0
)
end
context
'with the :build_report_summary flag turned off'
do
before
do
stub_feature_flags
(
build_report_summary:
false
)
end
it
'verifies number of queries'
,
:request_store
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expected_queries
=
Gitlab
.
ee?
?
46
:
43
expect
(
recorded
.
count
).
to
be_within
(
2
).
of
(
expected_queries
)
expect
(
recorded
.
cached_count
).
to
eq
(
0
)
end
end
end
def
create_pipeline
(
status
)
create
(
:ci_empty_pipeline
,
...
...
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