Exemple #1
0
def OnTryJobCompleted(params, try_job_data, build, error):
    try_job_id = params['try_job_id']
    try_job_type = params['try_job_type']

    # We want to retry 404s due to logdog's propagation delay (inherent to
    # pubsub) of up to 3 minutes.
    http_client = FinditHttpClient(interceptor=HttpClientMetricsInterceptor(
        no_retry_codes=[200, 302, 401, 403, 409, 501]))

    try:
        report = step_util.GetStepLogForLuciBuild(try_job_id, 'report',
                                                  http_client, 'report')
        if report:
            _RecordCacheStats(build, report)
    except (ValueError, TypeError) as e:
        report = {}
        logging.exception('Failed to load result report for tryjob/%s '
                          'due to exception %s.' % (try_job_id, e.message))

    error_dict, error_code = _GetError(buildbucket_build=build,
                                       buildbucket_error=error,
                                       timed_out=False,
                                       no_report=report == {})
    UpdateTryJobMetadata(try_job_data,
                         try_job_type,
                         buildbucket_build=build,
                         error_dict=error_dict,
                         error_code=error_code,
                         report=report or {})
    result_to_update = _UpdateTryJobEntity(params['urlsafe_try_job_key'],
                                           try_job_type, try_job_id, build.url,
                                           BuildbucketBuild.COMPLETED, report)
    return (result_to_update[-1],
            analysis_status.ERROR if error_dict else analysis_status.COMPLETED)
Exemple #2
0
 def testGetStepLogForLuciBuild(self, mock_get_build, mock_get_log, _):
   build_id = '8945610992972640896'
   mock_log = Step.Log()
   mock_log.name = 'step_metadata'
   mock_log.view_url = 'view_url'
   mock_step = Step()
   mock_step.name = 's'
   mock_step.logs.extend([mock_log])
   mock_build = Build()
   mock_build.id = int(build_id)
   mock_build.steps.extend([mock_step])
   mock_get_build.return_value = mock_build
   self.assertEqual(
       'log',
       step_util.GetStepLogForLuciBuild(build_id, 's', None, 'step_metadata'))
   mock_get_log.assert_called_once_with('view_url', None)
Exemple #3
0
 def testGetStepLogForLuciBuildNoViewUrl(self, mock_get_build, mock_get_log,
                                         _):
   build_id = '8945610992972640896'
   mock_log = Step.Log()
   mock_log.name = 'step_metadata'
   mock_log.view_url = 'view_url'
   mock_step = Step()
   mock_step.name = 's'
   mock_step.logs.extend([mock_log])
   mock_build = Build()
   mock_build.id = int(build_id)
   mock_build.steps.extend([mock_step])
   mock_get_build.return_value = mock_build
   self.assertIsNone(
       step_util.GetStepLogForLuciBuild(build_id, 's', None, 'step_metadata'))
   self.assertFalse(mock_get_log.called)
Exemple #4
0
 def testGetStepLogForLuciBuildPartialMatch(self, mock_log_from_build, _):
     step_util.GetStepLogForLuciBuild('87654321', 's', None)
     self.assertIn(False, mock_log_from_build.call_args[0])
     step_util.GetStepLogForLuciBuild('87654321', 's', None, True)
     self.assertIn(True, mock_log_from_build.call_args[0])
Exemple #5
0
 def testGetStepLogForLuciBuildError(self, _):
     self.assertIsNone(
         step_util.GetStepLogForLuciBuild('87654321', 's', None))