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