1cb93a386Sopenharmony_ci# Copyright 2016 The Chromium Authors. All rights reserved. 2cb93a386Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 3cb93a386Sopenharmony_ci# found in the LICENSE file. 4cb93a386Sopenharmony_ci 5cb93a386Sopenharmony_ci 6cb93a386Sopenharmony_ci# Recipe for uploading DM results. 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci 9cb93a386Sopenharmony_ciimport calendar 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ciPYTHON_VERSION_COMPATIBILITY = "PY2+3" 12cb93a386Sopenharmony_ci 13cb93a386Sopenharmony_ciDEPS = [ 14cb93a386Sopenharmony_ci 'recipe_engine/file', 15cb93a386Sopenharmony_ci 'recipe_engine/json', 16cb93a386Sopenharmony_ci 'recipe_engine/path', 17cb93a386Sopenharmony_ci 'recipe_engine/properties', 18cb93a386Sopenharmony_ci 'recipe_engine/step', 19cb93a386Sopenharmony_ci 'recipe_engine/time', 20cb93a386Sopenharmony_ci 'gsutil', 21cb93a386Sopenharmony_ci 'vars', 22cb93a386Sopenharmony_ci] 23cb93a386Sopenharmony_ci 24cb93a386Sopenharmony_ci 25cb93a386Sopenharmony_ciDM_JSON = 'dm.json' 26cb93a386Sopenharmony_ciVERBOSE_LOG = 'verbose.log' 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_ci 29cb93a386Sopenharmony_cidef RunSteps(api): 30cb93a386Sopenharmony_ci api.vars.setup() 31cb93a386Sopenharmony_ci revision = api.properties['revision'] 32cb93a386Sopenharmony_ci 33cb93a386Sopenharmony_ci results_dir = api.path['start_dir'].join('test') 34cb93a386Sopenharmony_ci 35cb93a386Sopenharmony_ci # Upload the images. It is *vital* that the images are uploaded first 36cb93a386Sopenharmony_ci # so they exist whenever the json is processed. 37cb93a386Sopenharmony_ci image_dest_path = 'gs://%s/dm-images-v1' % api.properties['gs_bucket'] 38cb93a386Sopenharmony_ci for ext in ['.png', '.pdf']: 39cb93a386Sopenharmony_ci files_to_upload = api.file.glob_paths( 40cb93a386Sopenharmony_ci 'find %s images' % ext, 41cb93a386Sopenharmony_ci results_dir, 42cb93a386Sopenharmony_ci '*%s' % ext, 43cb93a386Sopenharmony_ci test_data=['someimage.png']) 44cb93a386Sopenharmony_ci # For some reason, glob returns results_dir when it should return nothing. 45cb93a386Sopenharmony_ci files_to_upload = [f for f in files_to_upload if str(f).endswith(ext)] 46cb93a386Sopenharmony_ci if len(files_to_upload) > 0: 47cb93a386Sopenharmony_ci api.gsutil.cp('%s images' % ext, results_dir.join('*%s' % ext), 48cb93a386Sopenharmony_ci image_dest_path, multithread=True) 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci # Compute the directory to upload results to 51cb93a386Sopenharmony_ci now = api.time.utcnow() 52cb93a386Sopenharmony_ci summary_dest_path = '/'.join([ 53cb93a386Sopenharmony_ci 'dm-json-v1', 54cb93a386Sopenharmony_ci str(now.year ).zfill(4), 55cb93a386Sopenharmony_ci str(now.month).zfill(2), 56cb93a386Sopenharmony_ci str(now.day ).zfill(2), 57cb93a386Sopenharmony_ci str(now.hour ).zfill(2), 58cb93a386Sopenharmony_ci revision, 59cb93a386Sopenharmony_ci api.vars.builder_name, 60cb93a386Sopenharmony_ci str(int(calendar.timegm(now.utctimetuple())))]) 61cb93a386Sopenharmony_ci 62cb93a386Sopenharmony_ci # Trybot results are further siloed by issue/patchset. 63cb93a386Sopenharmony_ci if api.vars.is_trybot: 64cb93a386Sopenharmony_ci summary_dest_path = '/'.join(('trybot', summary_dest_path, 65cb93a386Sopenharmony_ci str(api.vars.issue), str(api.vars.patchset))) 66cb93a386Sopenharmony_ci 67cb93a386Sopenharmony_ci summary_dest_path = 'gs://%s/%s' % (api.properties['gs_bucket'], 68cb93a386Sopenharmony_ci summary_dest_path) 69cb93a386Sopenharmony_ci 70cb93a386Sopenharmony_ci # Directly upload dm.json and verbose.log if it exists 71cb93a386Sopenharmony_ci json_file = results_dir.join(DM_JSON) 72cb93a386Sopenharmony_ci log_file = results_dir.join(VERBOSE_LOG) 73cb93a386Sopenharmony_ci 74cb93a386Sopenharmony_ci api.gsutil.cp('dm.json', json_file, 75cb93a386Sopenharmony_ci summary_dest_path + '/' + DM_JSON, extra_args=['-Z']) 76cb93a386Sopenharmony_ci 77cb93a386Sopenharmony_ci files = api.file.listdir('check for optional verbose.log file', 78cb93a386Sopenharmony_ci results_dir, test_data=['dm.json', 'verbose.log']) 79cb93a386Sopenharmony_ci if log_file in files: 80cb93a386Sopenharmony_ci api.gsutil.cp('verbose.log', log_file, 81cb93a386Sopenharmony_ci summary_dest_path + '/' + VERBOSE_LOG, extra_args=['-Z']) 82cb93a386Sopenharmony_ci 83cb93a386Sopenharmony_ci 84cb93a386Sopenharmony_cidef GenTests(api): 85cb93a386Sopenharmony_ci builder = 'Upload-Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Debug-All' 86cb93a386Sopenharmony_ci yield ( 87cb93a386Sopenharmony_ci api.test('normal_bot') + 88cb93a386Sopenharmony_ci api.properties(buildername=builder, 89cb93a386Sopenharmony_ci gs_bucket='skia-infra-gm', 90cb93a386Sopenharmony_ci revision='abc123', 91cb93a386Sopenharmony_ci path_config='kitchen') 92cb93a386Sopenharmony_ci ) 93cb93a386Sopenharmony_ci 94cb93a386Sopenharmony_ci yield ( 95cb93a386Sopenharmony_ci api.test('alternate_bucket') + 96cb93a386Sopenharmony_ci api.properties(buildername=builder, 97cb93a386Sopenharmony_ci gs_bucket='skia-infra-gm-alt', 98cb93a386Sopenharmony_ci revision='abc123', 99cb93a386Sopenharmony_ci path_config='kitchen') 100cb93a386Sopenharmony_ci ) 101cb93a386Sopenharmony_ci 102cb93a386Sopenharmony_ci yield ( 103cb93a386Sopenharmony_ci api.test('failed_once') + 104cb93a386Sopenharmony_ci api.properties(buildername=builder, 105cb93a386Sopenharmony_ci gs_bucket='skia-infra-gm', 106cb93a386Sopenharmony_ci revision='abc123', 107cb93a386Sopenharmony_ci path_config='kitchen') + 108cb93a386Sopenharmony_ci api.step_data('upload .png images', retcode=1) 109cb93a386Sopenharmony_ci ) 110cb93a386Sopenharmony_ci 111cb93a386Sopenharmony_ci yield ( 112cb93a386Sopenharmony_ci api.test('failed_all') + 113cb93a386Sopenharmony_ci api.properties(buildername=builder, 114cb93a386Sopenharmony_ci gs_bucket='skia-infra-gm', 115cb93a386Sopenharmony_ci revision='abc123', 116cb93a386Sopenharmony_ci path_config='kitchen') + 117cb93a386Sopenharmony_ci api.step_data('upload .png images', retcode=1) + 118cb93a386Sopenharmony_ci api.step_data('upload .png images (attempt 2)', retcode=1) + 119cb93a386Sopenharmony_ci api.step_data('upload .png images (attempt 3)', retcode=1) + 120cb93a386Sopenharmony_ci api.step_data('upload .png images (attempt 4)', retcode=1) + 121cb93a386Sopenharmony_ci api.step_data('upload .png images (attempt 5)', retcode=1) 122cb93a386Sopenharmony_ci ) 123cb93a386Sopenharmony_ci 124cb93a386Sopenharmony_ci yield ( 125cb93a386Sopenharmony_ci api.test('trybot') + 126cb93a386Sopenharmony_ci api.properties.tryserver( 127cb93a386Sopenharmony_ci gerrit_project='skia', 128cb93a386Sopenharmony_ci gerrit_url='https://skia-review.googlesource.com/', 129cb93a386Sopenharmony_ci ) + 130cb93a386Sopenharmony_ci api.properties( 131cb93a386Sopenharmony_ci buildername=builder, 132cb93a386Sopenharmony_ci gs_bucket='skia-infra-gm', 133cb93a386Sopenharmony_ci revision='abc123', 134cb93a386Sopenharmony_ci path_config='kitchen') 135cb93a386Sopenharmony_ci ) 136