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