Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 import re | 11 import re |
| 12 import urllib | 12 import urllib |
| 13 import uuid | |
| 13 | 14 |
| 14 from recipe_engine import recipe_api | 15 from recipe_engine import recipe_api |
| 16 from . import build_state | |
| 15 | 17 |
| 16 PERF_CONFIG_FILE = 'tools/run-perf-test.cfg' | 18 PERF_CONFIG_FILE = 'tools/run-perf-test.cfg' |
| 17 WEBKIT_PERF_CONFIG_FILE = 'third_party/WebKit/Tools/run-perf-test.cfg' | 19 WEBKIT_PERF_CONFIG_FILE = 'third_party/WebKit/Tools/run-perf-test.cfg' |
| 18 PERF_BENCHMARKS_PATH = 'tools/perf/benchmarks' | 20 PERF_BENCHMARKS_PATH = 'tools/perf/benchmarks' |
| 19 PERF_MEASUREMENTS_PATH = 'tools/perf/measurements' | 21 PERF_MEASUREMENTS_PATH = 'tools/perf/measurements' |
| 20 BUILDBOT_BUILDERNAME = 'BUILDBOT_BUILDERNAME' | 22 BUILDBOT_BUILDERNAME = 'BUILDBOT_BUILDERNAME' |
| 21 BENCHMARKS_JSON_FILE = 'benchmarks.json' | 23 BENCHMARKS_JSON_FILE = 'benchmarks.json' |
| 22 | 24 |
| 23 CLOUD_RESULTS_LINK = (r'\s(?P<VALUES>http://storage.googleapis.com/' | 25 CLOUD_RESULTS_LINK = (r'\s(?P<VALUES>http://storage.googleapis.com/' |
| 24 'chromium-telemetry/html-results/results-[a-z0-9-_]+)\s') | 26 'chromium-telemetry/html-results/results-[a-z0-9-_]+)\s') |
| 25 PROFILER_RESULTS_LINK = (r'\s(?P<VALUES>https://console.developers.google.com/' | 27 PROFILER_RESULTS_LINK = (r'\s(?P<VALUES>https://console.developers.google.com/' |
| 26 'm/cloudstorage/b/[a-z-]+/o/profiler-[a-z0-9-_.]+)\s') | 28 'm/cloudstorage/b/[a-z-]+/o/profiler-[a-z0-9-_.]+)\s') |
| 27 RESULTS_BANNER = """ | 29 RESULTS_BANNER = """ |
| 28 ===== PERF TRY JOB RESULTS ===== | 30 ===== PERF TRY JOB RESULTS ===== |
| 29 | 31 |
| 30 Test Command: %(command)s | 32 Test Command: %(command)s |
| 31 Test Metric: %(metric)s | 33 Test Metric: %(metric)s |
| 32 Relative Change: %(relative_change).05f%% | 34 Relative Change: %(relative_change).05f%% |
| 33 Standard Error: +- %(std_err).05f delta | 35 Standard Error: +- %(std_err).05f delta |
| 34 | 36 |
| 35 %(results)s | 37 %(results)s |
| 36 """ | 38 """ |
| 37 | 39 SERVICE_ACCOUNT = 'chromium_bisect' |
| 38 | 40 |
| 39 class PerfTryJobApi(recipe_api.RecipeApi): | 41 class PerfTryJobApi(recipe_api.RecipeApi): |
| 40 | 42 |
| 41 def __init__(self, *args, **kwargs): | 43 def __init__(self, *args, **kwargs): |
| 42 super(PerfTryJobApi, self).__init__(*args, **kwargs) | 44 super(PerfTryJobApi, self).__init__(*args, **kwargs) |
| 43 | 45 |
| 44 def start_perf_try_job(self, affected_files, bot_update_step, bot_db): | 46 def start_perf_try_job(self, affected_files, bot_update_step, bot_db): |
| 45 """Entry point pert tryjob or CQ tryjob.""" | 47 """Entry point pert tryjob or CQ tryjob.""" |
| 46 perf_config = self._get_perf_config(affected_files) | 48 perf_config = self._get_perf_config(affected_files) |
| 47 if perf_config: | 49 if perf_config: |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 return { | 212 return { |
| 211 'results': all_values, | 213 'results': all_values, |
| 212 'ret_code': overall_success, | 214 'ret_code': overall_success, |
| 213 'output': ''.join(overall_output) | 215 'output': ''.join(overall_output) |
| 214 } | 216 } |
| 215 | 217 |
| 216 def _build_and_run_tests(self, cfg, update_step, bot_db, revision, | 218 def _build_and_run_tests(self, cfg, update_step, bot_db, revision, |
| 217 **kwargs): | 219 **kwargs): |
| 218 """Compiles binaries and runs tests for a given a revision.""" | 220 """Compiles binaries and runs tests for a given a revision.""" |
| 219 update_step = self._checkout_revision(update_step, bot_db, revision) | 221 update_step = self._checkout_revision(update_step, bot_db, revision) |
| 220 self._compile(kwargs['name'], self.m.properties['mastername'], | 222 revision = build_state.BuildState(self, revision) |
| 221 self.m.properties['buildername'], update_step, bot_db) | 223 self._request_build(revision) |
| 222 | 224 self._wait_for(revision) |
| 225 self._download_build(update_step, bot_db, revision) | |
| 223 if self.m.chromium.c.TARGET_PLATFORM == 'android': | 226 if self.m.chromium.c.TARGET_PLATFORM == 'android': |
| 224 self.m.chromium_android.adb_install_apk('ChromePublic.apk') | 227 self.m.chromium_android.adb_install_apk('ChromePublic.apk') |
| 225 | 228 |
| 226 return self._run_test(cfg, **kwargs) | 229 return self._run_test(cfg, **kwargs) |
| 227 | 230 |
| 231 #Duplicate code from auto_bisect.revision_state._request_build | |
| 232 def _request_build(self, revision): | |
| 233 bot_name = self.get_builder_bot_for_this_platform() | |
| 234 build_details = { | |
| 235 'bucket': 'master.' + self.m.properties['mastername'], | |
| 236 'parameters': { | |
| 237 'buildername': bot_name, | |
| 238 'properties': { | |
| 239 'parent_got_revision': revision.commit_hash, | |
| 240 'clobber': True, | |
| 241 'build_archive_url': revision.build_file_path | |
| 242 } | |
| 243 }, | |
| 244 'client_operation_id': uuid.uuid4().hex, | |
| 245 'tags':{} | |
| 246 } | |
| 247 self.m.buildbucket.put([build_details], | |
|
prasadv
2016/06/15 17:55:14
I think we also should capture buildbucket id, so
Ziqi Xiong
2016/06/17 18:41:31
Done.
| |
| 248 self.m.service_account.get_json_path\ | |
| 249 (SERVICE_ACCOUNT)) | |
| 250 | |
| 251 def _wait_for(self, revision): | |
| 252 while True: | |
| 253 if revision.is_build_failed() or revision.is_build_archived(): | |
| 254 break | |
| 255 else: | |
| 256 self.m.python.inline( | |
| 257 'sleeping', | |
| 258 """ | |
| 259 import sys | |
| 260 import time | |
| 261 time.sleep(20*60) | |
| 262 sys.exit(0) | |
| 263 """) | |
| 264 | |
| 265 #Duplicate code from auto_bisect.api.start_test_run_for_bisect | |
|
prasadv
2016/06/15 17:55:14
space after #, do this where ever applicable
Ziqi Xiong
2016/06/17 18:41:31
Done.
| |
| 266 def _download_build(self, update_step, bot_db, | |
| 267 revision, run_locally=False, | |
| 268 skip_download=False): | |
| 269 mastername = self.m.properties.get('mastername') | |
| 270 buildername = self.m.properties.get('buildername') | |
| 271 bot_config = bot_db.get_bot_config(mastername, buildername) | |
| 272 build_archive_url = revision.build_file_path | |
| 273 # No need to upload_job_url in perf_try | |
| 274 # if not run_locally: | |
|
prasadv
2016/06/15 17:55:13
If these lines are not needed, then we can remove
Ziqi Xiong
2016/06/17 18:41:31
Done.
| |
| 275 # self.m.bisect_tester.upload_job_url() | |
| 276 if not skip_download: | |
| 277 if self.m.chromium.c.TARGET_PLATFORM == 'android': | |
| 278 # The best way to ensure the old build directory is not used is to | |
| 279 # remove it. | |
| 280 build_dir = self.m.chromium.c.build_dir.join( | |
| 281 self.m.chromium.c.build_config_fs) | |
| 282 self.m.file.rmtree('build directory', build_dir) | |
| 283 | |
| 284 # The way android builders on tryserver.chromium.perf are archived is | |
| 285 # different from builders on chromium.perf. In order to support both | |
| 286 # forms of archives, we added this temporary hack until builders are | |
| 287 # fixed. See http://crbug.com/535218. | |
| 288 zip_dir = self.m.path.join(self.m.path['checkout'], 'full-build-linux') | |
| 289 if self.m.path.exists(zip_dir): # pragma: no cover | |
| 290 self.m.file.rmtree('full-build-linux directory', zip_dir) | |
| 291 | |
| 292 gs_bucket = 'gs://%s/' % bot_config['bucket'] | |
| 293 archive_path = build_archive_url[len(gs_bucket):] | |
| 294 self.m.chromium_android.download_build( | |
| 295 bucket=bot_config['bucket'], | |
| 296 path=archive_path) | |
| 297 | |
| 298 # The way android builders on tryserver.chromium.perf are archived is | |
| 299 # different from builders on chromium.perf. In order to support both | |
| 300 # forms of archives, we added this temporary hack until builders are | |
| 301 # fixed. See http://crbug.com/535218. | |
| 302 if self.m.path.exists(zip_dir): # pragma: no cover | |
| 303 self.m.python.inline( | |
| 304 'moving full-build-linux to out/Release', | |
| 305 """ | |
| 306 import shutil | |
| 307 import sys | |
| 308 shutil.move(sys.argv[1], sys.argv[2]) | |
| 309 """, | |
| 310 args=[zip_dir, build_dir]) | |
| 311 else: | |
| 312 self.m.chromium_tests.download_and_unzip_build( | |
| 313 mastername, buildername, update_step, bot_db, | |
| 314 build_archive_url=build_archive_url, | |
| 315 build_revision=revision.commit_hash, | |
| 316 override_bot_type='tester') | |
| 317 | |
| 318 #Duplicate code from auto_bisect.bisector.get_builder_bot_for_this_platform | |
| 319 def get_builder_bot_for_this_platform(self): | |
| 320 bot_name = self.m.properties.get('buildername', '') | |
| 321 if 'win' in bot_name: | |
| 322 if any(b in bot_name for b in ['x64', 'gpu']): | |
| 323 return 'winx64_bisect_builder' | |
| 324 return 'win_perf_bisect_builder' | |
| 325 | |
| 326 if 'android' in bot_name: | |
| 327 if 'nexus9' in bot_name: | |
| 328 return 'android_arm64_perf_bisect_builder' | |
| 329 return 'android_perf_bisect_builder' | |
| 330 | |
| 331 if 'mac' in bot_name: | |
| 332 return 'mac_perf_bisect_builder' | |
| 333 | |
| 334 return 'linux_perf_bisect_builder' | |
| 335 | |
| 228 def _load_config_file(self, name, src_path, **kwargs): | 336 def _load_config_file(self, name, src_path, **kwargs): |
| 229 """Attempts to load the specified config file and grab config dict.""" | 337 """Attempts to load the specified config file and grab config dict.""" |
| 230 step_result = self.m.python( | 338 step_result = self.m.python( |
| 231 name, | 339 name, |
| 232 self.resource('load_config_to_json.py'), | 340 self.resource('load_config_to_json.py'), |
| 233 ['--source', src_path, '--output_json', self.m.json.output()], | 341 ['--source', src_path, '--output_json', self.m.json.output()], |
| 234 **kwargs) | 342 **kwargs) |
| 235 if not step_result.json.output: # pragma: no cover | 343 if not step_result.json.output: # pragma: no cover |
| 236 raise self.m.step.StepFailure('Loading config file failed. [%s]' % | 344 raise self.m.step.StepFailure('Loading config file failed. [%s]' % |
| 237 src_path) | 345 src_path) |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 | 619 |
| 512 def _prepend_src_to_path_in_command(test_cfg): | 620 def _prepend_src_to_path_in_command(test_cfg): |
| 513 command_to_run = [] | 621 command_to_run = [] |
| 514 for v in test_cfg.get('command').split(): | 622 for v in test_cfg.get('command').split(): |
| 515 if v in ['./tools/perf/run_benchmark', | 623 if v in ['./tools/perf/run_benchmark', |
| 516 'tools/perf/run_benchmark', | 624 'tools/perf/run_benchmark', |
| 517 'tools\\perf\\run_benchmark']: | 625 'tools\\perf\\run_benchmark']: |
| 518 v = 'src/tools/perf/run_benchmark' | 626 v = 'src/tools/perf/run_benchmark' |
| 519 command_to_run.append(v) | 627 command_to_run.append(v) |
| 520 test_cfg.update({'command': ' '.join(command_to_run)}) | 628 test_cfg.update({'command': ' '.join(command_to_run)}) |
| OLD | NEW |