Commit cb0ec148 authored by Ben Pastene's avatar Ben Pastene Committed by Commit Bot

android: Allow custom artifacts to be passed to result_sink.Post().

I'd like to use this lib to upload Chrome OS tests to rdb as well. Some
of the tests have some artifacts that should be attached to their
results.

So this CL lets the caller of result_sink.Post() specify custom
artifacts.

Bug: 1129654
Change-Id: I35bc4009020d724e38adebb4af3cebd12a7b44be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504579Reviewed-by: default avatarbenjamin joyce <bjoyce@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821786}
parent 3bfb3223
...@@ -57,7 +57,7 @@ class ResultSinkClient(object): ...@@ -57,7 +57,7 @@ class ResultSinkClient(object):
'Authorization': 'ResultSink %s' % context['auth_token'], 'Authorization': 'ResultSink %s' % context['auth_token'],
} }
def Post(self, test_id, status, test_log): def Post(self, test_id, status, test_log, artifacts=None):
"""Uploads the test result to the ResultSink server. """Uploads the test result to the ResultSink server.
This assumes that the rdb stream has been called already and that This assumes that the rdb stream has been called already and that
...@@ -67,6 +67,7 @@ class ResultSinkClient(object): ...@@ -67,6 +67,7 @@ class ResultSinkClient(object):
test_id: A string representing the test's name. test_id: A string representing the test's name.
status: A string representing if the test passed, failed, etc... status: A string representing if the test passed, failed, etc...
test_log: A string representing the test's output. test_log: A string representing the test's output.
artifacts: An optional dict of artifacts to attach to the test.
Returns: Returns:
N/A N/A
...@@ -91,8 +92,11 @@ class ResultSinkClient(object): ...@@ -91,8 +92,11 @@ class ResultSinkClient(object):
'summaryHtml': test_log_formatted, 'summaryHtml': test_log_formatted,
'testId': test_id, 'testId': test_id,
} }
artifacts = artifacts or {}
if len(test_log) > report_check_size: if len(test_log) > report_check_size:
tr['artifacts'] = {'Test Log': {'contents': base64.b64encode(test_log)}} artifacts.update({'Test Log': {'contents': base64.b64encode(test_log)}})
if artifacts:
tr['artifacts'] = artifacts
res = requests.post(url=self.url, res = requests.post(url=self.url,
headers=self.headers, headers=self.headers,
......
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