| 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 import argparse | 5 import argparse |
| 6 import os | 6 import os |
| 7 import logging | 7 import logging |
| 8 import platform | 8 import platform |
| 9 import re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| 11 import urllib2 | 11 import urllib2 |
| 12 import json | 12 import json |
| 13 | 13 |
| 14 from core import path_util | 14 from core import path_util |
| 15 | 15 |
| 16 from telemetry import benchmark | 16 from telemetry import benchmark |
| 17 from telemetry.core import discover | 17 from telemetry.core import discover |
| 18 from telemetry.util import command_line | 18 from telemetry.util import command_line |
| 19 from telemetry.util import matching | 19 from telemetry.util import matching |
| 20 | 20 |
| 21 from core import path_util |
| 21 | 22 |
| 22 CHROMIUM_CONFIG_FILENAME = 'tools/run-perf-test.cfg' | 23 |
| 23 BLINK_CONFIG_FILENAME = 'Tools/run-perf-test.cfg' | 24 CHROMIUM_CONFIG_FILENAME = os.path.join(path_util.GetChromiumSrcDir(), 'tools', |
| 25 'run-perf-test.cfg') |
| 24 SUCCESS, NO_CHANGES, ERROR = range(3) | 26 SUCCESS, NO_CHANGES, ERROR = range(3) |
| 25 # Unsupported Perf bisect bots. | 27 # Unsupported Perf bisect bots. |
| 26 EXCLUDED_BOTS = { | 28 EXCLUDED_BOTS = { |
| 27 'win_xp_perf_bisect', # Goma issues: crbug.com/330900 | 29 'win_xp_perf_bisect', # Goma issues: crbug.com/330900 |
| 28 'win_perf_bisect_builder', | 30 'win_perf_bisect_builder', |
| 29 'win64_nv_tester', | 31 'win64_nv_tester', |
| 30 'winx64_bisect_builder', | 32 'winx64_bisect_builder', |
| 31 'linux_perf_bisect_builder', | 33 'linux_perf_bisect_builder', |
| 32 'mac_perf_bisect_builder', | 34 'mac_perf_bisect_builder', |
| 33 'android_perf_bisect_builder', | 35 'android_perf_bisect_builder', |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 """ | 220 """ |
| 219 if extra_args is None: | 221 if extra_args is None: |
| 220 extra_args = [] | 222 extra_args = [] |
| 221 self._InitializeBuilderNames(options.trybot) | 223 self._InitializeBuilderNames(options.trybot) |
| 222 | 224 |
| 223 arguments = [options.benchmark_name] + extra_args | 225 arguments = [options.benchmark_name] + extra_args |
| 224 | 226 |
| 225 # First check if there are chromium changes to upload. | 227 # First check if there are chromium changes to upload. |
| 226 status = self._AttemptTryjob(CHROMIUM_CONFIG_FILENAME, arguments) | 228 status = self._AttemptTryjob(CHROMIUM_CONFIG_FILENAME, arguments) |
| 227 if status not in [SUCCESS, ERROR]: | 229 if status not in [SUCCESS, ERROR]: |
| 228 # If we got here, there are no chromium changes to upload. Try blink. | |
| 229 os.chdir('third_party/WebKit/') | |
| 230 status = self._AttemptTryjob(BLINK_CONFIG_FILENAME, arguments) | |
| 231 os.chdir('../..') | |
| 232 if status not in [SUCCESS, ERROR]: | 230 if status not in [SUCCESS, ERROR]: |
| 233 logging.error('No local changes found in chromium or blink trees. ' | 231 logging.error('No local changes found in chromium or blink trees. ' |
| 234 'browser=%s argument sends local changes to the ' | 232 'browser=%s argument sends local changes to the ' |
| 235 'perf trybot(s): %s.', options.trybot, | 233 'perf trybot(s): %s.', options.trybot, |
| 236 self._builder_names.values()) | 234 self._builder_names.values()) |
| 237 return 1 | 235 return 1 |
| 238 return 0 | 236 return 0 |
| 239 | 237 |
| 240 def _UpdateConfigAndRunTryjob(self, bot_platform, cfg_file_path, arguments): | 238 def _UpdateConfigAndRunTryjob(self, bot_platform, cfg_file_path, arguments): |
| 241 """Updates perf config file, uploads changes and excutes perf try job. | 239 """Updates perf config file, uploads changes and excutes perf try job. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 254 """ | 252 """ |
| 255 config = self._GetPerfConfig(bot_platform, arguments) | 253 config = self._GetPerfConfig(bot_platform, arguments) |
| 256 config_to_write = 'config = %s' % json.dumps( | 254 config_to_write = 'config = %s' % json.dumps( |
| 257 config, sort_keys=True, indent=2, separators=(',', ': ')) | 255 config, sort_keys=True, indent=2, separators=(',', ': ')) |
| 258 | 256 |
| 259 try: | 257 try: |
| 260 with open(cfg_file_path, 'r') as config_file: | 258 with open(cfg_file_path, 'r') as config_file: |
| 261 if config_to_write == config_file.read(): | 259 if config_to_write == config_file.read(): |
| 262 return NO_CHANGES, '' | 260 return NO_CHANGES, '' |
| 263 except IOError: | 261 except IOError: |
| 264 msg = 'Cannot find %s. Please run from src dir.' % cfg_file_path | 262 msg = 'Cannot find %s.' % cfg_file_path |
| 265 return (ERROR, msg) | 263 return (ERROR, msg) |
| 266 | 264 |
| 267 with open(cfg_file_path, 'w') as config_file: | 265 with open(cfg_file_path, 'w') as config_file: |
| 268 config_file.write(config_to_write) | 266 config_file.write(config_to_write) |
| 269 # Commit the config changes locally. | 267 # Commit the config changes locally. |
| 270 returncode, out, err = _RunProcess( | 268 returncode, out, err = _RunProcess( |
| 271 [_GIT_CMD, 'commit', '-a', '-m', 'bisect config: %s' % bot_platform]) | 269 [_GIT_CMD, 'commit', '-a', '-m', 'bisect config: %s' % bot_platform]) |
| 272 if returncode: | 270 if returncode: |
| 273 raise TrybotError('Could not commit bisect config change for %s,' | 271 raise TrybotError('Could not commit bisect config change for %s,' |
| 274 ' error %s' % (bot_platform, err)) | 272 ' error %s' % (bot_platform, err)) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 This is run once for chromium, and if it returns NO_CHANGES, once for blink. | 348 This is run once for chromium, and if it returns NO_CHANGES, once for blink. |
| 351 | 349 |
| 352 Args: | 350 Args: |
| 353 cfg_file_path: Path to the config file for the try job. | 351 cfg_file_path: Path to the config file for the try job. |
| 354 | 352 |
| 355 Returns: | 353 Returns: |
| 356 Returns SUCCESS if a tryjob was sent, NO_CHANGES if there was nothing to | 354 Returns SUCCESS if a tryjob was sent, NO_CHANGES if there was nothing to |
| 357 try, ERROR if a tryjob was attempted but an error encountered. | 355 try, ERROR if a tryjob was attempted but an error encountered. |
| 358 """ | 356 """ |
| 359 source_repo = 'chromium' | 357 source_repo = 'chromium' |
| 360 if cfg_file_path == BLINK_CONFIG_FILENAME: | |
| 361 source_repo = 'blink' | |
| 362 | 358 |
| 363 # TODO(prasadv): This method is quite long, we should consider refactor | 359 # TODO(prasadv): This method is quite long, we should consider refactor |
| 364 # this by extracting to helper methods. | 360 # this by extracting to helper methods. |
| 365 returncode, original_branchname, err = _RunProcess( | 361 returncode, original_branchname, err = _RunProcess( |
| 366 [_GIT_CMD, 'rev-parse', '--abbrev-ref', 'HEAD']) | 362 [_GIT_CMD, 'rev-parse', '--abbrev-ref', 'HEAD']) |
| 367 if returncode: | 363 if returncode: |
| 368 msg = 'Must be in a git repository to send changes to trybots.' | 364 msg = 'Must be in a git repository to send changes to trybots.' |
| 369 if err: | 365 if err: |
| 370 msg += '\nGit error: %s' % err | 366 msg += '\nGit error: %s' % err |
| 371 logging.error(msg) | 367 logging.error(msg) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 return ERROR # pylint: disable=lost-exception | 430 return ERROR # pylint: disable=lost-exception |
| 435 logging.info('Checked out original branch: %s', original_branchname) | 431 logging.info('Checked out original branch: %s', original_branchname) |
| 436 returncode, out, err = _RunProcess( | 432 returncode, out, err = _RunProcess( |
| 437 [_GIT_CMD, 'branch', '-D', 'telemetry-tryjob']) | 433 [_GIT_CMD, 'branch', '-D', 'telemetry-tryjob']) |
| 438 if returncode: | 434 if returncode: |
| 439 logging.error('Could not delete telemetry-tryjob branch. ' | 435 logging.error('Could not delete telemetry-tryjob branch. ' |
| 440 'Please delete it manually: %s', err) | 436 'Please delete it manually: %s', err) |
| 441 return ERROR # pylint: disable=lost-exception | 437 return ERROR # pylint: disable=lost-exception |
| 442 logging.info('Deleted temp branch: telemetry-tryjob') | 438 logging.info('Deleted temp branch: telemetry-tryjob') |
| 443 return SUCCESS | 439 return SUCCESS |
| OLD | NEW |