Commit ff3792e9 authored by Mikhail Khokhlov's avatar Mikhail Khokhlov Committed by Commit Bot

[tools/perf] Fix links to local traces in traceUrls diagnostic

Bug: 1027074
Change-Id: I077c164aaa59ee6644f9f05ee61a26944d6a23c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928701
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Reviewed-by: default avatarJuan Antonio Navarro Pérez <perezju@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717639}
parent 58d83b49
...@@ -259,11 +259,15 @@ def UploadArtifacts(test_result, upload_bucket, run_identifier): ...@@ -259,11 +259,15 @@ def UploadArtifacts(test_result, upload_bucket, run_identifier):
artifact['remoteUrl']) artifact['remoteUrl'])
def _GetTraceUrl(test_result): def GetTraceUrl(test_result):
artifacts = test_result.get('outputArtifacts', {}) artifacts = test_result.get('outputArtifacts', {})
trace_artifact = artifacts.get(compute_metrics.HTML_TRACE_NAME, {}) trace_artifact = artifacts.get(compute_metrics.HTML_TRACE_NAME, {})
return (trace_artifact['remoteUrl'] if 'remoteUrl' in trace_artifact if 'remoteUrl' in trace_artifact:
else trace_artifact.get('filePath')) return trace_artifact['remoteUrl']
elif 'filePath' in trace_artifact:
return 'file://' + trace_artifact['filePath']
else:
return None
def AddDiagnosticsToHistograms(test_result, test_suite_start, results_label, def AddDiagnosticsToHistograms(test_result, test_suite_start, results_label,
...@@ -295,7 +299,7 @@ def AddDiagnosticsToHistograms(test_result, test_suite_start, results_label, ...@@ -295,7 +299,7 @@ def AddDiagnosticsToHistograms(test_result, test_suite_start, results_label,
story_tags = [tag['value'] for tag in test_result.get('tags', []) story_tags = [tag['value'] for tag in test_result.get('tags', [])
if tag['key'] == 'story_tag'] if tag['key'] == 'story_tag']
result_id = int(test_result.get('resultId', 0)) result_id = int(test_result.get('resultId', 0))
trace_url = _GetTraceUrl(test_result) trace_url = GetTraceUrl(test_result)
additional_diagnostics = [ additional_diagnostics = [
(reserved_infos.BENCHMARKS, test_suite), (reserved_infos.BENCHMARKS, test_suite),
......
...@@ -148,3 +148,28 @@ class ResultsProcessorUnitTests(unittest.TestCase): ...@@ -148,3 +148,28 @@ class ResultsProcessorUnitTests(unittest.TestCase):
def testMeasurementToHistogramUnknownUnits(self): def testMeasurementToHistogramUnknownUnits(self):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
processor.MeasurementToHistogram('a', {'unit': 'yards', 'samples': [9]}) processor.MeasurementToHistogram('a', {'unit': 'yards', 'samples': [9]})
def testGetTraceUrlRemote(self):
test_result = testing.TestResult(
'benchmark/story',
output_artifacts={
'trace.html': testing.Artifact('trace.html', 'gs://trace.html')
},
)
url = processor.GetTraceUrl(test_result)
self.assertEqual(url, 'gs://trace.html')
def testGetTraceUrlLocal(self):
test_result = testing.TestResult(
'benchmark/story',
output_artifacts={
'trace.html': testing.Artifact('trace.html')
},
)
url = processor.GetTraceUrl(test_result)
self.assertEqual(url, 'file://trace.html')
def testGetTraceUrlEmpty(self):
test_result = testing.TestResult('benchmark/story')
url = processor.GetTraceUrl(test_result)
self.assertIsNone(url)
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