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
0ae3fc6b
Commit
0ae3fc6b
authored
Feb 25, 2021
by
Erick Bajao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include suite errors in test summary
Exposes suite_error in test suite summary.
parent
eb17d3ce
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
109 additions
and
5 deletions
+109
-5
app/models/ci/build_report_result.rb
app/models/ci/build_report_result.rb
+4
-0
app/serializers/test_suite_summary_entity.rb
app/serializers/test_suite_summary_entity.rb
+2
-0
app/services/ci/build_report_result_service.rb
app/services/ci/build_report_result_service.rb
+2
-1
changelogs/unreleased/eb-test-summary-suite-error.yml
changelogs/unreleased/eb-test-summary-suite-error.yml
+5
-0
lib/gitlab/ci/reports/test_suite_summary.rb
lib/gitlab/ci/reports/test_suite_summary.rb
+10
-1
spec/factories/ci/build_report_results.rb
spec/factories/ci/build_report_results.rb
+27
-2
spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb
spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb
+33
-1
spec/serializers/test_suite_summary_entity_spec.rb
spec/serializers/test_suite_summary_entity_spec.rb
+4
-0
spec/services/ci/build_report_result_service_spec.rb
spec/services/ci/build_report_result_service_spec.rb
+22
-0
No files found.
app/models/ci/build_report_result.rb
View file @
0ae3fc6b
...
@@ -38,6 +38,10 @@ module Ci
...
@@ -38,6 +38,10 @@ module Ci
tests
.
dig
(
"skipped"
).
to_i
tests
.
dig
(
"skipped"
).
to_i
end
end
def
suite_error
tests
.
dig
(
"suite_error"
)
end
def
tests_total
def
tests_total
[
tests_success
,
tests_failed
,
tests_errored
,
tests_skipped
].
sum
[
tests_success
,
tests_failed
,
tests_errored
,
tests_skipped
].
sum
end
end
...
...
app/serializers/test_suite_summary_entity.rb
View file @
0ae3fc6b
...
@@ -4,4 +4,6 @@ class TestSuiteSummaryEntity < TestSuiteEntity
...
@@ -4,4 +4,6 @@ class TestSuiteSummaryEntity < TestSuiteEntity
expose
:build_ids
do
|
summary
|
expose
:build_ids
do
|
summary
|
summary
.
build_ids
summary
.
build_ids
end
end
expose
:suite_error
end
end
app/services/ci/build_report_result_service.rb
View file @
0ae3fc6b
...
@@ -33,7 +33,8 @@ module Ci
...
@@ -33,7 +33,8 @@ module Ci
failed:
test_suite
.
failed_count
,
failed:
test_suite
.
failed_count
,
errored:
test_suite
.
error_count
,
errored:
test_suite
.
error_count
,
skipped:
test_suite
.
skipped_count
,
skipped:
test_suite
.
skipped_count
,
success:
test_suite
.
success_count
success:
test_suite
.
success_count
,
suite_error:
test_suite
.
suite_error
}
}
}
}
end
end
...
...
changelogs/unreleased/eb-test-summary-suite-error.yml
0 → 100644
View file @
0ae3fc6b
---
title
:
Display suite errors on test summary page
merge_request
:
55770
author
:
type
:
changed
lib/gitlab/ci/reports/test_suite_summary.rb
View file @
0ae3fc6b
...
@@ -4,6 +4,8 @@ module Gitlab
...
@@ -4,6 +4,8 @@ module Gitlab
module
Ci
module
Ci
module
Reports
module
Reports
class
TestSuiteSummary
class
TestSuiteSummary
include
Gitlab
::
Utils
::
StrongMemoize
def
initialize
(
build_report_results
)
def
initialize
(
build_report_results
)
@build_report_results
=
build_report_results
@build_report_results
=
build_report_results
end
end
...
@@ -42,6 +44,12 @@ module Gitlab
...
@@ -42,6 +44,12 @@ module Gitlab
end
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
suite_error
strong_memoize
(
:suite_error
)
do
@build_report_results
.
map
(
&
:suite_error
).
compact
.
first
end
end
def
to_h
def
to_h
{
{
time:
total_time
,
time:
total_time
,
...
@@ -49,7 +57,8 @@ module Gitlab
...
@@ -49,7 +57,8 @@ module Gitlab
success:
success_count
,
success:
success_count
,
failed:
failed_count
,
failed:
failed_count
,
skipped:
skipped_count
,
skipped:
skipped_count
,
error:
error_count
error:
error_count
,
suite_error:
suite_error
}
}
end
end
end
end
...
...
spec/factories/ci/build_report_results.rb
View file @
0ae3fc6b
...
@@ -4,10 +4,15 @@ FactoryBot.define do
...
@@ -4,10 +4,15 @@ FactoryBot.define do
factory
:ci_build_report_result
,
class:
'Ci::BuildReportResult'
do
factory
:ci_build_report_result
,
class:
'Ci::BuildReportResult'
do
build
factory: :ci_build
build
factory: :ci_build
project
factory: :project
project
factory: :project
transient
do
test_suite_name
{
"rspec"
}
end
data
do
data
do
{
{
tests:
{
tests:
{
name:
"rspec"
,
name:
test_suite_name
,
duration:
0.42
,
duration:
0.42
,
failed:
0
,
failed:
0
,
errored:
2
,
errored:
2
,
...
@@ -21,7 +26,7 @@ FactoryBot.define do
...
@@ -21,7 +26,7 @@ FactoryBot.define do
data
do
data
do
{
{
tests:
{
tests:
{
name:
"rspec"
,
name:
test_suite_name
,
duration:
0.42
,
duration:
0.42
,
failed:
0
,
failed:
0
,
errored:
0
,
errored:
0
,
...
@@ -31,5 +36,25 @@ FactoryBot.define do
...
@@ -31,5 +36,25 @@ FactoryBot.define do
}
}
end
end
end
end
trait
:with_junit_suite_error
do
transient
do
test_suite_error
{
"some error"
}
end
data
do
{
tests:
{
name:
test_suite_name
,
duration:
0.42
,
failed:
0
,
errored:
0
,
skipped:
0
,
success:
2
,
suite_error:
test_suite_error
}
}
end
end
end
end
end
end
spec/lib/gitlab/ci/reports/test_suite_summary_spec.rb
View file @
0ae3fc6b
...
@@ -87,12 +87,44 @@ RSpec.describe Gitlab::Ci::Reports::TestSuiteSummary do
...
@@ -87,12 +87,44 @@ RSpec.describe Gitlab::Ci::Reports::TestSuiteSummary do
end
end
end
end
describe
'#suite_error'
do
subject
(
:suite_error
)
{
test_suite_summary
.
suite_error
}
context
'when there are no build report results with suite errors'
do
it
{
is_expected
.
to
be_nil
}
end
context
'when there are build report results with suite errors'
do
let
(
:build_report_result_1
)
do
build
(
:ci_build_report_result
,
:with_junit_suite_error
,
test_suite_name:
'karma'
,
test_suite_error:
'karma parsing error'
)
end
let
(
:build_report_result_2
)
do
build
(
:ci_build_report_result
,
:with_junit_suite_error
,
test_suite_name:
'karma'
,
test_suite_error:
'another karma parsing error'
)
end
it
'includes the first suite error from the collection of build report results'
do
expect
(
suite_error
).
to
eq
(
'karma parsing error'
)
end
end
end
describe
'#to_h'
do
describe
'#to_h'
do
subject
{
test_suite_summary
.
to_h
}
subject
{
test_suite_summary
.
to_h
}
context
'when test suite summary has several build report results'
do
context
'when test suite summary has several build report results'
do
it
'returns the total as a hash'
do
it
'returns the total as a hash'
do
expect
(
subject
).
to
include
(
:time
,
:count
,
:success
,
:failed
,
:skipped
,
:error
)
expect
(
subject
).
to
include
(
:time
,
:count
,
:success
,
:failed
,
:skipped
,
:error
,
:suite_error
)
end
end
end
end
end
end
...
...
spec/serializers/test_suite_summary_entity_spec.rb
View file @
0ae3fc6b
...
@@ -20,5 +20,9 @@ RSpec.describe TestSuiteSummaryEntity do
...
@@ -20,5 +20,9 @@ RSpec.describe TestSuiteSummaryEntity do
it
'contains the build_ids'
do
it
'contains the build_ids'
do
expect
(
as_json
).
to
include
(
:build_ids
)
expect
(
as_json
).
to
include
(
:build_ids
)
end
end
it
'contains the suite_error'
do
expect
(
as_json
).
to
include
(
:suite_error
)
end
end
end
end
end
spec/services/ci/build_report_result_service_spec.rb
View file @
0ae3fc6b
...
@@ -26,6 +26,28 @@ RSpec.describe Ci::BuildReportResultService do
...
@@ -26,6 +26,28 @@ RSpec.describe Ci::BuildReportResultService do
expect
(
unique_test_cases_parsed
).
to
eq
(
4
)
expect
(
unique_test_cases_parsed
).
to
eq
(
4
)
end
end
context
'and build has test report parsing errors'
do
let
(
:build
)
{
create
(
:ci_build
,
:success
,
:broken_test_reports
)
}
it
'creates a build report result entry with suite error'
,
:aggregate_failures
do
expect
(
build_report_result
.
tests_name
).
to
eq
(
"test"
)
expect
(
build_report_result
.
tests_success
).
to
eq
(
0
)
expect
(
build_report_result
.
tests_failed
).
to
eq
(
0
)
expect
(
build_report_result
.
tests_errored
).
to
eq
(
0
)
expect
(
build_report_result
.
tests_skipped
).
to
eq
(
0
)
expect
(
build_report_result
.
tests_duration
).
to
eq
(
0
)
expect
(
build_report_result
.
suite_error
).
to
be_present
expect
(
Ci
::
BuildReportResult
.
count
).
to
eq
(
1
)
unique_test_cases_parsed
=
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
unique_events
(
event_names:
described_class
::
EVENT_NAME
,
start_date:
2
.
weeks
.
ago
,
end_date:
2
.
weeks
.
from_now
)
expect
(
unique_test_cases_parsed
).
to
eq
(
0
)
end
end
context
'when data has already been persisted'
do
context
'when data has already been persisted'
do
it
'raises an error and do not persist the same data twice'
do
it
'raises an error and do not persist the same data twice'
do
expect
{
2
.
times
{
described_class
.
new
.
execute
(
build
)
}
}.
to
raise_error
(
ActiveRecord
::
RecordNotUnique
)
expect
{
2
.
times
{
described_class
.
new
.
execute
(
build
)
}
}.
to
raise_error
(
ActiveRecord
::
RecordNotUnique
)
...
...
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