mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 02:31:29 +00:00
Add structured test id upload support to resuldb uploader
Not sure how to roll this to src after landing. This is similar to changes for structured-test-ids in changes such as: https://source.chromium.org/chromium/chromium/src/+/main:testing/scripts/common.py;l=203?q=common.py&ss=chromium Bug:418015486 Change-Id: I742a6a9e7b04735e31aa1b893a1cbffc9d6e3188 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7173696 Commit-Queue: Benjamin Joyce (Ben) <bjoyce@google.com> Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
This commit is contained in:
@@ -37,11 +37,19 @@ class ResultSink(object):
|
||||
elapsed_time: the time taken to invoke the presubmit function
|
||||
failure_reason (str or None): if set, the failure reason
|
||||
"""
|
||||
# Source comes from:
|
||||
# infra/go/src/go.chromium.org/luci/resultdb/sink/proto/v1/test_result.proto
|
||||
struct_test_dict = {
|
||||
'coarseName': None, # Not used for flat tests.
|
||||
'fineName': None, # Not used for flat tests.
|
||||
'caseNameComponents': [str(function_name)],
|
||||
}
|
||||
tr = {
|
||||
'testId': self._prefix + function_name,
|
||||
'status': status,
|
||||
'expected': status == STATUS_PASS,
|
||||
'duration': '{:.9f}s'.format(elapsed_time)
|
||||
'duration': '{:.9f}s'.format(elapsed_time),
|
||||
'testIdStructured': struct_test_dict,
|
||||
}
|
||||
if failure_reason:
|
||||
if len(failure_reason) > _FAILURE_REASON_LENGTH_LIMIT:
|
||||
|
||||
@@ -76,6 +76,12 @@ class TestClient(unittest.TestCase):
|
||||
|
||||
|
||||
class TestResultSink(unittest.TestCase):
|
||||
struct_test_dict = {
|
||||
'coarseName': None,
|
||||
'fineName': None,
|
||||
'caseNameComponents': ['function_foo'],
|
||||
}
|
||||
|
||||
def test_report(self):
|
||||
session = mock.MagicMock()
|
||||
sink = rdb_wrapper.ResultSink(session, 'http://host', 'test_id_prefix/')
|
||||
@@ -85,6 +91,7 @@ class TestResultSink(unittest.TestCase):
|
||||
'status': rdb_wrapper.STATUS_PASS,
|
||||
'expected': True,
|
||||
'duration': '123.000000000s',
|
||||
'testIdStructured': TestResultSink.struct_test_dict,
|
||||
}
|
||||
session.post.assert_called_once_with(
|
||||
'http://host',
|
||||
@@ -100,6 +107,7 @@ class TestResultSink(unittest.TestCase):
|
||||
'status': rdb_wrapper.STATUS_PASS,
|
||||
'expected': True,
|
||||
'duration': '123.000000000s',
|
||||
'testIdStructured': TestResultSink.struct_test_dict,
|
||||
'failureReason': {
|
||||
'primaryErrorMessage': 'Bad CL.',
|
||||
},
|
||||
@@ -121,6 +129,7 @@ class TestResultSink(unittest.TestCase):
|
||||
'status': rdb_wrapper.STATUS_PASS,
|
||||
'expected': True,
|
||||
'duration': '123.000000000s',
|
||||
'testIdStructured': TestResultSink.struct_test_dict,
|
||||
'failureReason': {
|
||||
'primaryErrorMessage': expected_truncated_error,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user