示例#1
0
def _PerformLegacyBisect(bisect_job):
  config_dict = bisect_job.GetConfigDict()
  config = bisect_job.config
  bot = bisect_job.bot
  email = bisect_job.email
  bug_id = bisect_job.bug_id

  # We need to rewrite the metric name for legacy bisect.
  config_dict['metric'] = _RewriteMetricName(config_dict['metric'])
  bisect_job.config = utils.BisectConfigPythonString(config_dict)

  # Get the base config file contents and make a patch.
  base_config = utils.DownloadChromiumFile(_BISECT_CONFIG_PATH)
  if not base_config:
    return {'error': 'Error downloading base config'}
  patch, base_checksum, base_hashes = _CreatePatch(
      base_config, config, _BISECT_CONFIG_PATH)

  # Check if bisect is for internal only tests.
  bisect_internal = _IsBisectInternalOnly(bisect_job)

  # Upload the patch to Rietveld.
  server = rietveld_service.RietveldService(bisect_internal)

  subject = 'Perf bisect for bug %s on behalf of %s' % (bug_id, email)
  issue_id, patchset_id = server.UploadPatch(subject,
                                             patch,
                                             base_checksum,
                                             base_hashes,
                                             base_config,
                                             _BISECT_CONFIG_PATH)

  if not issue_id:
    return {'error': 'Error uploading patch to rietveld_service.'}

  if bisect_internal:
    # Internal server URL has '/bots', that cannot be accessed via browser,
    # therefore strip this path from internal server URL.
    issue_url = '%s/%s' % (server.Config().internal_server_url.strip('/bots'),
                           issue_id)
  else:
    issue_url = '%s/%s' % (server.Config().server_url.strip('/bots'), issue_id)

  # Tell Rietveld to try the patch.
  master = _GetTryServerMaster(bisect_job)
  trypatch_success = server.TryPatch(master, issue_id, patchset_id, bot)
  if trypatch_success:
    # Create TryJob entity.  update_bug_with_results and auto_bisect
    # cron job will be tracking/starting/restarting bisect.
    if bug_id and bug_id > 0:
      bisect_job.rietveld_issue_id = int(issue_id)
      bisect_job.rietveld_patchset_id = int(patchset_id)
      bisect_job.SetStarted()
      bug_comment = ('Bisect started; track progress at '
                     '<a href="%s">%s</a>' % (issue_url, issue_url))
      LogBisectResult(bug_id, bug_comment)
    return {'issue_id': issue_id, 'issue_url': issue_url}

  return {'error': 'Error starting try job. Try to fix at %s' % issue_url}
示例#2
0
def _PerformPerfTryJob(perf_job):
  """Performs the perf try job on the try bot.

  This creates a patch, uploads it, then tells Rietveld to try the patch.

  Args:
    perf_job: TryJob entity with initialized bot name and config.

  Returns:
    A dictionary containing the result; if successful, this dictionary contains
    the field "issue_id", otherwise it contains "error".
  """
  assert perf_job.bot and perf_job.config

  if not perf_job.key:
    perf_job.put()

  bot = perf_job.bot
  email = perf_job.email

  config_dict = perf_job.GetConfigDict()
  config_dict['try_job_id'] = perf_job.key.id()
  perf_job.config = utils.BisectConfigPythonString(config_dict)

  # Get the base config file contents and make a patch.
  base_config = utils.DownloadChromiumFile(_PERF_CONFIG_PATH)
  if not base_config:
    return {'error': 'Error downloading base config'}
  patch, base_checksum, base_hashes = _CreatePatch(
      base_config, perf_job.config, _PERF_CONFIG_PATH)

  # Upload the patch to Rietveld.
  server = rietveld_service.RietveldService()
  subject = 'Perf Try Job on behalf of %s' % email
  issue_id, patchset_id = server.UploadPatch(subject,
                                             patch,
                                             base_checksum,
                                             base_hashes,
                                             base_config,
                                             _PERF_CONFIG_PATH)

  if not issue_id:
    return {'error': 'Error uploading patch to rietveld_service.'}
  url = 'https://codereview.chromium.org/%s/' % issue_id

  # Tell Rietveld to try the patch.
  master = 'tryserver.chromium.perf'
  trypatch_success = server.TryPatch(master, issue_id, patchset_id, bot)
  if trypatch_success:
    # Create TryJob entity. The update_bug_with_results and auto_bisect
    # cron jobs will be tracking, or restarting the job.
    perf_job.rietveld_issue_id = int(issue_id)
    perf_job.rietveld_patchset_id = int(patchset_id)
    perf_job.SetStarted()
    return {'issue_id': issue_id}
  return {'error': 'Error starting try job. Try to fix at %s' % url}
