Commit 84ee9f79 authored by Scott Lee's avatar Scott Lee Committed by Commit Bot

[web_tests][resultdb] set testLocation when report a result to rdb-sink

Chromium-deriver is a tool that parses the isolate output of
a test run, and uploads the test results to ResultDB.

Chromium-deriver is currently being used in chromium recipes to upload
the test results of Swarming Tasks to ResultDB, and it has a hard-coded
path for blink_web_tests.
: https://source.chromium.org/chromium/infra/infra/+/master:go/src/go.chromium.org/luci/resultdb/internal/services/deriver/swarming.go;l=190-191
: https://source.chromium.org/chromium/infra/infra/+/master:go/src/go.chromium.org/luci/resultdb/internal/services/deriver/formats/json.go;l=357-359

This CL is to copy the same logic to test_result_sink.py so that
run_web_tests.py with `rdb stream` will generate and upload the same
test results that chromum-deriver uploads for blink_web_tests.

R=robertma@chromium.org
CC=chanli@chromium.org,iannucci@chromium.org,nodir@chromium.org

Bug: 1108016
Change-Id: Ia31bf3435ca9fab70359c64d8485dcd2397c1c07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425750Reviewed-by: default avatarChan Li <chanli@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810326}
parent 6a95b339
...@@ -168,5 +168,13 @@ class TestResultSink(object): ...@@ -168,5 +168,13 @@ class TestResultSink(object):
# 'startTime': result.start_time # 'startTime': result.start_time
'tags': self._tags(result), 'tags': self._tags(result),
'testId': result.test_name, 'testId': result.test_name,
# testLocation is where the test is defined. It is used to find
# the associated component/team/os information in flakiness and
# disabled-test dashboards.
'testLocation': {
'fileName':
'//third_party/blink/web_tests/' + result.test_name,
},
} }
self._send({'testResults': [r]}) self._send({'testResults': [r]})
...@@ -84,6 +84,16 @@ class TestResultSinkMessage(TestResultSinkTestBase): ...@@ -84,6 +84,16 @@ class TestResultSinkMessage(TestResultSinkTestBase):
self.assertEqual(sent_data['status'], 'CRASH') self.assertEqual(sent_data['status'], 'CRASH')
self.assertEqual(sent_data['duration'], '123.456s') self.assertEqual(sent_data['duration'], '123.456s')
def test_test_location(self):
tr = test_results.TestResult('')
prefix = '//third_party/blink/web_tests/'
sink = lambda tr: self.sink(True, tr)['testLocation']['fileName']
tr.test_name = "test-name"
self.assertEqual(sink(tr), prefix + 'test-name')
tr.test_name = "///test-name"
self.assertEqual(sink(tr), prefix + '///test-name')
def test_device_failure(self): def test_device_failure(self):
tr = test_results.TestResult(test_name='test-name') tr = test_results.TestResult(test_name='test-name')
tr.type = ResultType.Failure tr.type = ResultType.Failure
......
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