Bug 1462783 - Artifact raptor test results in treeherder; r=ahal

MozReview-Commit-ID: FYXU2nVhn3n

--HG--
extra : rebase_source : 9ae83608d6bd7f94736ade618312099d02d8bce5
This commit is contained in:
Rob Wood 2018-05-24 10:50:39 -04:00
parent 801fc7686e
commit 736da4ed3d
2 changed files with 28 additions and 6 deletions

View File

@ -10,6 +10,8 @@ import os
import re
import sys
from shutil import copyfile
import mozharness
from mozharness.base.config import parse_config_file
@ -253,15 +255,22 @@ class Raptor(TestingMixin, MercurialScript, Python3Virtualenv, CodeCoverageMixin
schema = json.load(f)
data = json.loads(parser.found_perf_data[0])
jsonschema.validate(data, schema)
except:
except Exception as e:
self.exception("Error while validating PERFHERDER_DATA")
self.info(e)
def _artifact_perf_data(self, dest):
src = os.path.join(self.query_abs_dirs()['abs_work_dir'], 'local.json')
src = os.path.join(self.query_abs_dirs()['abs_work_dir'], 'raptor.json')
if not os.path.isdir(os.path.dirname(dest)):
# create upload dir if it doesn't already exist
self.info("creating dir: %s" % os.path.dirname(dest))
os.makedirs(os.path.dirname(dest))
self.info('copying raptor results from %s to %s' % (src, dest))
try:
shutil.copyfile(src, dest)
except:
copyfile(src, dest)
except Exception as e:
self.critical("Error copying results %s to upload dir %s" % (src, dest))
self.info(e)
def run_tests(self, args=None, **kw):
"""run raptor tests"""
@ -346,7 +355,9 @@ class Raptor(TestingMixin, MercurialScript, Python3Virtualenv, CodeCoverageMixin
self._validate_treeherder_data(parser)
if not self.run_local:
# copy results to upload dir so they are included as an artifact
self.info("copying raptor results to upload dir:")
dest = os.path.join(env['MOZ_UPLOAD_DIR'], 'perfherder-data.json')
self.info(str(dest))
self._artifact_perf_data(dest)

View File

@ -11,9 +11,11 @@ from __future__ import absolute_import
import filter
import json
import os
from mozlog import get_proxy_logger
LOG = get_proxy_logger(component="output")
LOG = get_proxy_logger(component="raptor-output")
class Output(object):
@ -83,7 +85,14 @@ class Output(object):
LOG.error("error: no summarized raptor results found!")
return False
results_path = "raptor.json"
if os.environ['MOZ_UPLOAD_DIR']:
# i.e. testing/mozharness/build/raptor.json locally; in production it will
# be at /tasks/task_*/build/ (where it will be picked up by mozharness later
# and made into a tc artifact accessible in treeherder as perfherder-data.json)
results_path = os.path.join(os.path.dirname(os.environ['MOZ_UPLOAD_DIR']),
'raptor.json')
else:
results_path = os.path.join(os.getcwd(), 'raptor.json')
with open(results_path, 'w') as f:
for result in self.summarized_results:
@ -96,6 +105,8 @@ class Output(object):
json.dump(self.summarized_results, open(results_path, 'w'), indent=2,
sort_keys=True)
LOG.info("results can also be found locally at: %s" % results_path)
return True
@classmethod