blob: 5c5db2703d2fd9b9cb045c6422c225b2953d6c69 [file] [log] [blame]
rmistry5eab9912016-08-09 13:46:48 -07001# Copyright 2015 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
6import math
7
8
9DEPS = [
10 'build/file',
11 'build/gsutil',
rmistry5eab9912016-08-09 13:46:48 -070012 'recipe_engine/json',
13 'recipe_engine/path',
14 'recipe_engine/properties',
15 'recipe_engine/step',
16 'recipe_engine/time',
Eric Boren6441a462017-01-13 13:37:53 -050017 'skia-recipes/core',
18 'skia-recipes/ct',
19 'skia-recipes/flavor',
20 'skia-recipes/run',
21 'skia-recipes/swarming',
22 'skia-recipes/vars',
rmistry5eab9912016-08-09 13:46:48 -070023]
24
25
26SKPS_VERSION_FILE = 'skps_version'
27CT_SKPS_ISOLATE = 'ct_skps.isolate'
28
29# Do not batch archive more slaves than this value. This is used to prevent
30# no output timeouts in the 'isolate tests' step.
31MAX_SLAVES_TO_BATCHARCHIVE = 100
32
33TOOL_TO_DEFAULT_SKPS_PER_SLAVE = {
34 'dm': 10000,
35 'nanobench': 1000,
36 'get_images_from_skps': 10000,
37}
38
39# The SKP repository to use.
40DEFAULT_SKPS_CHROMIUM_BUILD = 'fad657e-276e633'
41
42
43def RunSteps(api):
44 # Figure out which repository to use.
45 buildername = api.properties['buildername']
46 if '1k' in buildername:
47 ct_page_type = '10k'
48 num_pages = 1000
49 elif '10k' in buildername:
50 ct_page_type = '10k'
51 num_pages = 10000
52 elif '100k' in buildername:
53 ct_page_type = '100k'
54 num_pages = 100000
55 elif '1m' in buildername:
56 ct_page_type = 'All'
57 num_pages = 1000000
58 else:
59 raise Exception('Do not recognise the buildername %s.' % buildername)
60
61 # Figure out which tool to use.
62 if 'DM' in buildername:
63 skia_tool = 'dm'
64 build_target = 'dm'
65 elif 'BENCH' in buildername:
66 skia_tool = 'nanobench'
67 build_target = 'nanobench'
68 elif 'IMG_DECODE' in buildername:
69 skia_tool = 'get_images_from_skps'
70 build_target = 'tools'
71 else:
72 raise Exception('Do not recognise the buildername %s.' % buildername)
73
74 api.core.setup()
75 api.flavor.compile(build_target)
76
77 # Required paths.
78 infrabots_dir = api.vars.skia_dir.join('infra', 'bots')
79 isolate_dir = infrabots_dir.join('ct')
80 isolate_path = isolate_dir.join(CT_SKPS_ISOLATE)
81
82 api.run.copy_build_products(
83 api.flavor.out_dir,
84 isolate_dir)
85 api.swarming.setup(
86 infrabots_dir.join('tools', 'luci-go'),
87 swarming_rev='')
88
89 skps_chromium_build = api.properties.get(
90 'skps_chromium_build', DEFAULT_SKPS_CHROMIUM_BUILD)
91
Ravi Mistry1eab4422016-10-13 10:36:50 -040092 # Set build properties to make finding SKPs convenient.
93 webpage_rankings_link = (
94 'https://storage.cloud.google.com/%s/csv/top-1m.csv'
95 % api.ct.CT_GS_BUCKET)
96 api.step.active_result.presentation.properties['Webpage rankings'] = (
97 webpage_rankings_link)
98 download_skps_link = (
rmistry5eab9912016-08-09 13:46:48 -070099 'https://pantheon.corp.google.com/storage/browser/%s/swarming/skps/%s/%s/'
100 % (api.ct.CT_GS_BUCKET, ct_page_type, skps_chromium_build))
Ravi Mistry1eab4422016-10-13 10:36:50 -0400101 api.step.active_result.presentation.properties['Download SKPs by rank'] = (
102 download_skps_link)
rmistry5eab9912016-08-09 13:46:48 -0700103
104 # Delete swarming_temp_dir to ensure it starts from a clean slate.
105 api.run.rmtree(api.swarming.swarming_temp_dir)
106
107 num_per_slave = api.properties.get(
108 'num_per_slave',
109 min(TOOL_TO_DEFAULT_SKPS_PER_SLAVE[skia_tool], num_pages))
110 ct_num_slaves = api.properties.get(
111 'ct_num_slaves',
112 int(math.ceil(float(num_pages) / num_per_slave)))
113
114 # Try to figure out if the SKPs we are going to isolate already exist
115 # locally by reading the SKPS_VERSION_FILE.
116 download_skps = True
117 expected_version_contents = {
118 "chromium_build": skps_chromium_build,
119 "page_type": ct_page_type,
120 "num_slaves": ct_num_slaves,
121 }
122 skps_dir = api.vars.checkout_root.join('skps', buildername)
123 version_file = skps_dir.join(SKPS_VERSION_FILE)
124 if api.path.exists(version_file): # pragma: nocover
125 version_file_contents = api.file.read(
126 "Read %s" % version_file,
127 version_file,
128 test_data=expected_version_contents,
129 infra_step=True)
130 actual_version_contents = api.json.loads(version_file_contents)
131 differences = (set(expected_version_contents.items()) ^
132 set(actual_version_contents.items()))
133 download_skps = len(differences) != 0
134 if download_skps:
135 # Delete and recreate the skps dir.
136 api.run.rmtree(skps_dir)
137 api.file.makedirs(api.path.basename(skps_dir), skps_dir)
138
139 # If a blacklist file exists then specify SKPs to be blacklisted.
140 blacklists_dir = api.vars.skia_dir.join('infra', 'bots', 'ct', 'blacklists')
141 blacklist_file = blacklists_dir.join(
142 '%s_%s_%s.json' % (skia_tool, ct_page_type, skps_chromium_build))
143 blacklist_skps = []
144 if api.path.exists(blacklist_file): # pragma: nocover
145 blacklist_file_contents = api.file.read(
146 "Read %s" % blacklist_file,
147 blacklist_file,
148 infra_step=True)
149 blacklist_skps = api.json.loads(blacklist_file_contents)['blacklisted_skps']
150
151 for slave_num in range(1, ct_num_slaves + 1):
152 if download_skps:
153 # Download SKPs.
154 api.ct.download_swarming_skps(
155 ct_page_type, slave_num, skps_chromium_build,
156 skps_dir,
157 start_range=((slave_num-1)*num_per_slave) + 1,
158 num_skps=num_per_slave)
159
160 # Create this slave's isolated.gen.json file to use for batcharchiving.
161 extra_variables = {
162 'SLAVE_NUM': str(slave_num),
163 'TOOL_NAME': skia_tool,
164 'GIT_HASH': api.vars.got_revision,
165 'CONFIGURATION': api.vars.configuration,
166 'BUILDER': buildername,
167 }
168 api.swarming.create_isolated_gen_json(
169 isolate_path, isolate_dir, 'linux', 'ct-%s-%s' % (skia_tool, slave_num),
170 extra_variables, blacklist=blacklist_skps)
171
172 if download_skps:
173 # Since we had to download SKPs create an updated version file.
174 api.file.write("Create %s" % version_file,
175 version_file,
176 api.json.dumps(expected_version_contents),
177 infra_step=True)
178
179 # Batcharchive everything on the isolate server for efficiency.
180 max_slaves_to_batcharchive = MAX_SLAVES_TO_BATCHARCHIVE
181 if '1m' in buildername:
182 # Break up the "isolate tests" step into batches with <100k files due to
183 # https://github.com/luci/luci-go/issues/9
184 max_slaves_to_batcharchive = 5
185 tasks_to_swarm_hashes = []
186 for slave_start_num in xrange(1, ct_num_slaves+1, max_slaves_to_batcharchive):
187 m = min(max_slaves_to_batcharchive, ct_num_slaves)
188 batcharchive_output = api.swarming.batcharchive(
189 targets=['ct-' + skia_tool + '-%s' % num for num in range(
190 slave_start_num, slave_start_num + m)])
191 tasks_to_swarm_hashes.extend(batcharchive_output)
192 # Sort the list to go through tasks in order.
193 tasks_to_swarm_hashes.sort()
194
195 # Trigger all swarming tasks.
196 dimensions={'os': 'Ubuntu-14.04', 'cpu': 'x86-64', 'pool': 'Chrome'}
197 if 'GPU' in buildername:
198 dimensions['gpu'] = '10de:104a'
199 tasks = api.swarming.trigger_swarming_tasks(
200 tasks_to_swarm_hashes, dimensions=dimensions, io_timeout=40*60)
201
202 # Now collect all tasks.
203 failed_tasks = []
204 for task in tasks:
205 try:
206 api.swarming.collect_swarming_task(task)
207
208 if skia_tool == 'nanobench':
209 output_dir = api.swarming.tasks_output_dir.join(
210 task.title).join('0')
211 utc = api.time.utcnow()
212 gs_dest_dir = 'ct/%s/%d/%02d/%02d/%02d/' % (
213 ct_page_type, utc.year, utc.month, utc.day, utc.hour)
214 for json_output in api.file.listdir('output dir', output_dir):
215 api.gsutil.upload(
216 name='upload json output',
217 source=output_dir.join(json_output),
218 bucket='skia-perf',
219 dest=gs_dest_dir,
220 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None},
221 args=['-R']
222 )
223
224 except api.step.StepFailure as e:
Ravi Mistry1eab4422016-10-13 10:36:50 -0400225 # Add SKP links for convenience.
226 api.step.active_result.presentation.links['Webpage rankings'] = (
227 webpage_rankings_link)
228 api.step.active_result.presentation.links['Download SKPs by rank'] = (
229 download_skps_link)
rmistry5eab9912016-08-09 13:46:48 -0700230 failed_tasks.append(e)
231
232 if failed_tasks:
233 raise api.step.StepFailure(
234 'Failed steps: %s' % ', '.join([f.name for f in failed_tasks]))
235
236
237def GenTests(api):
238 ct_num_slaves = 5
239 num_per_slave = 10
240 skia_revision = 'abc123'
241 mastername = 'client.skia'
242 slavename = 'skiabot-linux-swarm-000'
243 buildnumber = 2
244 path_config = 'kitchen'
245
246 yield(
247 api.test('CT_DM_10k_SKPs') +
248 api.properties(
249 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_10k_SKPs',
250 mastername=mastername,
251 slavename=slavename,
252 buildnumber=buildnumber,
253 path_config=path_config,
254 swarm_out_dir='[SWARM_OUT_DIR]',
255 ct_num_slaves=ct_num_slaves,
256 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500257 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700258 revision=skia_revision,
259 )
260 )
261
262 yield(
263 api.test('CT_IMG_DECODE_10k_SKPs') +
264 api.properties(
265 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
266 '10k_SKPs',
267 mastername=mastername,
268 slavename=slavename,
269 buildnumber=buildnumber,
270 path_config=path_config,
271 swarm_out_dir='[SWARM_OUT_DIR]',
272 ct_num_slaves=ct_num_slaves,
273 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500274 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700275 revision=skia_revision,
276 )
277 )
278
279 yield(
280 api.test('CT_DM_100k_SKPs') +
281 api.properties(
282 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_100k_SKPs',
283 mastername=mastername,
284 slavename=slavename,
285 buildnumber=buildnumber,
286 path_config=path_config,
287 swarm_out_dir='[SWARM_OUT_DIR]',
288 ct_num_slaves=ct_num_slaves,
289 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500290 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700291 revision=skia_revision,
292 )
293 )
294
295 yield(
296 api.test('CT_IMG_DECODE_100k_SKPs') +
297 api.properties(
298 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
299 '100k_SKPs',
300 mastername=mastername,
301 slavename=slavename,
302 buildnumber=buildnumber,
303 path_config=path_config,
304 swarm_out_dir='[SWARM_OUT_DIR]',
305 ct_num_slaves=ct_num_slaves,
306 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500307 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700308 revision=skia_revision,
309 )
310 )
311
312 yield(
313 api.test('CT_GPU_BENCH_1k_SKPs') +
314 api.properties(
315 buildername=
316 'Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_1k_SKPs',
317 mastername=mastername,
318 slavename=slavename,
319 buildnumber=buildnumber,
320 path_config=path_config,
321 swarm_out_dir='[SWARM_OUT_DIR]',
322 ct_num_slaves=ct_num_slaves,
323 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500324 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700325 revision=skia_revision,
326 ) +
327 api.path.exists(
Ravi Mistry9bcca6a2016-11-21 16:06:19 -0500328 api.path['start_dir'].join('skia'),
329 api.path['start_dir'].join('src')
rmistry5eab9912016-08-09 13:46:48 -0700330 )
331 )
332
333 yield(
334 api.test('CT_CPU_BENCH_10k_SKPs') +
335 api.properties(
336 buildername=
337 'Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-CT_BENCH_10k_SKPs',
338 mastername=mastername,
339 slavename=slavename,
340 buildnumber=buildnumber,
341 path_config=path_config,
342 swarm_out_dir='[SWARM_OUT_DIR]',
343 ct_num_slaves=ct_num_slaves,
344 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500345 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700346 revision=skia_revision,
347 ) +
348 api.path.exists(
Ravi Mistry9bcca6a2016-11-21 16:06:19 -0500349 api.path['start_dir'].join('skia'),
350 api.path['start_dir'].join('src')
rmistry5eab9912016-08-09 13:46:48 -0700351 )
352 )
353
354 yield(
355 api.test('CT_GPU_BENCH_10k_SKPs') +
356 api.properties(
357 buildername=
358 'Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_10k_SKPs',
359 mastername=mastername,
360 slavename=slavename,
361 buildnumber=buildnumber,
362 path_config=path_config,
363 swarm_out_dir='[SWARM_OUT_DIR]',
364 ct_num_slaves=ct_num_slaves,
365 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500366 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700367 revision=skia_revision,
368 ) +
369 api.path.exists(
Ravi Mistry9bcca6a2016-11-21 16:06:19 -0500370 api.path['start_dir'].join('skia'),
371 api.path['start_dir'].join('src')
rmistry5eab9912016-08-09 13:46:48 -0700372 )
373 )
374
375 yield(
376 api.test('CT_DM_1m_SKPs') +
377 api.properties(
378 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
379 mastername=mastername,
380 slavename=slavename,
381 buildnumber=buildnumber,
382 path_config=path_config,
383 swarm_out_dir='[SWARM_OUT_DIR]',
384 ct_num_slaves=ct_num_slaves,
385 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500386 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700387 revision=skia_revision,
388 )
389 )
390
391 yield (
392 api.test('CT_DM_SKPs_UnknownBuilder') +
393 api.properties(
394 buildername=
395 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_UnknownRepo_SKPs',
396 mastername=mastername,
397 slavename=slavename,
398 buildnumber=buildnumber,
399 path_config=path_config,
400 swarm_out_dir='[SWARM_OUT_DIR]',
401 ct_num_slaves=ct_num_slaves,
402 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500403 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700404 revision=skia_revision,
405 ) +
406 api.expect_exception('Exception')
407 )
408
409 yield (
410 api.test('CT_10k_SKPs_UnknownBuilder') +
411 api.properties(
412 buildername=
413 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_UnknownTool_10k_SKPs',
414 mastername=mastername,
415 slavename=slavename,
416 buildnumber=buildnumber,
417 path_config=path_config,
418 swarm_out_dir='[SWARM_OUT_DIR]',
419 ct_num_slaves=ct_num_slaves,
420 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500421 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700422 revision=skia_revision,
423 ) +
424 api.expect_exception('Exception')
425 )
426
427 yield(
428 api.test('CT_DM_1m_SKPs_slave3_failure') +
429 api.step_data('ct-dm-3 on Ubuntu-14.04', retcode=1) +
430 api.properties(
431 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
432 mastername=mastername,
433 slavename=slavename,
434 buildnumber=buildnumber,
435 path_config=path_config,
436 swarm_out_dir='[SWARM_OUT_DIR]',
437 ct_num_slaves=ct_num_slaves,
438 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500439 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700440 revision=skia_revision,
441 )
442 )
443
444 yield(
445 api.test('CT_DM_1m_SKPs_2slaves_failure') +
446 api.step_data('ct-dm-1 on Ubuntu-14.04', retcode=1) +
447 api.step_data('ct-dm-3 on Ubuntu-14.04', retcode=1) +
448 api.properties(
449 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
450 mastername=mastername,
451 slavename=slavename,
452 buildnumber=buildnumber,
453 path_config=path_config,
454 swarm_out_dir='[SWARM_OUT_DIR]',
455 ct_num_slaves=ct_num_slaves,
456 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500457 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700458 revision=skia_revision,
459 )
460 )
461
462 yield(
463 api.test('CT_DM_10k_SKPs_Trybot') +
464 api.properties(
465 buildername=
466 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_10k_SKPs-Trybot',
467 mastername=mastername,
468 slavename=slavename,
469 buildnumber=buildnumber,
470 path_config=path_config,
471 swarm_out_dir='[SWARM_OUT_DIR]',
472 ct_num_slaves=ct_num_slaves,
473 num_per_slave=num_per_slave,
474 rietveld='codereview.chromium.org',
475 issue=1499623002,
476 patchset=1,
Eric Borenad29aee2017-01-17 14:35:06 -0500477 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700478 )
479 )
480
481 yield(
482 api.test('CT_IMG_DECODE_10k_SKPs_Trybot') +
483 api.properties(
484 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
485 '10k_SKPs_Trybot',
486 mastername=mastername,
487 slavename=slavename,
488 buildnumber=buildnumber,
489 path_config=path_config,
490 swarm_out_dir='[SWARM_OUT_DIR]',
491 ct_num_slaves=ct_num_slaves,
492 num_per_slave=num_per_slave,
Eric Borenad29aee2017-01-17 14:35:06 -0500493 repository='https://skia.googlesource.com/skia.git',
rmistry5eab9912016-08-09 13:46:48 -0700494 revision=skia_revision,
495 )
496 )