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

Side by Side Diff: scripts/slave/recipe_modules/skia_swarming/api.py

Issue 2099713002: Download the Android SDK as a CIPD package (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@cipd_swarm
Patch Set: Rebase Created 4 years, 5 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
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 from recipe_engine import recipe_api 6 from recipe_engine import recipe_api
7 import shlex 7 import shlex
8 8
9 9
10 DEFAULT_TASK_EXPIRATION = 20*60*60 10 DEFAULT_TASK_EXPIRATION = 20*60*60
(...skipping 14 matching lines...) Expand all
25 """Directory where the outputs of the swarming tasks will be stored.""" 25 """Directory where the outputs of the swarming tasks will be stored."""
26 return self.swarming_temp_dir.join('outputs') 26 return self.swarming_temp_dir.join('outputs')
27 27
28 def isolated_file_path(self, task_name): 28 def isolated_file_path(self, task_name):
29 """Get the path to the given task's .isolated file.""" 29 """Get the path to the given task's .isolated file."""
30 return self.swarming_temp_dir.join('skia-task-%s.isolated' % task_name) 30 return self.swarming_temp_dir.join('skia-task-%s.isolated' % task_name)
31 31
32 def setup(self, luci_go_dir, swarming_rev=None): 32 def setup(self, luci_go_dir, swarming_rev=None):
33 """Performs setup steps for swarming.""" 33 """Performs setup steps for swarming."""
34 self.m.swarming_client.checkout(revision=swarming_rev) 34 self.m.swarming_client.checkout(revision=swarming_rev)
35 self.m.swarming.check_client_version() 35 self.m.swarming.check_client_version(step_test_data=(0, 8, 6))
36 self.setup_go_isolate(luci_go_dir) 36 self.setup_go_isolate(luci_go_dir)
37 37
38 # TODO(rmistry): Remove once the Go binaries are moved to recipes or buildbot. 38 # TODO(rmistry): Remove once the Go binaries are moved to recipes or buildbot.
39 def setup_go_isolate(self, luci_go_dir): 39 def setup_go_isolate(self, luci_go_dir):
40 """Generates and puts in place the isolate Go binary.""" 40 """Generates and puts in place the isolate Go binary."""
41 self.m.step('download luci-go linux', 41 self.m.step('download luci-go linux',
42 ['download_from_google_storage', '--no_resume', 42 ['download_from_google_storage', '--no_resume',
43 '--platform=linux*', '--no_auth', '--bucket', 'chromium-luci', 43 '--platform=linux*', '--no_auth', '--bucket', 'chromium-luci',
44 '-d', luci_go_dir.join('linux64')]) 44 '-d', luci_go_dir.join('linux64')])
45 self.m.step('download luci-go mac', 45 self.m.step('download luci-go mac',
46 ['download_from_google_storage', '--no_resume', 46 ['download_from_google_storage', '--no_resume',
47 '--platform=darwin', '--no_auth', '--bucket', 'chromium-luci', 47 '--platform=darwin', '--no_auth', '--bucket', 'chromium-luci',
48 '-d', luci_go_dir.join('mac64')]) 48 '-d', luci_go_dir.join('mac64')])
49 self.m.step('download luci-go win', 49 self.m.step('download luci-go win',
50 ['download_from_google_storage', '--no_resume', 50 ['download_from_google_storage', '--no_resume',
51 '--platform=win32', '--no_auth', '--bucket', 'chromium-luci', 51 '--platform=win32', '--no_auth', '--bucket', 'chromium-luci',
52 '-d', luci_go_dir.join('win64')]) 52 '-d', luci_go_dir.join('win64')])
53 # Copy binaries to the expected location. 53 # Copy binaries to the expected location.
54 dest = self.m.path['slave_build'].join('luci-go') 54 dest = self.m.path['slave_build'].join('luci-go')
55 self.m.file.rmtree('Go binary dir', dest) 55 self.m.file.rmtree('Go binary dir', dest)
56 self.m.file.copytree('Copy Go binary', 56 self.m.file.copytree('Copy Go binary',
57 source=luci_go_dir, 57 source=luci_go_dir,
58 dest=dest) 58 dest=dest)
59 59
60 def isolate_and_trigger_task( 60 def isolate_and_trigger_task(
61 self, isolate_path, isolate_base_dir, task_name, isolate_vars, 61 self, isolate_path, isolate_base_dir, task_name, isolate_vars,
62 swarm_dimensions, isolate_blacklist=None, extra_isolate_hashes=None, 62 swarm_dimensions, isolate_blacklist=None, extra_isolate_hashes=None,
63 idempotent=False, store_output=True, extra_args=None, expiration=None, 63 idempotent=False, store_output=True, extra_args=None, expiration=None,
64 hard_timeout=None, io_timeout=None): 64 hard_timeout=None, io_timeout=None, cipd_packages=None):
65 """Isolate inputs and trigger the task to run.""" 65 """Isolate inputs and trigger the task to run."""
66 os_type = swarm_dimensions.get('os', 'linux') 66 os_type = swarm_dimensions.get('os', 'linux')
67 isolated_hash = self.isolate_task( 67 isolated_hash = self.isolate_task(
68 isolate_path, isolate_base_dir, os_type, task_name, isolate_vars, 68 isolate_path, isolate_base_dir, os_type, task_name, isolate_vars,
69 blacklist=isolate_blacklist, extra_hashes=extra_isolate_hashes) 69 blacklist=isolate_blacklist, extra_hashes=extra_isolate_hashes)
70 tasks = self.trigger_swarming_tasks([(task_name, isolated_hash)], 70 tasks = self.trigger_swarming_tasks([(task_name, isolated_hash)],
71 swarm_dimensions, 71 swarm_dimensions,
72 idempotent=idempotent, 72 idempotent=idempotent,
73 store_output=store_output, 73 store_output=store_output,
74 extra_args=extra_args, 74 extra_args=extra_args,
75 expiration=expiration, 75 expiration=expiration,
76 hard_timeout=hard_timeout, 76 hard_timeout=hard_timeout,
77 io_timeout=io_timeout) 77 io_timeout=io_timeout,
78 cipd_packages=cipd_packages)
78 assert len(tasks) == 1 79 assert len(tasks) == 1
79 return tasks[0] 80 return tasks[0]
80 81
81 def isolate_task(self, isolate_path, base_dir, os_type, task_name, 82 def isolate_task(self, isolate_path, base_dir, os_type, task_name,
82 isolate_vars, blacklist=None, extra_hashes=None): 83 isolate_vars, blacklist=None, extra_hashes=None):
83 """Isolate inputs for the given task.""" 84 """Isolate inputs for the given task."""
84 self.create_isolated_gen_json(isolate_path, base_dir, os_type, 85 self.create_isolated_gen_json(isolate_path, base_dir, os_type,
85 task_name, isolate_vars, 86 task_name, isolate_vars,
86 blacklist=blacklist) 87 blacklist=blacklist)
87 hashes = self.batcharchive([task_name]) 88 hashes = self.batcharchive([task_name])
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 isolateserver = self.m.swarming_client.path.join('isolateserver.py') 172 isolateserver = self.m.swarming_client.path.join('isolateserver.py')
172 r = self.m.python('upload new .isolated file for %s' % task_name, 173 r = self.m.python('upload new .isolated file for %s' % task_name,
173 script=isolateserver, 174 script=isolateserver,
174 args=['archive', '--isolate-server', 175 args=['archive', '--isolate-server',
175 self.m.isolate.isolate_server, isolated_file], 176 self.m.isolate.isolate_server, isolated_file],
176 stdout=self.m.raw_io.output()) 177 stdout=self.m.raw_io.output())
177 return shlex.split(r.stdout)[0] 178 return shlex.split(r.stdout)[0]
178 179
179 def trigger_swarming_tasks( 180 def trigger_swarming_tasks(
180 self, swarm_hashes, dimensions, idempotent=False, store_output=True, 181 self, swarm_hashes, dimensions, idempotent=False, store_output=True,
181 extra_args=None, expiration=None, hard_timeout=None, io_timeout=None): 182 extra_args=None, expiration=None, hard_timeout=None, io_timeout=None,
183 cipd_packages=None):
182 """Triggers swarming tasks using swarm hashes. 184 """Triggers swarming tasks using swarm hashes.
183 185
184 Args: 186 Args:
185 swarm_hashes: list of str. List of swarm hashes from the isolate server. 187 swarm_hashes: list of str. List of swarm hashes from the isolate server.
186 dimensions: dict of str to str. The dimensions to run the task on. 188 dimensions: dict of str to str. The dimensions to run the task on.
187 Eg: {'os': 'Ubuntu', 'gpu': '10de', 'pool': 'Skia'} 189 Eg: {'os': 'Ubuntu', 'gpu': '10de', 'pool': 'Skia'}
188 idempotent: bool. Whether or not to de-duplicate tasks. 190 idempotent: bool. Whether or not to de-duplicate tasks.
189 store_output: bool. Whether task output should be stored. 191 store_output: bool. Whether task output should be stored.
190 extra_args: list of str. Extra arguments to pass to the task. 192 extra_args: list of str. Extra arguments to pass to the task.
191 expiration: int. Task will expire if not picked up within this time. 193 expiration: int. Task will expire if not picked up within this time.
192 DEFAULT_TASK_EXPIRATION is used if this argument is None. 194 DEFAULT_TASK_EXPIRATION is used if this argument is None.
193 hard_timeout: int. Task will timeout if not completed within this time. 195 hard_timeout: int. Task will timeout if not completed within this time.
194 DEFAULT_TASK_TIMEOUT is used if this argument is None. 196 DEFAULT_TASK_TIMEOUT is used if this argument is None.
195 io_timeout: int. Task will timeout if there is no output within this time. 197 io_timeout: int. Task will timeout if there is no output within this time.
196 DEFAULT_IO_TIMEOUT is used if this argument is None. 198 DEFAULT_IO_TIMEOUT is used if this argument is None.
199 cipd_packages: CIPD packages which these tasks depend on.
197 200
198 Returns: 201 Returns:
199 List of swarming.SwarmingTask instances. 202 List of swarming.SwarmingTask instances.
200 """ 203 """
201 swarming_tasks = [] 204 swarming_tasks = []
202 for task_name, swarm_hash in swarm_hashes: 205 for task_name, swarm_hash in swarm_hashes:
203 swarming_task = self.m.swarming.task( 206 swarming_task = self.m.swarming.task(
204 title=task_name, 207 title=task_name,
208 cipd_packages=cipd_packages,
205 isolated_hash=swarm_hash) 209 isolated_hash=swarm_hash)
206 if store_output: 210 if store_output:
207 swarming_task.task_output_dir = self.tasks_output_dir.join(task_name) 211 swarming_task.task_output_dir = self.tasks_output_dir.join(task_name)
208 swarming_task.dimensions = dimensions 212 swarming_task.dimensions = dimensions
209 swarming_task.idempotent = idempotent 213 swarming_task.idempotent = idempotent
210 swarming_task.priority = 90 214 swarming_task.priority = 90
211 swarming_task.expiration = ( 215 swarming_task.expiration = (
212 expiration if expiration else DEFAULT_TASK_EXPIRATION) 216 expiration if expiration else DEFAULT_TASK_EXPIRATION)
213 swarming_task.hard_timeout = ( 217 swarming_task.hard_timeout = (
214 hard_timeout if hard_timeout else DEFAULT_TASK_TIMEOUT) 218 hard_timeout if hard_timeout else DEFAULT_TASK_TIMEOUT)
(...skipping 29 matching lines...) Expand all
244 def collect_swarming_task_isolate_hash(self, swarming_task): 248 def collect_swarming_task_isolate_hash(self, swarming_task):
245 """Wait for the given swarming task to finish and return its output hash. 249 """Wait for the given swarming task to finish and return its output hash.
246 250
247 Args: 251 Args:
248 swarming_task: An instance of swarming.SwarmingTask. 252 swarming_task: An instance of swarming.SwarmingTask.
249 Returns: 253 Returns:
250 the hash of the isolate output of the task. 254 the hash of the isolate output of the task.
251 """ 255 """
252 res = self.collect_swarming_task(swarming_task) 256 res = self.collect_swarming_task(swarming_task)
253 return res.json.output['shards'][0]['isolated_out']['isolated'] 257 return res.json.output['shards'][0]['isolated_out']['isolated']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698