Skip to content

Commit

Permalink
[processor] Save the merged report
Browse files Browse the repository at this point in the history
This change makes the results processor to save the merged report
instead of just the last chunk of the report if the original report is
chunked when uploaded.

Besides, it also sets the channel label (stable/experimental) based on a
new property in the report, `run_info.browser_channel`, introduced in
web-platform-tests/wpt#12679 .
  • Loading branch information
Hexcles committed Sep 7, 2018
1 parent 082fb61 commit 96482c7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
12 changes: 10 additions & 2 deletions results-processor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,19 @@ def task_handler():
# to tell TaskQueue to drop the task.
return ('', HTTPStatus.NO_CONTENT)

resp = "{} results loaded from {}\n".format(len(report.results), gcs_path)
resp = "{} results loaded from {}\n".format(
len(report.results), str(gcs_paths))

raw_results_gcs_path = '/{}/{}/report.json'.format(
config.raw_results_bucket(), report.sha_product_path)
gsutil.copy('gs:/' + gcs_path, 'gs:/' + raw_results_gcs_path)
if result_type == 'single':
# If the original report isn't chunked, we store it directly without
# the roundtrip to serialize it back.
gsutil.copy('gs:/' + gcs_paths[0], 'gs:/' + raw_results_gcs_path)
else:
with tempfile.NamedTemporaryFile(suffix='.json.gz') as temp:
report.serialize_gzip(temp.name)
gsutil.copy(temp.name, 'gs:/' + raw_results_gcs_path, gzipped=True)

tempdir = tempfile.mkdtemp()
try:
Expand Down
17 changes: 15 additions & 2 deletions results-processor/wptreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,16 @@ def finalize(self):
self.sha_product_path
self.test_run_metadata

def serialize_gzip(self, filepath):
"""Serializes and gzips the in-memory report to a file.
finalize() should be called first.
Args:
filepath: A file path to write to.
"""
self.write_gzip_json(filepath, self._report)


def prepare_labels(report, labels_str, uploader):
"""Prepares the list of labels for a test run.
Expand All @@ -438,9 +448,12 @@ def prepare_labels(report, labels_str, uploader):
# Empty labels may be generated here, but they will be removed later.
for label in labels_str.split(','):
labels.add(label.strip())
# Set the default channel to stable.
if ('stable' not in labels) and ('experimental' not in labels):
labels.add('stable')
# Extract browser_channel into a label; default to "stable".
if report.run_info.get('browser_channel') in {'nightly', 'dev'}:
labels.add('experimental')
else:
labels.add('stable')
# Remove any empty labels.
if '' in labels:
labels.remove('')
Expand Down
26 changes: 26 additions & 0 deletions results-processor/wptreport_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,29 @@ def test_prepare_labels_from_experimental_label(self):
prepare_labels(r, 'experimental', 'blade-runner'),
['blade-runner', 'experimental', 'firefox']
)

def test_prepare_labels_from_stable_label(self):
r = WPTReport()
r.update_metadata(browser_name='firefox')
self.assertListEqual(
prepare_labels(r, 'stable', 'blade-runner'),
['blade-runner', 'firefox', 'stable']
)

def test_prepare_labels_from_browser_channel(self):
r = WPTReport()
r._report = {
'run_info': {
'product': 'firefox',
'browser_channel': 'dev',
}
}
self.assertListEqual(
prepare_labels(r, '', 'blade-runner'),
['blade-runner', 'experimental', 'firefox']
)
r._report['run_info']['browser_channel'] = 'nightly'
self.assertListEqual(
prepare_labels(r, '', 'blade-runner'),
['blade-runner', 'experimental', 'firefox']
)

0 comments on commit 96482c7

Please sign in to comment.