Exemplo n.º 1
0
def _PerformBuildbucketBisect(bisect_job):
    config_dict = bisect_job.GetConfigDict()
    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.'}

    bucket = _GetTryServerBucket(bisect_job)
    try:
        bisect_job.buildbucket_job_id = buildbucket_service.PutJob(
            _MakeBuildbucketBisectJob(bisect_job), bucket)
        bisect_job.SetStarted()
        hostname = app_identity.get_default_version_hostname()
        job_id = bisect_job.buildbucket_job_id
        issue_url = 'https://%s/buildbucket_job_status/%s' % (hostname, job_id)
        bug_comment = ('Bisect started; track progress at '
                       '<a href="%s">%s</a>' % (issue_url, issue_url))
        LogBisectResult(bisect_job, bug_comment)
        return {
            'issue_id': job_id,
            'issue_url': issue_url,
        }
    except httplib2.HttpLib2Error as e:
        return {
            'error':
            ('Could not start job because of the following exception: ' +
             e.message),
        }
Exemplo n.º 2
0
    def testPutJob(self):
        fake_job = BuildbucketServiceTest.FakeJob()
        with mock.patch('apiclient.discovery.build',
                        mock.MagicMock(return_value=self.fake_service)):
            fake_id = buildbucket_service.PutJob(fake_job)

        # Ensure the request was composed
        request = self.fake_service.bodies[0]
        self.assertEqual('master.tryserver.chromium.perf', request['bucket'])
        parameters_json = request['parameters_json']
        parameters = json.loads(parameters_json)
        self.assertIsInstance(parameters, dict)
        self.assertIn('bisect_config', parameters['properties'])

        # Ensure the result is exactly what we plugged in.
        self.assertEqual(fake_id, 'fake_id')
Exemplo n.º 3
0
def PerformBuildbucketBisect(bisect_job):
    try:
        bisect_job.buildbucket_job_id = buildbucket_service.PutJob(
            _MakeBuildbucketBisectJob(bisect_job))
        bisect_job.SetStarted()
        return {
            'issue_id':
            bisect_job.buildbucket_job_id,
            'issue_url':
            '/buildbucket_job_status/' + bisect_job.buildbucket_job_id,
        }
    except httplib2.HttpLib2Error as e:
        return {
            'error':
            ('Could not start job because of the following exception: ' +
             e.message),
        }
Exemplo n.º 4
0
def PerformBuildbucketBisect(bisect_job):
  try:
    bisect_job.buildbucket_job_id = buildbucket_service.PutJob(
        _MakeBuildbucketBisectJob(bisect_job))
    bisect_job.SetStarted()
    hostname = app_identity.get_default_version_hostname()
    job_id = bisect_job.buildbucket_job_id
    issue_url = 'https://%s/buildbucket_job_status/%s' % (hostname, job_id)
    bug_comment = ('Bisect started; track progress at '
                   '<a href="%s">%s</a>' % (issue_url, issue_url))
    LogBisectResult(bisect_job.bug_id, bug_comment)
    return {
        'issue_id': job_id,
        'issue_url': issue_url,
    }
  except httplib2.HttpLib2Error as e:
    return {
        'error': ('Could not start job because of the following exception: ' +
                  e.message),
    }
Exemplo n.º 5
0
    def post(self):
        if not utils.IsInternalUser():
            self.response.out.write(
                json.dumps({
                    'error':
                    'You are not authorized to post to this endpoint.',
                }))
            return
        job = buildbucket_job.BisectJob(self.request.get('platform'),
                                        self.request.get('good_revision'),
                                        self.request.get('bad_revision'),
                                        self.request.get('command'),
                                        self.request.get('metric'),
                                        self.request.get('repeat_count'),
                                        self.request.get('truncate_percent'),
                                        self.request.get('max_time_minutes'),
                                        self.request.get('bug_id'),
                                        self.request.get('gs_bucket'),
                                        self.request.get('builder_host'),
                                        self.request.get('builder_port'))

        buildbucket_service.PutJob(job)
        self.response.out.write(job.response_fields)