Skip to content

Commit

Permalink
[tools/perf] Mark stories as failed in the case of metrics failure
Browse files Browse the repository at this point in the history
Telemetry marks stories as failed when there is a problem with metrics
computation. This CL reproduces the same behavior in Results Processor.

Bug: 1010041
Change-Id: Idb0b86fc30c2cc4a9e8fd18feb56737501f34487
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1840654
Reviewed-by: Juan Antonio Navarro Pérez <perezju@chromium.org>
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Cr-Commit-Position: refs/heads/master@{#702867}
  • Loading branch information
Mikhail Khokhlov authored and Commit Bot committed Oct 4, 2019
1 parent 9d2521d commit d420c5b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/perf/core/results_processor/compute_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def _PoolWorker(test_result):
test_result['testPath'], time.time() - start))

if mre_result.failures:
test_result['status'] = 'FAIL'
for f in mre_result.failures:
logging.error('Failure recorded for test %s: %s',
test_result['testPath'], f)
Expand Down Expand Up @@ -92,6 +93,7 @@ def ComputeTBMv2Metrics(intermediate_results):
# details.
# TODO(crbug.com/1010041): Return a non-zero exit code in this case.
if trace_size_in_mib > 400:
test_result['status'] = 'FAIL'
logging.error('%s: Trace size is too big: %s MiB',
test_result['testPath'], trace_size_in_mib)
continue
Expand Down
28 changes: 28 additions & 0 deletions tools/perf/core/results_processor/compute_metrics_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from core.results_processor import compute_metrics
from core.results_processor import testing

from tracing.mre import failure
from tracing.mre import job
from tracing.mre import mre_result
from tracing.value import histogram

Expand Down Expand Up @@ -47,6 +49,8 @@ def testComputeTBMv2Metrics(self):
histogram_dicts = compute_metrics.ComputeTBMv2Metrics(in_results)

self.assertEqual(histogram_dicts, [test_dict, test_dict])
self.assertEqual(in_results['testResults'][0]['status'], 'PASS')
self.assertEqual(in_results['testResults'][1]['status'], 'PASS')

def testComputeTBMv2MetricsTraceTooBig(self):
in_results = testing.IntermediateResults([
Expand All @@ -66,3 +70,27 @@ def testComputeTBMv2MetricsTraceTooBig(self):
run_metrics_mock.assert_not_called()

self.assertEqual(histogram_dicts, [])
self.assertEqual(in_results['testResults'][0]['status'], 'FAIL')

def testComputeTBMv2MetricsFailure(self):
in_results = testing.IntermediateResults([
testing.TestResult(
'benchmark/story1',
artifacts={
compute_metrics.HTML_TRACE_NAME:
testing.Artifact('/trace1.html', 'gs://trace1.html')},
tags=['tbmv2:metric1'],
),
])

metrics_result = mre_result.MreResult()
metrics_result.AddFailure(failure.Failure(job.Job(0), 0, 0, 0, 0, 0))

with mock.patch(GETSIZE_METHOD) as getsize_mock:
with mock.patch(RUN_METRICS_METHOD) as run_metrics_mock:
getsize_mock.return_value = 100
run_metrics_mock.return_value = metrics_result
histogram_dicts = compute_metrics.ComputeTBMv2Metrics(in_results)

self.assertEqual(histogram_dicts, [])
self.assertEqual(in_results['testResults'][0]['status'], 'FAIL')

0 comments on commit d420c5b

Please sign in to comment.