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

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

Issue 2237293005: Add support to Perf tryjobs to read test attributes from buildbot properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: 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
« no previous file with comments | « scripts/slave/recipe_modules/auto_bisect/api.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 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 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 """API for the perf try job recipe module. 5 """API for the perf try job recipe module.
6 6
7 This API is meant to enable the perf try job recipe on any chromium-supported 7 This API is meant to enable the perf try job recipe on any chromium-supported
8 platform for any test that can be run via buildbot, perf or otherwise. 8 platform for any test that can be run via buildbot, perf or otherwise.
9 """ 9 """
10 10
(...skipping 24 matching lines...) Expand all
35 Standard Error: +- %(std_err).05f delta 35 Standard Error: +- %(std_err).05f delta
36 36
37 %(results)s 37 %(results)s
38 """ 38 """
39 39
40 class PerfTryJobApi(recipe_api.RecipeApi): 40 class PerfTryJobApi(recipe_api.RecipeApi):
41 41
42 def __init__(self, *args, **kwargs): 42 def __init__(self, *args, **kwargs):
43 super(PerfTryJobApi, self).__init__(*args, **kwargs) 43 super(PerfTryJobApi, self).__init__(*args, **kwargs)
44 44
45 def start_perf_try_job(self, affected_files, bot_update_step, bot_db): 45 def start_perf_try_job(self, api, affected_files, bot_update_step, bot_db):
46 """Entry point pert tryjob or CQ tryjob.""" 46 """Entry point pert tryjob or CQ tryjob."""
47 perf_config = self._get_perf_config(affected_files) 47 perf_config = self._get_perf_config(api, affected_files)
48 if perf_config: 48 if perf_config:
49 self._run_perf_job(perf_config, bot_update_step, bot_db) 49 self._run_perf_job(perf_config, bot_update_step, bot_db)
50 elif (not perf_config and 50 elif (not perf_config and
51 self.m.properties.get('requester') == 'commit-bot@chromium.org'): 51 self.m.properties.get('requester') == 'commit-bot@chromium.org'):
52 self.run_cq_job(bot_update_step, bot_db, affected_files) 52 self.run_cq_job(bot_update_step, bot_db, affected_files)
53 else: 53 else:
54 self.m.halt('Could not load config file. Double check your changes to ' 54 self.m.halt('Could not load config file. Double check your changes to '
55 'config files for syntax errors.') 55 'config files for syntax errors.')
56 56
57 def _run_perf_job(self, perf_cfg, bot_update_step, bot_db): 57 def _run_perf_job(self, perf_cfg, bot_update_step, bot_db):
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 step_result = self.m.python( 221 step_result = self.m.python(
222 name, 222 name,
223 self.resource('load_config_to_json.py'), 223 self.resource('load_config_to_json.py'),
224 ['--source', src_path, '--output_json', self.m.json.output()], 224 ['--source', src_path, '--output_json', self.m.json.output()],
225 **kwargs) 225 **kwargs)
226 if not step_result.json.output: # pragma: no cover 226 if not step_result.json.output: # pragma: no cover
227 raise self.m.step.StepFailure('Loading config file failed. [%s]' % 227 raise self.m.step.StepFailure('Loading config file failed. [%s]' %
228 src_path) 228 src_path)
229 return step_result.json.output 229 return step_result.json.output
230 230
231 def _get_perf_config(self, affected_files): 231 def _get_perf_config(self, api, affected_files):
232 """Checks affected config file and loads the config params to a dict.""" 232 """Checks affected config file and loads the config params to a dict."""
233 perf_cfg_files = [PERF_CONFIG_FILE, WEBKIT_PERF_CONFIG_FILE] 233 perf_cfg_files = [PERF_CONFIG_FILE, WEBKIT_PERF_CONFIG_FILE]
234 cfg_file = [f for f in perf_cfg_files if str(f) in affected_files] 234 cfg_file = [f for f in perf_cfg_files if str(f) in affected_files]
235 if not cfg_file: # pragma: no cover 235 if cfg_file: # pragma: no cover
236 # Try reading any possible perf test config files.
237 cfg_content = self._load_config_file(
238 'load config', self.m.path['checkout'].join(cfg_file[0]))
239 elif api.properties.get('perf_try_config'): # pragma: no cover
240 cfg_content = dict(api.m.properties.get('perf_try_config'))
241 else:
236 return None 242 return None
237 # Try reading any possible perf test config files. 243
238 cfg_content = self._load_config_file(
239 'load config', self.m.path['checkout'].join(cfg_file[0]))
240 cfg_is_valid = _validate_perf_config( 244 cfg_is_valid = _validate_perf_config(
241 cfg_content, required_parameters=['command']) 245 cfg_content, required_parameters=['command'])
242 if cfg_content and cfg_is_valid: 246 if cfg_content and cfg_is_valid:
243 return cfg_content 247 return cfg_content
244 248
245 return None 249 return None
246 250
247 def _get_hash(self, rev): 251 def _get_hash(self, rev):
248 """Returns git hash for the given commit position.""" 252 """Returns git hash for the given commit position."""
249 def _check_if_hash(s): # pragma: no cover 253 def _check_if_hash(s): # pragma: no cover
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 506
503 def _prepend_src_to_path_in_command(test_cfg): 507 def _prepend_src_to_path_in_command(test_cfg):
504 command_to_run = [] 508 command_to_run = []
505 for v in test_cfg.get('command').split(): 509 for v in test_cfg.get('command').split():
506 if v in ['./tools/perf/run_benchmark', 510 if v in ['./tools/perf/run_benchmark',
507 'tools/perf/run_benchmark', 511 'tools/perf/run_benchmark',
508 'tools\\perf\\run_benchmark']: 512 'tools\\perf\\run_benchmark']:
509 v = 'src/tools/perf/run_benchmark' 513 v = 'src/tools/perf/run_benchmark'
510 command_to_run.append(v) 514 command_to_run.append(v)
511 test_cfg.update({'command': ' '.join(command_to_run)}) 515 test_cfg.update({'command': ' '.join(command_to_run)})
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/auto_bisect/api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698