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

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: Address comments 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 extra_variables = {
155 'SLAVE_NUM': str(slave_num),
156 'TOOL_NAME': skia_tool,
157 'GIT_HASH': api.vars.got_revision,
158 'CONFIGURATION': api.vars.configuration,
159 'BUILDER': buildername,
160 }
161 api.swarming.create_isolated_gen_json(
162 isolate_path, isolate_dir, 'linux', 'ct-%s-%s' % (skia_tool, slave_num),
163 extra_variables, blacklist=blacklist_skps)
164
165 if download_skps:
166 # Since we had to download SKPs create an updated version file.
167 api.file.write("Create %s" % version_file,
168 version_file,
169 api.json.dumps(expected_version_contents),
170 infra_step=True)
171
172 # Batcharchive everything on the isolate server for efficiency.
173 max_slaves_to_batcharchive = MAX_SLAVES_TO_BATCHARCHIVE
174 if '1m' in buildername:
175 # Break up the "isolate tests" step into batches with <100k files due to
176 # https://github.com/luci/luci-go/issues/9
177 max_slaves_to_batcharchive = 5
178 tasks_to_swarm_hashes = []
179 for slave_start_num in xrange(1, ct_num_slaves+1, max_slaves_to_batcharchive):
180 m = min(max_slaves_to_batcharchive, ct_num_slaves)
181 batcharchive_output = api.swarming.batcharchive(
182 targets=['ct-' + skia_tool + '-%s' % num for num in range(
183 slave_start_num, slave_start_num + m)])
184 tasks_to_swarm_hashes.extend(batcharchive_output)
185 # Sort the list to go through tasks in order.
186 tasks_to_swarm_hashes.sort()
187
188 # Trigger all swarming tasks.
189 dimensions={'os': 'Ubuntu-14.04', 'cpu': 'x86-64', 'pool': 'Chrome'}
190 if 'GPU' in buildername:
191 dimensions['gpu'] = '10de:104a'
192 tasks = api.swarming.trigger_swarming_tasks(
193 tasks_to_swarm_hashes, dimensions=dimensions, io_timeout=40*60)
194
195 # Now collect all tasks.
196 failed_tasks = []
197 for task in tasks:
198 try:
199 api.swarming.collect_swarming_task(task)
200
201 if skia_tool == 'nanobench':
202 output_dir = api.swarming.tasks_output_dir.join(
203 task.title).join('0')
204 utc = api.time.utcnow()
205 gs_dest_dir = 'ct/%s/%d/%02d/%02d/%02d/' % (
206 ct_page_type, utc.year, utc.month, utc.day, utc.hour)
207 for json_output in api.file.listdir('output dir', output_dir):
208 api.gsutil.upload(
209 name='upload json output',
210 source=output_dir.join(json_output),
211 bucket='skia-perf',
212 dest=gs_dest_dir,
213 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None},
214 args=['-R']
215 )
216
217 except api.step.StepFailure as e:
218 failed_tasks.append(e)
219
220 if failed_tasks:
221 raise api.step.StepFailure(
222 'Failed steps: %s' % ', '.join([f.name for f in failed_tasks]))
223
224
225 def GenTests(api):
226 ct_num_slaves = 5
227 num_per_slave = 10
228 skia_revision = 'abc123'
229 mastername = 'client.skia'
230 slavename = 'skiabot-linux-swarm-000'
231 buildnumber = 2
232 path_config = 'kitchen'
233
234 yield(
235 api.test('CT_DM_10k_SKPs') +
236 api.properties(
237 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_10k_SKPs',
238 mastername=mastername,
239 slavename=slavename,
240 buildnumber=buildnumber,
241 path_config=path_config,
242 swarm_out_dir='[SWARM_OUT_DIR]',
243 ct_num_slaves=ct_num_slaves,
244 num_per_slave=num_per_slave,
245 revision=skia_revision,
246 )
247 )
248
249 yield(
250 api.test('CT_IMG_DECODE_10k_SKPs') +
251 api.properties(
252 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
253 '10k_SKPs',
254 mastername=mastername,
255 slavename=slavename,
256 buildnumber=buildnumber,
257 path_config=path_config,
258 swarm_out_dir='[SWARM_OUT_DIR]',
259 ct_num_slaves=ct_num_slaves,
260 num_per_slave=num_per_slave,
261 revision=skia_revision,
262 )
263 )
264
265 yield(
266 api.test('CT_DM_100k_SKPs') +
267 api.properties(
268 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_100k_SKPs',
269 mastername=mastername,
270 slavename=slavename,
271 buildnumber=buildnumber,
272 path_config=path_config,
273 swarm_out_dir='[SWARM_OUT_DIR]',
274 ct_num_slaves=ct_num_slaves,
275 num_per_slave=num_per_slave,
276 revision=skia_revision,
277 )
278 )
279
280 yield(
281 api.test('CT_IMG_DECODE_100k_SKPs') +
282 api.properties(
283 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
284 '100k_SKPs',
285 mastername=mastername,
286 slavename=slavename,
287 buildnumber=buildnumber,
288 path_config=path_config,
289 swarm_out_dir='[SWARM_OUT_DIR]',
290 ct_num_slaves=ct_num_slaves,
291 num_per_slave=num_per_slave,
292 revision=skia_revision,
293 )
294 )
295
296 yield(
297 api.test('CT_GPU_BENCH_1k_SKPs') +
298 api.properties(
299 buildername=
300 'Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_1k_SKPs',
301 mastername=mastername,
302 slavename=slavename,
303 buildnumber=buildnumber,
304 path_config=path_config,
305 swarm_out_dir='[SWARM_OUT_DIR]',
306 ct_num_slaves=ct_num_slaves,
307 num_per_slave=num_per_slave,
308 revision=skia_revision,
309 ) +
310 api.path.exists(
311 api.path['slave_build'].join('skia'),
312 api.path['slave_build'].join('src')
313 )
314 )
315
316 yield(
317 api.test('CT_CPU_BENCH_10k_SKPs') +
318 api.properties(
319 buildername=
320 'Perf-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-CT_BENCH_10k_SKPs',
321 mastername=mastername,
322 slavename=slavename,
323 buildnumber=buildnumber,
324 path_config=path_config,
325 swarm_out_dir='[SWARM_OUT_DIR]',
326 ct_num_slaves=ct_num_slaves,
327 num_per_slave=num_per_slave,
328 revision=skia_revision,
329 ) +
330 api.path.exists(
331 api.path['slave_build'].join('skia'),
332 api.path['slave_build'].join('src')
333 )
334 )
335
336 yield(
337 api.test('CT_GPU_BENCH_10k_SKPs') +
338 api.properties(
339 buildername=
340 'Perf-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-CT_BENCH_10k_SKPs',
341 mastername=mastername,
342 slavename=slavename,
343 buildnumber=buildnumber,
344 path_config=path_config,
345 swarm_out_dir='[SWARM_OUT_DIR]',
346 ct_num_slaves=ct_num_slaves,
347 num_per_slave=num_per_slave,
348 revision=skia_revision,
349 ) +
350 api.path.exists(
351 api.path['slave_build'].join('skia'),
352 api.path['slave_build'].join('src')
353 )
354 )
355
356 yield(
357 api.test('CT_DM_1m_SKPs') +
358 api.properties(
359 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
360 mastername=mastername,
361 slavename=slavename,
362 buildnumber=buildnumber,
363 path_config=path_config,
364 swarm_out_dir='[SWARM_OUT_DIR]',
365 ct_num_slaves=ct_num_slaves,
366 num_per_slave=num_per_slave,
367 revision=skia_revision,
368 )
369 )
370
371 yield (
372 api.test('CT_DM_SKPs_UnknownBuilder') +
373 api.properties(
374 buildername=
375 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_UnknownRepo_SKPs',
376 mastername=mastername,
377 slavename=slavename,
378 buildnumber=buildnumber,
379 path_config=path_config,
380 swarm_out_dir='[SWARM_OUT_DIR]',
381 ct_num_slaves=ct_num_slaves,
382 num_per_slave=num_per_slave,
383 revision=skia_revision,
384 ) +
385 api.expect_exception('Exception')
386 )
387
388 yield (
389 api.test('CT_10k_SKPs_UnknownBuilder') +
390 api.properties(
391 buildername=
392 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_UnknownTool_10k_SKPs',
393 mastername=mastername,
394 slavename=slavename,
395 buildnumber=buildnumber,
396 path_config=path_config,
397 swarm_out_dir='[SWARM_OUT_DIR]',
398 ct_num_slaves=ct_num_slaves,
399 num_per_slave=num_per_slave,
400 revision=skia_revision,
401 ) +
402 api.expect_exception('Exception')
403 )
404
405 yield(
406 api.test('CT_DM_1m_SKPs_slave3_failure') +
407 api.step_data('ct-dm-3 on Ubuntu-14.04', retcode=1) +
408 api.properties(
409 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
410 mastername=mastername,
411 slavename=slavename,
412 buildnumber=buildnumber,
413 path_config=path_config,
414 swarm_out_dir='[SWARM_OUT_DIR]',
415 ct_num_slaves=ct_num_slaves,
416 num_per_slave=num_per_slave,
417 revision=skia_revision,
418 )
419 )
420
421 yield(
422 api.test('CT_DM_1m_SKPs_2slaves_failure') +
423 api.step_data('ct-dm-1 on Ubuntu-14.04', retcode=1) +
424 api.step_data('ct-dm-3 on Ubuntu-14.04', retcode=1) +
425 api.properties(
426 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_1m_SKPs',
427 mastername=mastername,
428 slavename=slavename,
429 buildnumber=buildnumber,
430 path_config=path_config,
431 swarm_out_dir='[SWARM_OUT_DIR]',
432 ct_num_slaves=ct_num_slaves,
433 num_per_slave=num_per_slave,
434 revision=skia_revision,
435 )
436 )
437
438 yield(
439 api.test('CT_DM_10k_SKPs_Trybot') +
440 api.properties(
441 buildername=
442 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_DM_10k_SKPs-Trybot',
443 mastername=mastername,
444 slavename=slavename,
445 buildnumber=buildnumber,
446 path_config=path_config,
447 swarm_out_dir='[SWARM_OUT_DIR]',
448 ct_num_slaves=ct_num_slaves,
449 num_per_slave=num_per_slave,
450 rietveld='codereview.chromium.org',
451 issue=1499623002,
452 patchset=1,
453 )
454 )
455
456 yield(
457 api.test('CT_IMG_DECODE_10k_SKPs_Trybot') +
458 api.properties(
459 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-CT_IMG_DECODE_'
460 '10k_SKPs_Trybot',
461 mastername=mastername,
462 slavename=slavename,
463 buildnumber=buildnumber,
464 path_config=path_config,
465 swarm_out_dir='[SWARM_OUT_DIR]',
466 ct_num_slaves=ct_num_slaves,
467 num_per_slave=num_per_slave,
468 revision=skia_revision,
469 )
470 )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698