示例#3
0
 def testDownloadChromiumFile_Non200Status(self, mock_logging_error):
     self.assertIsNone(utils.DownloadChromiumFile('some/file'))
     self.assertEqual(1, mock_logging_error.call_count)
示例#4
0
 def testDownloadChromiumFile_BasicCase(self):
     self.assertEqual(json.dumps({'key': 'this is well-formed JSON.'}),
                      utils.DownloadChromiumFile('some/file'))
示例#5
0
def PerformBisect(bisect_job):
  """Starts the bisect job.

  This creates a patch, uploads it, then tells Rietveld to try the patch.

  TODO(qyearsley): If we want to use other tryservers sometimes in the future,
  then we need to have some way to decide which one to use. This could
  perhaps be passed as part of the bisect bot name, or guessed from the bisect
  bot name.

  Args:
    bisect_job: A TryJob entity.

  Returns:
    A dictionary containing the result; if successful, this dictionary contains
    the field "issue_id" and "issue_url", otherwise it contains "error".
  """
  assert bisect_job.bot and bisect_job.config
  config_dict = bisect_job.GetConfigDict()

  if bisect_job.use_buildbucket:
    if 'recipe_tester_name' not in config_dict:
      logging.error('"recipe_tester_name" required in bisect jobs '
                    'that use buildbucket. Config: %s', config_dict)
      return {'error': 'No "recipe_tester_name" given.'}
    return PerformBuildbucketBisect(bisect_job)

  config = bisect_job.config
  bot = bisect_job.bot
  email = bisect_job.email
  bug_id = bisect_job.bug_id

  # We need to rewrite the metric name for legacy bisect.
  config_dict['metric'] = _RewriteMetricName(config_dict['metric'])
  bisect_job.config = utils.BisectConfigPythonString(config_dict)

  # Get the base config file contents and make a patch.
  base_config = utils.DownloadChromiumFile(_BISECT_CONFIG_PATH)
  if not base_config:
    return {'error': 'Error downloading base config'}
  patch, base_checksum, base_hashes = _CreatePatch(
      base_config, config, _BISECT_CONFIG_PATH)

  # Check if bisect is for internal only tests.
  bisect_internal = _IsBisectInternalOnly(bisect_job)

  # Upload the patch to Rietveld.
  server = rietveld_service.RietveldService(bisect_internal)

  subject = 'Perf bisect for bug %s on behalf of %s' % (bug_id, email)
  issue_id, patchset_id = server.UploadPatch(subject,
                                             patch,
                                             base_checksum,
                                             base_hashes,
                                             base_config,
                                             _BISECT_CONFIG_PATH)

  if not issue_id:
    return {'error': 'Error uploading patch to rietveld_service.'}

  if bisect_internal:
    # Internal server URL has '/bots', that cannot be accessed via browser,
    # therefore strip this path from internal server URL.
    issue_url = '%s/%s' % (server.Config().internal_server_url.strip('/bots'),
                           issue_id)
  else:
    issue_url = '%s/%s' % (server.Config().server_url.strip('/bots'), issue_id)

  # Tell Rietveld to try the patch.
  master = _GetTryServerMaster(bisect_job)
  trypatch_success = server.TryPatch(master, issue_id, patchset_id, bot)
  if trypatch_success:
    # Create TryJob entity.  update_bug_with_results and auto_bisect
    # cron job will be tracking/starting/restarting bisect.
    if bug_id and bug_id > 0:
      bisect_job.rietveld_issue_id = int(issue_id)
      bisect_job.rietveld_patchset_id = int(patchset_id)
      bisect_job.SetStarted()
      bug_comment = ('Bisect started; track progress at '
                     '<a href="%s">%s</a>' % (issue_url, issue_url))
      LogBisectResult(bug_id, bug_comment)
    return {'issue_id': issue_id, 'issue_url': issue_url}
  return {'error': 'Error starting try job. Try to fix at %s' % issue_url}