Commit b1d99fbb authored by mfluharty's avatar mfluharty

Mark xUnit test errors as errors, not failures

Give STATUS_ERROR instead of STATUS_FAILED
Add error_count and lists of errors to test report/suite comparers
parent 26f6f719
...@@ -7,6 +7,7 @@ class TestReportsComparerEntity < Grape::Entity ...@@ -7,6 +7,7 @@ class TestReportsComparerEntity < Grape::Entity
expose :total_count, as: :total expose :total_count, as: :total
expose :resolved_count, as: :resolved expose :resolved_count, as: :resolved
expose :failed_count, as: :failed expose :failed_count, as: :failed
expose :error_count, as: :errored
end end
expose :suite_comparers, as: :suites, using: TestSuiteComparerEntity expose :suite_comparers, as: :suites, using: TestSuiteComparerEntity
......
...@@ -11,6 +11,7 @@ class TestSuiteComparerEntity < Grape::Entity ...@@ -11,6 +11,7 @@ class TestSuiteComparerEntity < Grape::Entity
expose :total_count, as: :total expose :total_count, as: :total
expose :resolved_count, as: :resolved expose :resolved_count, as: :resolved
expose :failed_count, as: :failed expose :failed_count, as: :failed
expose :error_count, as: :errored
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
...@@ -28,6 +29,20 @@ class TestSuiteComparerEntity < Grape::Entity ...@@ -28,6 +29,20 @@ class TestSuiteComparerEntity < Grape::Entity
max_tests(suite.new_failures, suite.existing_failures)) max_tests(suite.new_failures, suite.existing_failures))
end end
expose :new_errors, using: TestCaseEntity do |suite|
suite.new_errors.take(max_tests)
end
expose :existing_errors, using: TestCaseEntity do |suite|
suite.existing_errors.take(
max_tests(suite.new_errors))
end
expose :resolved_errors, using: TestCaseEntity do |suite|
suite.resolved_errors.take(
max_tests(suite.new_errors, suite.existing_errors))
end
private private
def max_tests(*used) def max_tests(*used)
......
...@@ -50,10 +50,7 @@ module Gitlab ...@@ -50,10 +50,7 @@ module Gitlab
status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED
system_output = data['failure'] system_output = data['failure']
elsif data['error'] elsif data['error']
# For now, as an MVC, we are grouping error test cases together status = ::Gitlab::Ci::Reports::TestCase::STATUS_ERROR
# with failed ones. But we will improve this further on
# https://gitlab.com/gitlab-org/gitlab/issues/32046.
status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED
system_output = data['error'] system_output = data['error']
else else
status = ::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS status = ::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS
......
...@@ -29,7 +29,7 @@ module Gitlab ...@@ -29,7 +29,7 @@ module Gitlab
end end
end end
%w(total_count resolved_count failed_count).each do |method| %w(total_count resolved_count failed_count error_count).each do |method|
define_method(method) do define_method(method) do
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
suite_comparers.sum { |suite| suite.public_send(method) } # rubocop:disable GitlabSecurity/PublicSend suite_comparers.sum { |suite| suite.public_send(method) } # rubocop:disable GitlabSecurity/PublicSend
......
...@@ -38,6 +38,30 @@ module Gitlab ...@@ -38,6 +38,30 @@ module Gitlab
end end
end end
def new_errors
strong_memoize(:new_errors) do
head_suite.error.reject do |key, _|
base_suite.error.include?(key)
end.values
end
end
def existing_errors
strong_memoize(:existing_errors) do
head_suite.error.select do |key, _|
base_suite.error.include?(key)
end.values
end
end
def resolved_errors
strong_memoize(:resolved_errors) do
head_suite.success.select do |key, _|
base_suite.error.include?(key)
end.values
end
end
def total_count def total_count
head_suite.total_count head_suite.total_count
end end
...@@ -47,12 +71,16 @@ module Gitlab ...@@ -47,12 +71,16 @@ module Gitlab
end end
def resolved_count def resolved_count
resolved_failures.count resolved_failures.count + resolved_errors.count
end end
def failed_count def failed_count
new_failures.count + existing_failures.count new_failures.count + existing_failures.count
end end
def error_count
new_errors.count + existing_errors.count
end
end end
end end
end end
......
...@@ -12,11 +12,13 @@ ...@@ -12,11 +12,13 @@
"properties": { "properties": {
"total": { "type": "integer" }, "total": { "type": "integer" },
"resolved": { "type": "integer" }, "resolved": { "type": "integer" },
"errored": { "type": "integer" },
"failed": { "type": "integer" } "failed": { "type": "integer" }
}, },
"required": [ "required": [
"total", "total",
"resolved", "resolved",
"errored",
"failed" "failed"
] ]
}, },
......
...@@ -16,17 +16,17 @@ ...@@ -16,17 +16,17 @@
"properties": { "properties": {
"total": { "type": "integer" }, "total": { "type": "integer" },
"resolved": { "type": "integer" }, "resolved": { "type": "integer" },
"errored": { "type": "integer" },
"failed": { "type": "integer" } "failed": { "type": "integer" }
}, },
"required": [ "required": ["total", "resolved", "errored", "failed"]
"total",
"resolved",
"failed"
]
}, },
"new_failures": { "type": "array", "items": { "$ref": "test_case.json" } }, "new_failures": { "type": "array", "items": { "$ref": "test_case.json" } },
"resolved_failures": { "type": "array", "items": { "$ref": "test_case.json" } }, "resolved_failures": { "type": "array", "items": { "$ref": "test_case.json" } },
"existing_failures": { "type": "array", "items": { "$ref": "test_case.json" } } "existing_failures": { "type": "array", "items": { "$ref": "test_case.json" } },
"new_errors": { "type": "array", "items": { "$ref": "test_case.json" } },
"resolved_errors": { "type": "array", "items": { "$ref": "test_case.json" } },
"existing_errors": { "type": "array", "items": { "$ref": "test_case.json" } }
}, },
"additionalProperties": false "additionalProperties": false
} }
...@@ -99,7 +99,7 @@ describe Gitlab::Ci::Parsers::Test::Junit do ...@@ -99,7 +99,7 @@ describe Gitlab::Ci::Parsers::Test::Junit do
let(:testcase_content) { '<error>Some error</error>' } let(:testcase_content) { '<error>Some error</error>' }
it_behaves_like '<testcase> XML parser', it_behaves_like '<testcase> XML parser',
::Gitlab::Ci::Reports::TestCase::STATUS_FAILED, ::Gitlab::Ci::Reports::TestCase::STATUS_ERROR,
'Some error' 'Some error'
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment