Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: infra/bots/recipes/swarm_ct_skps.py

Issue 2221413002: Move ct_skps recipe from tools repo to Skia repo (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Changes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # 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
6 import math
7
8
9 DEPS = [
10 'build/file',
11 'build/gsutil',
12 'core',
13 'ct',
14 'flavor',
15 'recipe_engine/json',
16 'recipe_engine/path',
17 'recipe_engine/properties',
18 'recipe_engine/step',
19 'recipe_engine/time',
20 'run',
21 'swarming',
22 'vars',
23 ]
24
25
26 SKPS_VERSION_FILE = 'skps_version'
27 CT_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.
31 MAX_SLAVES_TO_BATCHARCHIVE = 100
32
33 TOOL_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.
40 DEFAULT_SKPS_CHROMIUM_BUILD = 'fad657e-276e633'
41
42
43 def 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
92 # Set build property to make finding SKPs convenient.
93 api.step.active_result.presentation.properties['Location of SKPs'] = (
94 'https://pantheon.corp.google.com/storage/browser/%s/swarming/skps/%s/%s/'
95 % (api.ct.CT_GS_BUCKET, ct_page_type, skps_chromium_build))
96
97 # Delete swarming_temp_dir to ensure it starts from a clean slate.
98 api.run.rmtree(api.swarming.swarming_temp_dir)
99
100 num_per_slave = api.properties.get(
101 'num_per_slave',
102 min(TOOL_TO_DEFAULT_SKPS_PER_SLAVE[skia_tool], num_pages))
103 ct_num_slaves = api.properties.get(
104 'ct_num_slaves',
105 int(math.ceil(float(num_pages) / num_per_slave)))
106
107 # Try to figure out if the SKPs we are going to isolate already exist
108 # locally by reading the SKPS_VERSION_FILE.
109 download_skps = True
110 expected_version_contents = {
111 "chromium_build": skps_chromium_build,
112 "page_type": ct_page_type,
113 "num_slaves": ct_num_slaves,
114 }
115 skps_dir = api.vars.checkout_root.join('skps', buildername)
116 version_file = skps_dir.join(SKPS_VERSION_FILE)
117 if api.path.exists(version_file): # pragma: nocover
118 version_file_contents = api.file.read(
119 "Read %s" % version_file,
120 version_file,
121 test_data=expected_version_contents,
122 infra_step=True)
123 actual_version_contents = api.json.loads(version_file_contents)
124 differences = (set(expected_version_contents.items()) ^
125 set(actual_version_contents.items()))
126 download_skps = len(differences) != 0
127 if download_skps:
128 # Delete and recreate the skps dir.
129 api.run.rmtree(skps_dir)
130 api.file.makedirs(api.path.basename(skps_dir), skps_dir)
131
132 # If a blacklist file exists then specify SKPs to be blacklisted.
133 blacklists_dir = api.vars.skia_dir.join('infra', 'bots', 'ct', 'blacklists')
134 blacklist_file = blacklists_dir.join(
135 '%s_%s_%s.json' % (skia_tool, ct_page_type, skps_chromium_build))
136 blacklist_skps = []
137 if api.path.exists(blacklist_file): # pragma: nocover
138 blacklist_file_contents = api.file.read(
139 "Read %s" % blacklist_file,
140 blacklist_file,
141 infra_step=True)
142 blacklist_skps = api.json.loads(blacklist_file_contents)['blacklisted_skps']
143
144 for slave_num in range(1, ct_num_slaves + 1):
145 if download_skps:
146 # Download SKPs.
147 api.ct.download_swarming_skps(
148 ct_page_type, slave_num, skps_chromium_build,
149 skps_dir,
150 start_range=((slave_num-1)*num_per_slave) + 1,
151 num_skps=num_per_slave)
152
153 # Create this slave's isolated.gen.json file to use for batcharchiving.
154 isolate_dir = infrabots_dir.join('ct')
borenet 2016/08/09 17:10:21 isolate_dir is already defined above, shouldn't ha
rmistry 2016/08/09 18:19:11 Done.
155 isolate_path = isolate_dir.join(CT_SKPS_ISOLATE)
156 extra_variables = {
157 'SLAVE_NUM': str(slave_num),
158 'TOOL_NAME': skia_tool,
159 'GIT_HASH': api.vars.got_revision,
160 'CONFIGURATION': api.vars.configuration,
161 'BUILDER': buildername,
162 }
163 api.swarming.create_isolated_gen_json(
164 isolate_path, isolate_dir, 'linux', 'ct-%s-%s' % (skia_tool, slave_num),
165 extra_variables, blacklist=blacklist_skps)
166
167 if download_skps:
168 # Since we had to download SKPs create an updated version file.
169 api.file.write("Create %s" % version_file,
170 version_file,
171 api.json.dumps(expected_version_contents),
172 infra_step=True)
173
174 # Batcharchive everything on the isolate server for efficiency.
175 max_slaves_to_batcharchive = MAX_SLAVES_TO_BATCHARCHIVE
176 if '1m' in buildername:
177 # Break up the "isolate tests" step into batches with <100k files due to
178 # https://github.com/luci/luci-go/issues/9
179 max_slaves_to_batcharchive = 5
180 tasks_to_swarm_hashes = []
181 for slave_start_num in xrange(1, ct_num_slaves+1, max_slaves_to_batcharchive):
182 m = min(max_slaves_to_batcharchive, ct_num_slaves)
183 batcharchive_output = api.swarming.batcharchive(
184 targets=['ct-' + skia_tool + '-%s' % num for num in range(
185 slave_start_num, slave_start_num + m)])
186 tasks_to_swarm_hashes.extend(batcharchive_output)
187 # Sort the list to go through tasks in order.
188 tasks_to_swarm_hashes.sort()
189
190 # Trigger all swarming tasks.
191 dimensions={'os': 'Ubuntu-14.04', 'cpu': 'x86-64', 'pool': 'Chrome'}
192 if 'GPU' in buildername:
193 dimensions['gpu'] = '10de:104a'
194 tasks = api.swarming.trigger_swarming_tasks(
195 tasks_to_swarm_hashes, dimensions=dimensions, io_timeout=40*60)
196
197 # Now collect all tasks.
198 failed_tasks = []
199 for task in tasks:
200 try:
201 api.swarming.collect_swarming_task(task)
202
203 if skia_tool == 'nanobench':
204 output_dir = api.swarming.tasks_output_dir.join(
205 task.title).join('0')
206 utc = api.time.utcnow()
207 gs_dest_dir = 'ct/%s/%d/%02d/%02d/%02d/' % (
208 ct_page_type, utc.year, utc.month, utc.day, utc.hour)
209 for json_output in api.file.listdir('output dir', output_dir):
210 api.gsutil.upload(
211 name='upload json output',
212 source=output_dir.join(json_output),
213 bucket='skia-perf',
214 dest=gs_dest_dir,
215 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None},
216 args=['-R']
217 )
218
219 except api.step.StepFailure as e:
220 failed_tasks.append(e)
221
222 if failed_tasks:
223 raise api.step.StepFailure(
224 'Failed steps: %s' % ', '.join([f.name for f in failed_tasks]))
225
226
227 def GenTests(api):
228 ct_num_slaves = 5
229 num_per_slave = 10
230 skia_revision = 'abc123'
231 mastername = 'client.skia'
232 slavename = 'skiabot-linux-swarm-000'
233 buildnumber = 2
234 path_config = 'kitchen'
235
236 yield(
237 api.test('CT_DM_10k_SKPs') +
238 api.properties(
239 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_10k_SKPs',
240 mastername=mastername,
241 slavename=slavename,
242 buildnumber=buildnumber,
243 path_config=path_config,
244 swarm_out_dir='[SWARM_OUT_DIR]',
245 ct_num_slaves=ct_num_slaves,
246 num_per_slave=num_per_slave,
247 revision=skia_revision,
248 )
249 )
250
251 yield(
252 api.test('CT_IMG_DECODE_10k_SKPs') +
253 api.properties(
254 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
255 '10k_SKPs',
256 mastername=mastername,
257 slavename=slavename,
258 buildnumber=buildnumber,
259 path_config=path_config,
260 swarm_out_dir='[SWARM_OUT_DIR]',
261 ct_num_slaves=ct_num_slaves,
262 num_per_slave=num_per_slave,
263 revision=skia_revision,
264 )
265 )
266
267 yield(
268 api.test('CT_DM_100k_SKPs') +
269 api.properties(
270 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_100k_SKPs',
271 mastername=mastername,
272 slavename=slavename,
273 buildnumber=buildnumber,
274 path_config=path_config,
275 swarm_out_dir='[SWARM_OUT_DIR]',
276 ct_num_slaves=ct_num_slaves,
277 num_per_slave=num_per_slave,
278 revision=skia_revision,
279 )
280 )
281
282 yield(
283 api.test('CT_IMG_DECODE_100k_SKPs') +
284 api.properties(
285 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
286 '100k_SKPs',
287 mastername=mastername,
288 slavename=slavename,
289 buildnumber=buildnumber,
290 path_config=path_config,
291 swarm_out_dir='[SWARM_OUT_DIR]',
292 ct_num_slaves=ct_num_slaves,
293 num_per_slave=num_per_slave,
294 revision=skia_revision,
295 )
296 )
297
298 yield(
299 api.test('CT_GPU_BENCH_1k_SKPs') +
300 api.properties(
301 buildername=
302 'Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_1k_SKPs',
303 mastername=mastername,
304 slavename=slavename,
305 buildnumber=buildnumber,
306 path_config=path_config,
307 swarm_out_dir='[SWARM_OUT_DIR]',
308 ct_num_slaves=ct_num_slaves,
309 num_per_slave=num_per_slave,
310 revision=skia_revision,
311 ) +
312 api.path.exists(
313 api.path['slave_build'].join('skia'),
314 api.path['slave_build'].join('src')
315 )
316 )
317
318 yield(
319 api.test('CT_CPU_BENCH_10k_SKPs') +
320 api.properties(
321 buildername=
322 'Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-CT_BENCH_10k_SKPs',
323 mastername=mastername,
324 slavename=slavename,
325 buildnumber=buildnumber,
326 path_config=path_config,
327 swarm_out_dir='[SWARM_OUT_DIR]',
328 ct_num_slaves=ct_num_slaves,
329 num_per_slave=num_per_slave,
330 revision=skia_revision,
331 ) +
332 api.path.exists(
333 api.path['slave_build'].join('skia'),
334 api.path['slave_build'].join('src')
335 )
336 )
337
338 yield(
339 api.test('CT_GPU_BENCH_10k_SKPs') +
340 api.properties(
341 buildername=
342 'Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_10k_SKPs',
343 mastername=mastername,
344 slavename=slavename,
345 buildnumber=buildnumber,
346 path_config=path_config,
347 swarm_out_dir='[SWARM_OUT_DIR]',
348 ct_num_slaves=ct_num_slaves,
349 num_per_slave=num_per_slave,
350 revision=skia_revision,
351 ) +
352 api.path.exists(
353 api.path['slave_build'].join('skia'),
354 api.path['slave_build'].join('src')
355 )
356 )
357
358 yield(
359 api.test('CT_DM_1m_SKPs') +
360 api.properties(
361 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
362 mastername=mastername,
363 slavename=slavename,
364 buildnumber=buildnumber,
365 path_config=path_config,
366 swarm_out_dir='[SWARM_OUT_DIR]',
367 ct_num_slaves=ct_num_slaves,
368 num_per_slave=num_per_slave,
369 revision=skia_revision,
370 )
371 )
372
373 yield (
374 api.test('CT_DM_SKPs_UnknownBuilder') +
375 api.properties(
376 buildername=
377 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_UnknownRepo_SKPs',
378 mastername=mastername,
379 slavename=slavename,
380 buildnumber=buildnumber,
381 path_config=path_config,
382 swarm_out_dir='[SWARM_OUT_DIR]',
383 ct_num_slaves=ct_num_slaves,
384 num_per_slave=num_per_slave,
385 revision=skia_revision,
386 ) +
387 api.expect_exception('Exception')
388 )
389
390 yield (
391 api.test('CT_10k_SKPs_UnknownBuilder') +
392 api.properties(
393 buildername=
394 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_UnknownTool_10k_SKPs',
395 mastername=mastername,
396 slavename=slavename,
397 buildnumber=buildnumber,
398 path_config=path_config,
399 swarm_out_dir='[SWARM_OUT_DIR]',
400 ct_num_slaves=ct_num_slaves,
401 num_per_slave=num_per_slave,
402 revision=skia_revision,
403 ) +
404 api.expect_exception('Exception')
405 )
406
407 yield(
408 api.test('CT_DM_1m_SKPs_slave3_failure') +
409 api.step_data('ct-dm-3 on Ubuntu-14.04', retcode=1) +
410 api.properties(
411 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
412 mastername=mastername,
413 slavename=slavename,
414 buildnumber=buildnumber,
415 path_config=path_config,
416 swarm_out_dir='[SWARM_OUT_DIR]',
417 ct_num_slaves=ct_num_slaves,
418 num_per_slave=num_per_slave,
419 revision=skia_revision,
420 )
421 )
422
423 yield(
424 api.test('CT_DM_1m_SKPs_2slaves_failure') +
425 api.step_data('ct-dm-1 on Ubuntu-14.04', retcode=1) +
426 api.step_data('ct-dm-3 on Ubuntu-14.04', retcode=1) +
427 api.properties(
428 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
429 mastername=mastername,
430 slavename=slavename,
431 buildnumber=buildnumber,
432 path_config=path_config,
433 swarm_out_dir='[SWARM_OUT_DIR]',
434 ct_num_slaves=ct_num_slaves,
435 num_per_slave=num_per_slave,
436 revision=skia_revision,
437 )
438 )
439
440 yield(
441 api.test('CT_DM_10k_SKPs_Trybot') +
442 api.properties(
443 buildername=
444 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_10k_SKPs-Trybot',
445 mastername=mastername,
446 slavename=slavename,
447 buildnumber=buildnumber,
448 path_config=path_config,
449 swarm_out_dir='[SWARM_OUT_DIR]',
450 ct_num_slaves=ct_num_slaves,
451 num_per_slave=num_per_slave,
452 rietveld='codereview.chromium.org',
453 issue=1499623002,
454 patchset=1,
455 )
456 )
457
458 yield(
459 api.test('CT_IMG_DECODE_10k_SKPs_Trybot') +
460 api.properties(
461 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
462 '10k_SKPs_Trybot',
463 mastername=mastername,
464 slavename=slavename,
465 buildnumber=buildnumber,
466 path_config=path_config,
467 swarm_out_dir='[SWARM_OUT_DIR]',
468 ct_num_slaves=ct_num_slaves,
469 num_per_slave=num_per_slave,
470 revision=skia_revision,
471 )
472 )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698