| Index: tools/perf/core/trybot_command.py
|
| diff --git a/tools/perf/core/trybot_command.py b/tools/perf/core/trybot_command.py
|
| index a53a5a357f5ee7e5da1f9feaa5dfa079ba031215..1b170ca2763237de8f2b6887eafbd2193b721d41 100644
|
| --- a/tools/perf/core/trybot_command.py
|
| +++ b/tools/perf/core/trybot_command.py
|
| @@ -63,6 +63,25 @@ DEFAULT_TRYBOTS = [
|
| ]
|
|
|
| CHROMIUM_SRC_PATH = path_util.GetChromiumSrcDir()
|
| +# Mapping of repo to its root path and git remote URL.
|
| +REPO_INFO_MAP = {
|
| + 'src': {
|
| + 'src': 'src',
|
| + 'url': 'https://chromium.googlesource.com/chromium/src.git',
|
| + },
|
| + 'v8': {
|
| + 'src': 'src/v8',
|
| + 'url': 'https://chromium.googlesource.com/v8/v8.git',
|
| + },
|
| + 'skia': {
|
| + 'src': 'src/third_party/skia',
|
| + 'url': 'https://chromium.googlesource.com/skia.git',
|
| + },
|
| + 'angle': {
|
| + 'src': 'src/third_party/angle',
|
| + 'url': 'https://chromium.googlesource.com/angle/angle.git',
|
| + }
|
| +}
|
|
|
| assert not set(DEFAULT_TRYBOTS) & set(EXCLUDED_BOTS), (
|
| 'A trybot cannot present in both Default as well as Excluded bots lists.')
|
| @@ -159,7 +178,6 @@ def RunGit(cmd, msg_on_error='', ignore_return_code=False):
|
|
|
| return output
|
|
|
| -
|
| class Trybot(command_line.ArgParseCommand):
|
| """Run telemetry perf benchmark on trybot."""
|
|
|
| @@ -292,6 +310,14 @@ class Trybot(command_line.ArgParseCommand):
|
| help=('specify which benchmark to run. To see all available benchmarks,'
|
| ' run `run_benchmark list`'),
|
| metavar='<benchmark name>')
|
| + parser.add_argument(
|
| + '--repo_path', type=str, default=CHROMIUM_SRC_PATH,
|
| + help='specify which repo path to use for perf try job\n',
|
| + metavar='<repo path>')
|
| + parser.add_argument(
|
| + '--deps_revision', type=str, default=None,
|
| + help='specify DEPS revision to be used by Chromium.\n',
|
| + metavar='<deps revision>')
|
|
|
| def Run(self, options, extra_args=None):
|
| """Sends a tryjob to a perf trybot.
|
| @@ -303,11 +329,23 @@ class Trybot(command_line.ArgParseCommand):
|
| if extra_args is None:
|
| extra_args = []
|
| self._InitializeBuilderNames(options.trybot)
|
| +
|
| + original_workdir = os.getcwd()
|
| + repo_path = os.path.abspath(options.repo_path)
|
| try:
|
| - self._AttemptTryjob(CHROMIUM_SRC_PATH, options, extra_args)
|
| + # Check the existence of repo path.
|
| + if not os.path.exists(repo_path):
|
| + raise TrybotError('Repository path "%s" does not exists, please check '
|
| + 'the value of <repo_path> argument.' % repo_path)
|
| + # Change to the repo directory.
|
| + os.chdir(repo_path)
|
| + self._AttemptTryjob(repo_path, options, extra_args)
|
| except TrybotError, error:
|
| print error
|
| return 1
|
| + finally:
|
| + # Restore to original working directory.
|
| + os.chdir(original_workdir)
|
| return 0
|
|
|
| def _GetPerfConfig(self, bot_platform, arguments):
|
| @@ -403,6 +441,49 @@ class Trybot(command_line.ArgParseCommand):
|
|
|
| return (repo_name, branch_name)
|
|
|
| + def _GetBaseGitHashForRepo(self, branch_name, git_url):
|
| + """Gets the base revision for the repo on which local changes are made.
|
| +
|
| + Finds the upstream of the current branch that it is set to and gets
|
| + the HEAD revision from upstream. This also checks if the remote URL on
|
| + the upstream is supported by Perf Try job.
|
| +
|
| + Args:
|
| + branch_name: Current working branch name.
|
| + git_url: Remote URL of the repo.
|
| +
|
| + Returns:
|
| + Git hash of the HEAD revision from the upstream branch.
|
| +
|
| + Raises:
|
| + TrybotError: This exception is raised when a GIT command fails or if the
|
| + remote URL of the repo found is not supported.
|
| + """
|
| + while not self._IsRepoSupported(branch_name, git_url):
|
| + branch_name = RunGit(
|
| + ['rev-parse', '--abbrev-ref', '%s@{upstream}' % branch_name],
|
| + 'Failed to get upstream branch name.')
|
| +
|
| + return RunGit(
|
| + ['rev-parse', '%s@{upstream}' % branch_name],
|
| + 'Failed to get base revision hash on upstream.')
|
| +
|
| + def _IsRepoSupported(self, current_branch, repo_git_url):
|
| + cur_remote = RunGit(
|
| + ['config', 'branch.%s.remote'% current_branch],
|
| + 'Failed to get branch.%s.remote from git config' % current_branch)
|
| + cur_remote = cur_remote.strip()
|
| + import pdb; pdb.set_trace()
|
| + if cur_remote == '.':
|
| + return False
|
| + cur_remote_url = RunGit(
|
| + ['config', 'remote.%s.url' % cur_remote],
|
| + 'Failed to get remote.%s.url from git config' % cur_remote)
|
| + if cur_remote_url.lower() == repo_git_url:
|
| + return True
|
| + raise TrybotError('URL %s on remote %s is not recognized on branch.'% (
|
| + cur_remote_url, cur_remote))
|
| +
|
| def _AttemptTryjob(self, repo_path, options, extra_args):
|
| """Attempts to run a tryjob from a repo directory.
|
|
|
| @@ -413,6 +494,17 @@ class Trybot(command_line.ArgParseCommand):
|
| """
|
| repo_name, branch_name = self._GetRepoAndBranchName(repo_path)
|
|
|
| + repo_info = REPO_INFO_MAP.get(repo_name, None)
|
| + if not repo_info:
|
| + raise TrybotError('Unsupported repository %s' % repo_name)
|
| +
|
| + deps_override = None
|
| + if repo_name != 'src':
|
| + if not options.deps_revision:
|
| + options.deps_revision = self._GetBaseGitHashForRepo(
|
| + branch_name, repo_info.get('url'))
|
| + deps_override = {repo_info.get('src'): options.deps_revision}
|
| +
|
| arguments = [options.benchmark_name] + extra_args
|
|
|
| rietveld_url = self._UploadPatchToRietveld(repo_name, options)
|
| @@ -425,7 +517,7 @@ class Trybot(command_line.ArgParseCommand):
|
| logging.warning('No builder is found for %s', bot_platform)
|
| continue
|
| try:
|
| - self._RunTryJob(bot_platform, arguments)
|
| + self._RunTryJob(bot_platform, arguments, deps_override)
|
| except TrybotError, err:
|
| print err
|
|
|
| @@ -443,12 +535,13 @@ class Trybot(command_line.ArgParseCommand):
|
| (repo_name, output))
|
| return match.group(0)
|
|
|
| - def _RunTryJob(self, bot_platform, arguments):
|
| + def _RunTryJob(self, bot_platform, arguments, deps_override):
|
| """Executes perf try job with benchmark test properties.
|
|
|
| Args:
|
| bot_platform: Name of the platform to be generated.
|
| arguments: Command line arguments.
|
| + deps_override: DEPS revision if needs to be overridden.
|
|
|
| Raises:
|
| TrybotError: When trybot fails to upload CL or run git try.
|
| @@ -461,6 +554,10 @@ class Trybot(command_line.ArgParseCommand):
|
| # Add Perf Test config to git try --properties arg.
|
| git_try_command.extend(['-p', 'perf_try_config=%s' % json.dumps(config)])
|
|
|
| + # Add deps overrides to git try --properties arg.
|
| + if deps_override:
|
| + git_try_command.extend([
|
| + '-p', 'deps_revision_overrides=%s' % json.dumps(deps_override)])
|
| for bot in self._builder_names[bot_platform]:
|
| git_try_command.extend(['-b', bot])
|
|
|
|
|