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
39373637
Commit
39373637
authored
Apr 08, 2021
by
Scott Hampton
Committed by
Douglas Barbosa Alexandre
Apr 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test report summary to graphql
parent
1be0fefa
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
273 additions
and
0 deletions
+273
-0
app/graphql/resolvers/ci/test_report_summary_resolver.rb
app/graphql/resolvers/ci/test_report_summary_resolver.rb
+17
-0
app/graphql/types/ci/pipeline_type.rb
app/graphql/types/ci/pipeline_type.rb
+6
-0
app/graphql/types/ci/test_report_summary_type.rb
app/graphql/types/ci/test_report_summary_type.rb
+19
-0
app/graphql/types/ci/test_report_total_type.rb
app/graphql/types/ci/test_report_total_type.rb
+33
-0
app/graphql/types/ci/test_suite_summary_type.rb
app/graphql/types/ci/test_suite_summary_type.rb
+41
-0
changelogs/unreleased/be-test-report-summary-graphql.yml
changelogs/unreleased/be-test-report-summary-graphql.yml
+5
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+60
-0
spec/graphql/resolvers/ci/test_report_summary_resolver_spec.rb
...graphql/resolvers/ci/test_report_summary_resolver_spec.rb
+46
-0
spec/graphql/types/ci/pipeline_type_spec.rb
spec/graphql/types/ci/pipeline_type_spec.rb
+1
-0
spec/graphql/types/ci/test_report_summary_type_spec.rb
spec/graphql/types/ci/test_report_summary_type_spec.rb
+15
-0
spec/graphql/types/ci/test_report_total_type_spec.rb
spec/graphql/types/ci/test_report_total_type_spec.rb
+15
-0
spec/graphql/types/ci/test_suite_summary_type_spec.rb
spec/graphql/types/ci/test_suite_summary_type_spec.rb
+15
-0
No files found.
app/graphql/resolvers/ci/test_report_summary_resolver.rb
0 → 100644
View file @
39373637
# frozen_string_literal: true
module
Resolvers
module
Ci
class
TestReportSummaryResolver
<
BaseResolver
type
::
Types
::
Ci
::
TestReportSummaryType
,
null:
true
alias_method
:pipeline
,
:object
def
resolve
(
**
args
)
TestReportSummarySerializer
.
new
(
project:
pipeline
.
project
,
current_user:
@current_user
)
.
represent
(
pipeline
.
test_report_summary
)
end
end
end
end
app/graphql/types/ci/pipeline_type.rb
View file @
39373637
...
@@ -122,6 +122,12 @@ module Types
...
@@ -122,6 +122,12 @@ module Types
method: :uses_needs?
,
method: :uses_needs?
,
description:
'Indicates if the pipeline has jobs with `needs` dependencies.'
description:
'Indicates if the pipeline has jobs with `needs` dependencies.'
field
:test_report_summary
,
Types
::
Ci
::
TestReportSummaryType
,
null:
false
,
description:
'Summary of the test report generated by the pipeline.'
,
resolver:
Resolvers
::
Ci
::
TestReportSummaryResolver
def
detailed_status
def
detailed_status
object
.
detailed_status
(
current_user
)
object
.
detailed_status
(
current_user
)
end
end
...
...
app/graphql/types/ci/test_report_summary_type.rb
0 → 100644
View file @
39373637
# frozen_string_literal: true
module
Types
module
Ci
# rubocop: disable Graphql/AuthorizeTypes
# This is presented through `PipelineType` that has its own authorization
class
TestReportSummaryType
<
BaseObject
graphql_name
'TestReportSummary'
description
'Test report for a pipeline'
field
:total
,
Types
::
Ci
::
TestReportTotalType
,
null:
false
,
description:
'Total report statistics for a pipeline test report.'
field
:test_suites
,
Types
::
Ci
::
TestSuiteSummaryType
.
connection_type
,
null:
false
,
description:
'Test suites belonging to a pipeline test report.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
app/graphql/types/ci/test_report_total_type.rb
0 → 100644
View file @
39373637
# frozen_string_literal: true
module
Types
module
Ci
# rubocop: disable Graphql/AuthorizeTypes
class
TestReportTotalType
<
BaseObject
graphql_name
'TestReportTotal'
description
'Total test report statistics.'
field
:time
,
GraphQL
::
FLOAT_TYPE
,
null:
true
,
description:
'Total duration of the tests.'
field
:count
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of the test cases.'
field
:success
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of test cases that succeeded.'
field
:failed
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of test cases that failed.'
field
:skipped
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of test cases that were skipped.'
field
:error
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of test cases that had an error.'
field
:suite_error
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Test suite error message.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
app/graphql/types/ci/test_suite_summary_type.rb
0 → 100644
View file @
39373637
# frozen_string_literal: true
module
Types
module
Ci
# rubocop: disable Graphql/AuthorizeTypes
class
TestSuiteSummaryType
<
BaseObject
graphql_name
'TestSuiteSummary'
description
'Test suite summary in a pipeline test report.'
connection_type_class
(
Types
::
CountableConnectionType
)
field
:name
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Name of the test suite.'
field
:total_time
,
GraphQL
::
FLOAT_TYPE
,
null:
true
,
description:
'Total duration of the tests in the test suite.'
field
:total_count
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of the test cases in the test suite.'
field
:success_count
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of test cases that succeeded in the test suite.'
field
:failed_count
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of test cases that failed in the test suite.'
field
:skipped_count
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of test cases that were skipped in the test suite.'
field
:error_count
,
GraphQL
::
INT_TYPE
,
null:
true
,
description:
'Total number of test cases that had an error.'
field
:suite_error
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Test suite error message.'
field
:build_ids
,
[
GraphQL
::
ID_TYPE
],
null:
true
,
description:
'IDs of the builds used to run the test suite.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
changelogs/unreleased/be-test-report-summary-graphql.yml
0 → 100644
View file @
39373637
---
title
:
Add GraphQL endpoint for test report summary for pipelines
merge_request
:
58596
author
:
type
:
added
doc/api/graphql/reference/index.md
View file @
39373637
...
@@ -4691,6 +4691,7 @@ Information about pagination in a connection.
...
@@ -4691,6 +4691,7 @@ Information about pagination in a connection.
|
`stages`
|
[
`CiStageConnection`
](
#cistageconnection
)
| Stages of the pipeline. |
|
`stages`
|
[
`CiStageConnection`
](
#cistageconnection
)
| Stages of the pipeline. |
|
`startedAt`
|
[
`Time`
](
#time
)
| Timestamp when the pipeline was started. |
|
`startedAt`
|
[
`Time`
](
#time
)
| Timestamp when the pipeline was started. |
|
`status`
|
[
`PipelineStatusEnum!`
](
#pipelinestatusenum
)
| Status of the pipeline (CREATED, WAITING_FOR_RESOURCE, PREPARING, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL, SCHEDULED). |
|
`status`
|
[
`PipelineStatusEnum!`
](
#pipelinestatusenum
)
| Status of the pipeline (CREATED, WAITING_FOR_RESOURCE, PREPARING, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL, SCHEDULED). |
|
`testReportSummary`
|
[
`TestReportSummary!`
](
#testreportsummary
)
| Summary of the test report generated by the pipeline. |
|
`updatedAt`
|
[
`Time!`
](
#time
)
| Timestamp of the pipeline's last activity. |
|
`updatedAt`
|
[
`Time!`
](
#time
)
| Timestamp of the pipeline's last activity. |
|
`upstream`
|
[
`Pipeline`
](
#pipeline
)
| Pipeline that triggered the pipeline. |
|
`upstream`
|
[
`Pipeline`
](
#pipeline
)
| Pipeline that triggered the pipeline. |
|
`user`
|
[
`User`
](
#user
)
| Pipeline user. |
|
`user`
|
[
`User`
](
#user
)
| Pipeline user. |
...
@@ -6225,6 +6226,65 @@ An edge in a connection.
...
@@ -6225,6 +6226,65 @@ An edge in a connection.
|
`cursor`
|
[
`String!`
](
#string
)
| A cursor for use in pagination. |
|
`cursor`
|
[
`String!`
](
#string
)
| A cursor for use in pagination. |
|
`node`
|
[
`TestReport`
](
#testreport
)
| The item at the end of the edge. |
|
`node`
|
[
`TestReport`
](
#testreport
)
| The item at the end of the edge. |
### `TestReportSummary`
Test report for a pipeline.
| Field | Type | Description |
| ----- | ---- | ----------- |
|
`testSuites`
|
[
`TestSuiteSummaryConnection!`
](
#testsuitesummaryconnection
)
| Test suites belonging to a pipeline test report. |
|
`total`
|
[
`TestReportTotal!`
](
#testreporttotal
)
| Total report statistics for a pipeline test report. |
### `TestReportTotal`
Total test report statistics.
| Field | Type | Description |
| ----- | ---- | ----------- |
|
`count`
|
[
`Int`
](
#int
)
| Total number of the test cases. |
|
`error`
|
[
`Int`
](
#int
)
| Total number of test cases that had an error. |
|
`failed`
|
[
`Int`
](
#int
)
| Total number of test cases that failed. |
|
`skipped`
|
[
`Int`
](
#int
)
| Total number of test cases that were skipped. |
|
`success`
|
[
`Int`
](
#int
)
| Total number of test cases that succeeded. |
|
`suiteError`
|
[
`String`
](
#string
)
| Test suite error message. |
|
`time`
|
[
`Float`
](
#float
)
| Total duration of the tests. |
### `TestSuiteSummary`
Test suite summary in a pipeline test report.
| Field | Type | Description |
| ----- | ---- | ----------- |
|
`buildIds`
|
[
`[ID!]`
](
#id
)
| IDs of the builds used to run the test suite. |
|
`errorCount`
|
[
`Int`
](
#int
)
| Total number of test cases that had an error. |
|
`failedCount`
|
[
`Int`
](
#int
)
| Total number of test cases that failed in the test suite. |
|
`name`
|
[
`String`
](
#string
)
| Name of the test suite. |
|
`skippedCount`
|
[
`Int`
](
#int
)
| Total number of test cases that were skipped in the test suite. |
|
`successCount`
|
[
`Int`
](
#int
)
| Total number of test cases that succeeded in the test suite. |
|
`suiteError`
|
[
`String`
](
#string
)
| Test suite error message. |
|
`totalCount`
|
[
`Int`
](
#int
)
| Total number of the test cases in the test suite. |
|
`totalTime`
|
[
`Float`
](
#float
)
| Total duration of the tests in the test suite. |
### `TestSuiteSummaryConnection`
The connection type for TestSuiteSummary.
| Field | Type | Description |
| ----- | ---- | ----------- |
|
`count`
|
[
`Int!`
](
#int
)
| Total count of collection. |
|
`edges`
|
[
`[TestSuiteSummaryEdge]`
](
#testsuitesummaryedge
)
| A list of edges. |
|
`nodes`
|
[
`[TestSuiteSummary]`
](
#testsuitesummary
)
| A list of nodes. |
|
`pageInfo`
|
[
`PageInfo!`
](
#pageinfo
)
| Information to aid in pagination. |
### `TestSuiteSummaryEdge`
An edge in a connection.
| Field | Type | Description |
| ----- | ---- | ----------- |
|
`cursor`
|
[
`String!`
](
#string
)
| A cursor for use in pagination. |
|
`node`
|
[
`TestSuiteSummary`
](
#testsuitesummary
)
| The item at the end of the edge. |
### `TimeReportStats`
### `TimeReportStats`
Represents the time report stats for timeboxes.
Represents the time report stats for timeboxes.
...
...
spec/graphql/resolvers/ci/test_report_summary_resolver_spec.rb
0 → 100644
View file @
39373637
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Resolvers
::
Ci
::
TestReportSummaryResolver
do
include
GraphqlHelpers
describe
'#resolve'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
subject
(
:resolve_subject
)
{
resolve
(
described_class
,
obj:
pipeline
)
}
context
'when pipeline has build report results'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:with_report_results
,
project:
project
)
}
it
'returns test report summary data'
do
expect
(
resolve_subject
.
keys
).
to
contain_exactly
(
:total
,
:test_suites
)
expect
(
resolve_subject
[
:test_suites
][
0
].
keys
).
to
contain_exactly
(
:build_ids
,
:name
,
:total_time
,
:total_count
,
:success_count
,
:failed_count
,
:skipped_count
,
:error_count
,
:suite_error
)
expect
(
resolve_subject
[
:total
][
:time
]).
to
eq
(
0.42
)
expect
(
resolve_subject
[
:total
][
:count
]).
to
eq
(
2
)
expect
(
resolve_subject
[
:total
][
:success
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:failed
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:skipped
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:error
]).
to
eq
(
2
)
expect
(
resolve_subject
[
:total
][
:suite_error
]).
to
eq
(
nil
)
end
end
context
'when pipeline does not have build report results'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
it
'renders test report summary data'
do
expect
(
resolve_subject
.
keys
).
to
contain_exactly
(
:total
,
:test_suites
)
expect
(
resolve_subject
[
:test_suites
]).
to
eq
([])
expect
(
resolve_subject
[
:total
][
:time
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:count
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:success
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:failed
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:skipped
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:error
]).
to
eq
(
0
)
expect
(
resolve_subject
[
:total
][
:suite_error
]).
to
eq
(
nil
)
end
end
end
end
spec/graphql/types/ci/pipeline_type_spec.rb
View file @
39373637
...
@@ -13,6 +13,7 @@ RSpec.describe Types::Ci::PipelineType do
...
@@ -13,6 +13,7 @@ RSpec.describe Types::Ci::PipelineType do
coverage created_at updated_at started_at finished_at committed_at
coverage created_at updated_at started_at finished_at committed_at
stages user retryable cancelable jobs source_job job downstream
stages user retryable cancelable jobs source_job job downstream
upstream path project active user_permissions warnings commit_path uses_needs
upstream path project active user_permissions warnings commit_path uses_needs
test_report_summary
]
]
if
Gitlab
.
ee?
if
Gitlab
.
ee?
...
...
spec/graphql/types/ci/test_report_summary_type_spec.rb
0 → 100644
View file @
39373637
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Types
::
Ci
::
TestReportSummaryType
do
specify
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'TestReportSummary'
)
}
it
'contains attributes related to a pipeline test report summary'
do
expected_fields
=
%w[
total test_suites
]
expect
(
described_class
).
to
have_graphql_fields
(
*
expected_fields
)
end
end
spec/graphql/types/ci/test_report_total_type_spec.rb
0 → 100644
View file @
39373637
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Types
::
Ci
::
TestReportTotalType
do
specify
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'TestReportTotal'
)
}
it
'contains attributes related to a pipeline test report summary'
do
expected_fields
=
%w[
time count success failed skipped error suite_error
]
expect
(
described_class
).
to
have_graphql_fields
(
*
expected_fields
)
end
end
spec/graphql/types/ci/test_suite_summary_type_spec.rb
0 → 100644
View file @
39373637
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Types
::
Ci
::
TestSuiteSummaryType
do
specify
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'TestSuiteSummary'
)
}
it
'contains attributes related to a pipeline test report summary'
do
expected_fields
=
%w[
name total_time total_count success_count failed_count skipped_count error_count suite_error build_ids
]
expect
(
described_class
).
to
have_graphql_fields
(
*
expected_fields
)
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