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

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

Issue 1565113003: Add concept of bot config and test spec database (BotConfigAndTestDB). (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 11 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 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 23 matching lines...) Expand all
34 34
35 %(results)s 35 %(results)s
36 """ 36 """
37 37
38 38
39 class PerfTryJobApi(recipe_api.RecipeApi): 39 class PerfTryJobApi(recipe_api.RecipeApi):
40 40
41 def __init__(self, *args, **kwargs): 41 def __init__(self, *args, **kwargs):
42 super(PerfTryJobApi, self).__init__(*args, **kwargs) 42 super(PerfTryJobApi, self).__init__(*args, **kwargs)
43 43
44 def start_perf_try_job(self, affected_files, bot_update_step, master_dict): 44 def start_perf_try_job(self, affected_files, bot_update_step, bot_db):
45 """Entry point pert tryjob or CQ tryjob.""" 45 """Entry point pert tryjob or CQ tryjob."""
46 perf_config = self._get_perf_config(affected_files) 46 perf_config = self._get_perf_config(affected_files)
47 if perf_config: 47 if perf_config:
48 self._run_perf_job(perf_config, bot_update_step, master_dict) 48 self._run_perf_job(perf_config, bot_update_step, bot_db)
49 elif (not perf_config and 49 elif (not perf_config and
50 self.m.properties.get('requester') == 'commit-bot@chromium.org'): 50 self.m.properties.get('requester') == 'commit-bot@chromium.org'):
51 self.run_cq_job(bot_update_step, master_dict, affected_files) 51 self.run_cq_job(bot_update_step, bot_db, affected_files)
52 else: 52 else:
53 self.m.halt('Could not load config file. Double check your changes to ' 53 self.m.halt('Could not load config file. Double check your changes to '
54 'config files for syntax errors.') 54 'config files for syntax errors.')
55 55
56 def _run_perf_job(self, perf_cfg, bot_update_step, master_dict): 56 def _run_perf_job(self, perf_cfg, bot_update_step, bot_db):
57 """Runs performance try job with and without patch.""" 57 """Runs performance try job with and without patch."""
58 r = self._resolve_revisions_from_config(perf_cfg) 58 r = self._resolve_revisions_from_config(perf_cfg)
59 test_cfg = self.m.bisect_tester.load_config_from_dict(perf_cfg) 59 test_cfg = self.m.bisect_tester.load_config_from_dict(perf_cfg)
60 60
61 # TODO(prasadv): This is tempory hack to prepend 'src' to test command, 61 # TODO(prasadv): This is tempory hack to prepend 'src' to test command,
62 # until dashboard and trybot scripts are changed. 62 # until dashboard and trybot scripts are changed.
63 _prepend_src_to_path_in_command(test_cfg) 63 _prepend_src_to_path_in_command(test_cfg)
64 # Run with patch. 64 # Run with patch.
65 results_with_patch = self._build_and_run_tests( 65 results_with_patch = self._build_and_run_tests(
66 test_cfg, bot_update_step, master_dict, r[0], 66 test_cfg, bot_update_step, bot_db, r[0],
67 name='With Patch' if r[0] is None else r[0], 67 name='With Patch' if r[0] is None else r[0],
68 reset_on_first_run=True, 68 reset_on_first_run=True,
69 upload_on_last_run=True, 69 upload_on_last_run=True,
70 results_label='Patch' if r[0] is None else r[0], 70 results_label='Patch' if r[0] is None else r[0],
71 allow_flakes=False) 71 allow_flakes=False)
72 72
73 if not any(r): 73 if not any(r):
74 # Revert changes. 74 # Revert changes.
75 self.m.chromium_tests.deapply_patch(bot_update_step) 75 self.m.chromium_tests.deapply_patch(bot_update_step)
76 76
77 # Run without patch. 77 # Run without patch.
78 results_without_patch = self._build_and_run_tests( 78 results_without_patch = self._build_and_run_tests(
79 test_cfg, bot_update_step, master_dict, r[1], 79 test_cfg, bot_update_step, bot_db, r[1],
80 name='Without Patch' if r[1] is None else r[1], 80 name='Without Patch' if r[1] is None else r[1],
81 reset_on_first_run=False, 81 reset_on_first_run=False,
82 upload_on_last_run=True, 82 upload_on_last_run=True,
83 results_label='TOT' if r[1] is None else r[1], 83 results_label='TOT' if r[1] is None else r[1],
84 allow_flakes=False) 84 allow_flakes=False)
85 85
86 labels = { 86 labels = {
87 'profiler_link1': ('%s - Profiler Data' % 'With Patch' 87 'profiler_link1': ('%s - Profiler Data' % 'With Patch'
88 if r[0] is None else r[0]), 88 if r[0] is None else r[0]),
89 'profiler_link2': ('%s - Profiler Data' % 'Without Patch' 89 'profiler_link2': ('%s - Profiler Data' % 'Without Patch'
90 if r[1] is None else r[1]) 90 if r[1] is None else r[1])
91 } 91 }
92 self._compare_and_present_results( 92 self._compare_and_present_results(
93 test_cfg, results_without_patch, results_with_patch, labels) 93 test_cfg, results_without_patch, results_with_patch, labels)
94 94
95 def run_cq_job(self, update_step, master_dict, files_in_patch): 95 def run_cq_job(self, update_step, bot_db, files_in_patch):
96 """Runs benchmarks affected by a CL on CQ.""" 96 """Runs benchmarks affected by a CL on CQ."""
97 buildername = self.m.properties['buildername'] 97 buildername = self.m.properties['buildername']
98 affected_benchmarks = self._get_affected_benchmarks(files_in_patch) 98 affected_benchmarks = self._get_affected_benchmarks(files_in_patch)
99 if not affected_benchmarks: 99 if not affected_benchmarks:
100 step_result = self.m.step('Results', []) 100 step_result = self.m.step('Results', [])
101 step_result.presentation.step_text = ( 101 step_result.presentation.step_text = (
102 'There are no modifications to Telemetry benchmarks,' 102 'There are no modifications to Telemetry benchmarks,'
103 ' aborting the try job.') 103 ' aborting the try job.')
104 return 104 return
105 self._compile('With Patch', self.m.properties['mastername'], 105 self._compile('With Patch', self.m.properties['mastername'],
106 self.m.properties['buildername'], update_step, master_dict) 106 self.m.properties['buildername'], update_step, bot_db)
107 107
108 if self.m.chromium.c.TARGET_PLATFORM == 'android': 108 if self.m.chromium.c.TARGET_PLATFORM == 'android':
109 self.m.chromium_android.adb_install_apk('ChromePublic.apk') 109 self.m.chromium_android.adb_install_apk('ChromePublic.apk')
110 110
111 tests = self.m.chromium.list_perf_tests(_get_browser(buildername), 1) 111 tests = self.m.chromium.list_perf_tests(_get_browser(buildername), 1)
112 112
113 tests = dict((k, v) for k, v in tests.json.output['steps'].iteritems() 113 tests = dict((k, v) for k, v in tests.json.output['steps'].iteritems()
114 if _is_benchmark_match(k, affected_benchmarks)) 114 if _is_benchmark_match(k, affected_benchmarks))
115 115
116 if not tests: 116 if not tests:
(...skipping 21 matching lines...) Expand all
138 """Gets list of modified benchmark files under tools/perf/benchmarks.""" 138 """Gets list of modified benchmark files under tools/perf/benchmarks."""
139 modified_benchmarks = [] 139 modified_benchmarks = []
140 for affected_file in files_in_patch: 140 for affected_file in files_in_patch:
141 if (affected_file.startswith(PERF_BENCHMARKS_PATH) or 141 if (affected_file.startswith(PERF_BENCHMARKS_PATH) or
142 affected_file.startswith(PERF_MEASUREMENTS_PATH)): 142 affected_file.startswith(PERF_MEASUREMENTS_PATH)):
143 benchmark = self.m.path.basename( 143 benchmark = self.m.path.basename(
144 self.m.path.splitext(affected_file)[0]) 144 self.m.path.splitext(affected_file)[0])
145 modified_benchmarks.append(benchmark) 145 modified_benchmarks.append(benchmark)
146 return modified_benchmarks 146 return modified_benchmarks
147 147
148 def _checkout_revision(self, update_step, master_dict, revision=None): 148 def _checkout_revision(self, update_step, bot_db, revision=None):
149 """Checkouts specific revisions and updates bot_update step.""" 149 """Checkouts specific revisions and updates bot_update step."""
150 if revision: 150 if revision:
151 if self.m.platform.is_win: # pragma: no cover 151 if self.m.platform.is_win: # pragma: no cover
152 self.m.chromium.taskkill() 152 self.m.chromium.taskkill()
153 self.m.gclient.c.revisions['src'] = str(revision) 153 self.m.gclient.c.revisions['src'] = str(revision)
154 update_step = self.m.bot_update.ensure_checkout( 154 update_step = self.m.bot_update.ensure_checkout(
155 suffix=str(revision), force=True, patch=False, 155 suffix=str(revision), force=True, patch=False,
156 update_presentation=False) 156 update_presentation=False)
157 assert update_step.json.output['did_run'] 157 assert update_step.json.output['did_run']
158 self.m.chromium.runhooks(name='runhooks on %s' % str(revision)) 158 self.m.chromium.runhooks(name='runhooks on %s' % str(revision))
159 159
160 return update_step 160 return update_step
161 161
162 def _compile(self, name, mastername, buildername, update_step, 162 def _compile(self, name, mastername, buildername, update_step, bot_db):
163 master_dict, test_spec=None):
164 """Runs compile and related steps for given builder.""" 163 """Runs compile and related steps for given builder."""
165 if test_spec is None:
166 test_spec = {}
167 compile_targets, _ = self.m.chromium_tests.get_compile_targets_and_tests( 164 compile_targets, _ = self.m.chromium_tests.get_compile_targets_and_tests(
168 mastername, 165 mastername,
169 buildername, 166 buildername,
170 master_dict, 167 bot_db,
171 test_spec,
172 override_bot_type='builder_tester', 168 override_bot_type='builder_tester',
173 override_tests=[]) 169 override_tests=[])
174 if self.m.chromium.c.TARGET_PLATFORM == 'android': 170 if self.m.chromium.c.TARGET_PLATFORM == 'android':
175 self.m.chromium_android.clean_local_files() 171 self.m.chromium_android.clean_local_files()
176 compile_targets = None 172 compile_targets = None
177 else: 173 else:
178 # Removes any chrome temporary files or build.dead directories. 174 # Removes any chrome temporary files or build.dead directories.
179 self.m.chromium.cleanup_temp() 175 self.m.chromium.cleanup_temp()
180 176
181 if 'With Patch' in name: 177 if 'With Patch' in name:
(...skipping 16 matching lines...) Expand all
198 overall_success = all(v == 0 for v in retcodes) 194 overall_success = all(v == 0 for v in retcodes)
199 if not overall_success: # pragma: no cover 195 if not overall_success: # pragma: no cover
200 raise self.m.step.StepFailure( 196 raise self.m.step.StepFailure(
201 'Patched version failed to run performance test.') 197 'Patched version failed to run performance test.')
202 return { 198 return {
203 'results': all_values, 199 'results': all_values,
204 'ret_code': overall_success, 200 'ret_code': overall_success,
205 'output': ''.join(overall_output) 201 'output': ''.join(overall_output)
206 } 202 }
207 203
208 def _build_and_run_tests(self, cfg, update_step, master_dict, revision, 204 def _build_and_run_tests(self, cfg, update_step, bot_db, revision,
209 **kwargs): 205 **kwargs):
210 """Compiles binaries and runs tests for a given a revision.""" 206 """Compiles binaries and runs tests for a given a revision."""
211 update_step = self._checkout_revision(update_step, master_dict, revision) 207 update_step = self._checkout_revision(update_step, bot_db, revision)
212 self._compile(kwargs['name'], self.m.properties['mastername'], 208 self._compile(kwargs['name'], self.m.properties['mastername'],
213 self.m.properties['buildername'], update_step, master_dict) 209 self.m.properties['buildername'], update_step, bot_db)
214 210
215 if self.m.chromium.c.TARGET_PLATFORM == 'android': 211 if self.m.chromium.c.TARGET_PLATFORM == 'android':
216 self.m.chromium_android.adb_install_apk('ChromePublic.apk') 212 self.m.chromium_android.adb_install_apk('ChromePublic.apk')
217 213
218 return self._run_test(cfg, **kwargs) 214 return self._run_test(cfg, **kwargs)
219 215
220 def _load_config_file(self, name, src_path, **kwargs): 216 def _load_config_file(self, name, src_path, **kwargs):
221 """Attempts to load the specified config file and grab config dict.""" 217 """Attempts to load the specified config file and grab config dict."""
222 step_result = self.m.python( 218 step_result = self.m.python(
223 name, 219 name,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 438
443 def _prepend_src_to_path_in_command(test_cfg): 439 def _prepend_src_to_path_in_command(test_cfg):
444 command_to_run = [] 440 command_to_run = []
445 for v in test_cfg.get('command').split(): 441 for v in test_cfg.get('command').split():
446 if v in ['./tools/perf/run_benchmark', 442 if v in ['./tools/perf/run_benchmark',
447 'tools/perf/run_benchmark', 443 'tools/perf/run_benchmark',
448 'tools\\perf\\run_benchmark']: 444 'tools\\perf\\run_benchmark']:
449 v = 'src/tools/perf/run_benchmark' 445 v = 'src/tools/perf/run_benchmark'
450 command_to_run.append(v) 446 command_to_run.append(v)
451 test_cfg.update({'command': ' '.join(command_to_run)}) 447 test_cfg.update({'command': ' '.join(command_to_run)})
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698