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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 overall_success = all(v == 0 for v in retcodes) | 211 overall_success = all(v == 0 for v in retcodes) |
| 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.""" |
| 221 with_patch = kwargs.get('name') == 'With Patch' | |
| 219 update_step = self._checkout_revision(update_step, bot_db, revision) | 222 update_step = self._checkout_revision(update_step, bot_db, revision) |
| 220 self._compile(kwargs['name'], self.m.properties['mastername'], | 223 revision = build_state.BuildState(self, revision, with_patch) |
| 221 self.m.properties['buildername'], update_step, bot_db) | 224 self._request_build(revision, with_patch) |
| 222 | 225 self._wait_for(revision) |
|
prasadv
2016/06/22 21:56:23
Here we should capture if any error occurred while
Ziqi Xiong
2016/06/23 20:58:58
Done.
| |
| 226 self._download_build(update_step, bot_db, revision) | |
| 223 if self.m.chromium.c.TARGET_PLATFORM == 'android': | 227 if self.m.chromium.c.TARGET_PLATFORM == 'android': |
| 224 self.m.chromium_android.adb_install_apk('ChromePublic.apk') | 228 self.m.chromium_android.adb_install_apk('ChromePublic.apk') |
| 225 | 229 |
| 226 return self._run_test(cfg, **kwargs) | 230 return self._run_test(cfg, **kwargs) |
| 227 | 231 |
| 232 # Duplicate code from auto_bisect.revision_state._request_build | |
| 233 def _request_build(self, revision, with_patch): | |
| 234 if self.m.chromium.c.TARGET_PLATFORM == 'android': | |
| 235 self.m.chromium_android.clean_local_files() | |
| 236 else: | |
| 237 # Removes any chrome temporary files or build.dead directories. | |
| 238 self.m.chromium.cleanup_temp() | |
| 239 if with_patch: | |
| 240 properties = { | |
| 241 'parent_got_revision': revision.commit_hash, | |
| 242 'clobber': True, | |
| 243 'build_archive_url': revision.build_file_path, | |
| 244 'issue': self.m.properties['issue'], | |
| 245 'patch_storage': self.m.properties['patch_storage'], | |
| 246 'patchset': self.m.properties['patchset'], | |
| 247 'rietveld': self.m.properties['rietveld'] | |
|
prasadv
2016/06/22 21:56:23
rietveld url is missing.
Ziqi Xiong
2016/06/23 20:58:58
Done.
| |
| 248 } | |
| 249 else: | |
| 250 properties = { | |
|
prasadv
2016/06/22 21:56:23
Check the build archive before posting build reque
Ziqi Xiong
2016/06/23 20:58:58
Done.
| |
| 251 'parent_got_revision': revision.commit_hash, | |
| 252 'clobber': True, | |
| 253 'build_archive_url': revision.build_file_path, | |
| 254 } | |
| 255 bot_name = self.get_builder_bot_for_this_platform() | |
| 256 build_details = { | |
| 257 'bucket': 'master.' + self.m.properties['mastername'], | |
| 258 'parameters': { | |
| 259 'buildername': bot_name, | |
| 260 'properties': properties | |
| 261 }, | |
| 262 'client_operation_id': uuid.uuid4().hex, | |
| 263 'tags':{} | |
| 264 } | |
| 265 result = self.m.buildbucket.put( | |
| 266 [build_details], | |
| 267 self.m.service_account.get_json_path(SERVICE_ACCOUNT)) | |
| 268 revision.build_id = result.stdout['results'][0]['build']['id'] | |
| 269 | |
| 270 | |
| 271 def _wait_for(self, revision): | |
| 272 while True: | |
| 273 if revision.is_completed(): | |
| 274 break | |
| 275 else: | |
| 276 self.m.python.inline( | |
| 277 'sleeping', | |
| 278 """ | |
| 279 import sys | |
| 280 import time | |
| 281 time.sleep(20*60) | |
| 282 sys.exit(0) | |
| 283 """) | |
| 284 | |
| 285 # Duplicate code from auto_bisect.api.start_test_run_for_bisect | |
| 286 def _download_build(self, update_step, bot_db, | |
| 287 revision, run_locally=False, | |
| 288 skip_download=False): | |
| 289 if not revision.is_build_archived: | |
| 290 raise self.m.step.StepFailure('Build %s fails' % revision.build_id) | |
| 291 mastername = self.m.properties.get('mastername') | |
| 292 buildername = self.m.properties.get('buildername') | |
| 293 bot_config = bot_db.get_bot_config(mastername, buildername) | |
| 294 build_archive_url = revision.build_file_path | |
| 295 if not skip_download: | |
| 296 if self.m.chromium.c.TARGET_PLATFORM == 'android': | |
| 297 # The best way to ensure the old build directory is not used is to | |
| 298 # remove it. | |
| 299 build_dir = self.m.chromium.c.build_dir.join( | |
| 300 self.m.chromium.c.build_config_fs) | |
| 301 self.m.file.rmtree('build directory', build_dir) | |
| 302 | |
| 303 # The way android builders on tryserver.chromium.perf are archived is | |
| 304 # different from builders on chromium.perf. In order to support both | |
| 305 # forms of archives, we added this temporary hack until builders are | |
| 306 # fixed. See http://crbug.com/535218. | |
| 307 zip_dir = self.m.path.join(self.m.path['checkout'], 'full-build-linux') | |
| 308 if self.m.path.exists(zip_dir): # pragma: no cover | |
| 309 self.m.file.rmtree('full-build-linux directory', zip_dir) | |
| 310 gs_bucket = 'gs://%s/' % revision.bucket | |
| 311 archive_path = build_archive_url[len(gs_bucket):] | |
| 312 self.m.chromium_android.download_build( | |
| 313 bucket=bot_config['bucket'], | |
| 314 path=archive_path) | |
| 315 | |
| 316 # The way android builders on tryserver.chromium.perf are archived is | |
| 317 # different from builders on chromium.perf. In order to support both | |
| 318 # forms of archives, we added this temporary hack until builders are | |
| 319 # fixed. See http://crbug.com/535218. | |
| 320 if self.m.path.exists(zip_dir): # pragma: no cover | |
| 321 self.m.python.inline( | |
| 322 'moving full-build-linux to out/Release', | |
| 323 """ | |
| 324 import shutil | |
| 325 import sys | |
| 326 shutil.move(sys.argv[1], sys.argv[2]) | |
| 327 """, | |
| 328 args=[zip_dir, build_dir]) | |
| 329 else: | |
| 330 self.m.chromium_tests.download_and_unzip_build( | |
| 331 mastername, buildername, update_step, bot_db, | |
| 332 build_archive_url=build_archive_url, | |
| 333 build_revision=revision.commit_hash, | |
| 334 override_bot_type='tester') | |
| 335 | |
| 336 # Duplicate code from auto_bisect.bisector.get_builder_bot_for_this_platform | |
| 337 def get_builder_bot_for_this_platform(self): | |
| 338 bot_name = self.m.properties.get('buildername', '') | |
| 339 if 'win' in bot_name: | |
| 340 if any(b in bot_name for b in ['x64', 'gpu']): | |
| 341 return 'winx64_bisect_builder' | |
| 342 return 'win_perf_bisect_builder' | |
| 343 | |
| 344 if 'android' in bot_name: | |
| 345 if 'nexus9' in bot_name: | |
| 346 return 'android_arm64_perf_bisect_builder' | |
| 347 return 'android_perf_bisect_builder' | |
| 348 | |
| 349 if 'mac' in bot_name: | |
| 350 return 'mac_perf_bisect_builder' | |
| 351 | |
| 352 return 'linux_perf_bisect_builder' | |
| 353 | |
| 228 def _load_config_file(self, name, src_path, **kwargs): | 354 def _load_config_file(self, name, src_path, **kwargs): |
| 229 """Attempts to load the specified config file and grab config dict.""" | 355 """Attempts to load the specified config file and grab config dict.""" |
| 230 step_result = self.m.python( | 356 step_result = self.m.python( |
| 231 name, | 357 name, |
| 232 self.resource('load_config_to_json.py'), | 358 self.resource('load_config_to_json.py'), |
| 233 ['--source', src_path, '--output_json', self.m.json.output()], | 359 ['--source', src_path, '--output_json', self.m.json.output()], |
| 234 **kwargs) | 360 **kwargs) |
| 235 if not step_result.json.output: # pragma: no cover | 361 if not step_result.json.output: # pragma: no cover |
| 236 raise self.m.step.StepFailure('Loading config file failed. [%s]' % | 362 raise self.m.step.StepFailure('Loading config file failed. [%s]' % |
| 237 src_path) | 363 src_path) |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 | 637 |
| 512 def _prepend_src_to_path_in_command(test_cfg): | 638 def _prepend_src_to_path_in_command(test_cfg): |
| 513 command_to_run = [] | 639 command_to_run = [] |
| 514 for v in test_cfg.get('command').split(): | 640 for v in test_cfg.get('command').split(): |
| 515 if v in ['./tools/perf/run_benchmark', | 641 if v in ['./tools/perf/run_benchmark', |
| 516 'tools/perf/run_benchmark', | 642 'tools/perf/run_benchmark', |
| 517 'tools\\perf\\run_benchmark']: | 643 'tools\\perf\\run_benchmark']: |
| 518 v = 'src/tools/perf/run_benchmark' | 644 v = 'src/tools/perf/run_benchmark' |
| 519 command_to_run.append(v) | 645 command_to_run.append(v) |
| 520 test_cfg.update({'command': ' '.join(command_to_run)}) | 646 test_cfg.update({'command': ' '.join(command_to_run)}) |
| OLD | NEW |