2016-09-27 13:52:26 +00:00
|
|
|
# Copyright 2016 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
# Recipe for uploading DM results.
|
|
|
|
|
|
|
|
|
2017-04-10 12:19:10 +00:00
|
|
|
import calendar
|
|
|
|
|
|
|
|
|
2016-09-27 13:52:26 +00:00
|
|
|
DEPS = [
|
2017-06-16 17:10:22 +00:00
|
|
|
'recipe_engine/file',
|
2017-04-10 12:19:10 +00:00
|
|
|
'recipe_engine/json',
|
|
|
|
'recipe_engine/path',
|
2016-09-27 13:52:26 +00:00
|
|
|
'recipe_engine/properties',
|
2017-04-10 12:19:10 +00:00
|
|
|
'recipe_engine/step',
|
|
|
|
'recipe_engine/time',
|
2016-09-27 13:52:26 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2017-09-15 13:56:24 +00:00
|
|
|
GS_BUCKET_IMAGES = 'skia-infra-gm'
|
2017-04-10 12:19:10 +00:00
|
|
|
DM_JSON = 'dm.json'
|
|
|
|
UPLOAD_ATTEMPTS = 5
|
|
|
|
VERBOSE_LOG = 'verbose.log'
|
|
|
|
|
|
|
|
|
|
|
|
def cp(api, name, src, dst, extra_args=None):
|
|
|
|
cmd = ['gsutil', 'cp']
|
|
|
|
if extra_args:
|
|
|
|
cmd.extend(extra_args)
|
|
|
|
cmd.extend([src, dst])
|
|
|
|
|
|
|
|
name = 'upload %s' % name
|
|
|
|
for i in xrange(UPLOAD_ATTEMPTS):
|
|
|
|
step_name = name
|
|
|
|
if i > 0:
|
|
|
|
step_name += ' (attempt %d)' % (i+1)
|
|
|
|
try:
|
|
|
|
api.step(step_name, cmd=cmd)
|
|
|
|
break
|
|
|
|
except api.step.StepFailure:
|
|
|
|
if i == UPLOAD_ATTEMPTS - 1:
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
2016-09-27 13:52:26 +00:00
|
|
|
def RunSteps(api):
|
2017-04-10 12:19:10 +00:00
|
|
|
builder_name = api.properties['buildername']
|
|
|
|
revision = api.properties['revision']
|
|
|
|
|
|
|
|
results_dir = api.path['start_dir'].join('dm')
|
|
|
|
|
|
|
|
# Move dm.json and verbose.log to their own directory.
|
|
|
|
json_file = results_dir.join(DM_JSON)
|
|
|
|
log_file = results_dir.join(VERBOSE_LOG)
|
|
|
|
tmp_dir = api.path['start_dir'].join('tmp_upload')
|
2017-07-07 21:36:58 +00:00
|
|
|
api.file.ensure_directory('makedirs tmp dir', tmp_dir)
|
|
|
|
api.file.copy('copy dm.json', json_file, tmp_dir)
|
|
|
|
api.file.copy('copy verbose.log', log_file, tmp_dir)
|
|
|
|
api.file.remove('rm old dm.json', json_file)
|
|
|
|
api.file.remove('rm old verbose.log', log_file)
|
2017-04-10 12:19:10 +00:00
|
|
|
|
|
|
|
# Upload the images.
|
2017-09-15 13:56:24 +00:00
|
|
|
image_dest_path = 'gs://%s/dm-images-v1' % GS_BUCKET_IMAGES
|
2017-06-16 17:10:22 +00:00
|
|
|
for ext in ['.png', '.pdf']:
|
|
|
|
files_to_upload = api.file.glob_paths(
|
|
|
|
'find images',
|
|
|
|
results_dir,
|
|
|
|
'*%s' % ext,
|
|
|
|
test_data=['someimage.png'])
|
|
|
|
# For some reason, glob returns results_dir when it should return nothing.
|
|
|
|
files_to_upload = [f for f in files_to_upload if str(f).endswith(ext)]
|
|
|
|
if len(files_to_upload) > 0:
|
|
|
|
cp(api, 'images', results_dir.join('*%s' % ext), image_dest_path)
|
2017-04-10 12:19:10 +00:00
|
|
|
|
|
|
|
# Upload the JSON summary and verbose.log.
|
|
|
|
now = api.time.utcnow()
|
|
|
|
summary_dest_path = '/'.join([
|
|
|
|
'dm-json-v1',
|
|
|
|
str(now.year ).zfill(4),
|
|
|
|
str(now.month).zfill(2),
|
|
|
|
str(now.day ).zfill(2),
|
|
|
|
str(now.hour ).zfill(2),
|
|
|
|
revision,
|
|
|
|
builder_name,
|
|
|
|
str(int(calendar.timegm(now.utctimetuple())))])
|
|
|
|
|
|
|
|
# Trybot results are further siloed by issue/patchset.
|
2017-04-10 13:56:10 +00:00
|
|
|
issue = api.properties.get('patch_issue')
|
|
|
|
patchset = api.properties.get('patch_set')
|
2017-04-10 12:19:10 +00:00
|
|
|
if issue and patchset:
|
|
|
|
summary_dest_path = '/'.join((
|
2017-04-10 13:56:10 +00:00
|
|
|
'trybot', summary_dest_path, str(issue), str(patchset)))
|
2017-04-10 12:19:10 +00:00
|
|
|
|
|
|
|
summary_dest_path = 'gs://%s/%s' % (api.properties['gs_bucket'],
|
|
|
|
summary_dest_path)
|
|
|
|
|
|
|
|
cp(api, 'JSON and logs', tmp_dir.join('*'), summary_dest_path,
|
|
|
|
['-z', 'json,log'])
|
2016-09-27 13:52:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
def GenTests(api):
|
2017-09-26 18:11:15 +00:00
|
|
|
builder = 'Test-Debian9-GCC-GCE-CPU-AVX2-x86_64-Debug'
|
2016-09-27 13:52:26 +00:00
|
|
|
yield (
|
2017-04-10 12:19:10 +00:00
|
|
|
api.test('normal_bot') +
|
|
|
|
api.properties(buildername=builder,
|
2017-02-06 20:38:41 +00:00
|
|
|
gs_bucket='skia-infra-gm',
|
2016-09-27 13:52:26 +00:00
|
|
|
revision='abc123',
|
|
|
|
path_config='kitchen')
|
|
|
|
)
|
2017-04-10 12:19:10 +00:00
|
|
|
|
2017-09-15 13:56:24 +00:00
|
|
|
yield (
|
|
|
|
api.test('alternate_bucket') +
|
|
|
|
api.properties(buildername=builder,
|
|
|
|
gs_bucket='skia-infra-gm-alt',
|
|
|
|
revision='abc123',
|
|
|
|
path_config='kitchen')
|
|
|
|
)
|
|
|
|
|
2017-04-10 12:19:10 +00:00
|
|
|
yield (
|
|
|
|
api.test('failed_once') +
|
|
|
|
api.properties(buildername=builder,
|
|
|
|
gs_bucket='skia-infra-gm',
|
|
|
|
revision='abc123',
|
|
|
|
path_config='kitchen') +
|
|
|
|
api.step_data('upload images', retcode=1)
|
|
|
|
)
|
|
|
|
|
|
|
|
yield (
|
|
|
|
api.test('failed_all') +
|
|
|
|
api.properties(buildername=builder,
|
|
|
|
gs_bucket='skia-infra-gm',
|
|
|
|
revision='abc123',
|
|
|
|
path_config='kitchen') +
|
|
|
|
api.step_data('upload images', retcode=1) +
|
|
|
|
api.step_data('upload images (attempt 2)', retcode=1) +
|
|
|
|
api.step_data('upload images (attempt 3)', retcode=1) +
|
|
|
|
api.step_data('upload images (attempt 4)', retcode=1) +
|
|
|
|
api.step_data('upload images (attempt 5)', retcode=1)
|
|
|
|
)
|
|
|
|
|
|
|
|
yield (
|
2017-04-10 13:56:10 +00:00
|
|
|
api.test('trybot') +
|
2017-04-10 12:19:10 +00:00
|
|
|
api.properties(
|
|
|
|
buildername=builder,
|
|
|
|
gs_bucket='skia-infra-gm',
|
|
|
|
revision='abc123',
|
|
|
|
path_config='kitchen',
|
|
|
|
patch_storage='gerrit') +
|
|
|
|
api.properties.tryserver(
|
|
|
|
buildername=builder,
|
|
|
|
gerrit_project='skia',
|
|
|
|
gerrit_url='https://skia-review.googlesource.com/',
|
|
|
|
)
|
|
|
|
)
|