def RecordTestFailureAnalysisStateChange(master_name, builder_name, status,
                                         analysis_type):
  """Records state changes for test failure analysis."""
  monitoring.OnWaterfallAnalysisStateChange(
      master_name=master_name,
      builder_name=builder_name,
      failure_type=failure_type.GetDescriptionForFailureType(failure_type.TEST),
      canonical_step_name='Unknown',
      isolate_target_name='Unknown',
      status=analysis_status.STATUS_TO_DESCRIPTION[status],
      analysis_type=analysis_approach_type.STATUS_TO_DESCRIPTION[analysis_type])
Ejemplo n.º 2
0
def RecordCompileFailureAnalysisStateChange(master_name, builder_name, status,
                                            analysis_type):
  """Records state changes for compile failure anlaysis."""
  monitoring.OnWaterfallAnalysisStateChange(
      master_name=master_name,
      builder_name=builder_name,
      failure_type=failure_type.GetDescriptionForFailureType(
          failure_type.COMPILE),
      canonical_step_name='compile',
      isolate_target_name='N/A',
      status=analysis_status.STATUS_TO_DESCRIPTION[status],
      analysis_type=analysis_approach_type.STATUS_TO_DESCRIPTION[analysis_type])
Ejemplo n.º 3
0
 def testOnWaterfallAnalysisStateChange(self, mock_common_monitoring):
     monitoring.OnWaterfallAnalysisStateChange('m', 'b', 'compile',
                                               'compile', 'N/A',
                                               'Completed', 'Heuristic')
     parameters = {
         'master_name': 'm',
         'builder_name': 'b',
         'failure_type': 'compile',
         'canonical_step_name': 'compile',
         'isolate_target_name': 'N/A',
         'status': 'Completed',
         'analysis_type': 'Heuristic',
     }
     mock_common_monitoring.assert_called_once_with(parameters)
Ejemplo n.º 4
0
def _RecordSwarmingTaskStateChange(master_name, builder_name, build_number,
                                   step_name, status, analysis_type):
    """Records state changes for swarming tasks."""
    step_metadata = {}
    if step_name:
        step_metadata = step_util.LegacyGetStepMetadata(
            master_name, builder_name, build_number, step_name) or {}

    monitoring.OnWaterfallAnalysisStateChange(
        master_name=master_name,
        builder_name=builder_name,
        failure_type=failure_type.GetDescriptionForFailureType(
            failure_type.TEST),
        canonical_step_name=step_metadata.get('canonical_step_name')
        or 'Unknown',
        isolate_target_name=step_metadata.get('isolate_target_name')
        or 'Unknown',
        status=analysis_status.STATUS_TO_DESCRIPTION[status],
        analysis_type=analysis_approach_type.
        STATUS_TO_DESCRIPTION[analysis_type])
Ejemplo n.º 5
0
def GetBuildFailureInfo(master_name, builder_name, build_number):
  """Processes build info of a build and gets failure info.

  This function will also update wf_analysis about the build's not passed steps
  and failure type.

  Args:
    master_name (str): Master name of the build.
    builder_name (str): Builder name of the build.
    build_number (int): Number of the build.

  Returns:
    A dict of failure info and a flag for should start analysis.
  """
  build_info = build_util.GetBuildInfo(master_name, builder_name, build_number)
  analysis = WfAnalysis.Get(master_name, builder_name, build_number)
  assert analysis

  if not build_info:
    logging.error('Failed to extract build info for build %s/%s/%d',
                  master_name, builder_name, build_number)
    analysis.status = analysis_status.ERROR
    analysis.result_status = result_status.NOT_FOUND_UNTRIAGED
    analysis.put()

    monitoring.OnWaterfallAnalysisStateChange(
        master_name=master_name,
        builder_name=builder_name,
        failure_type='unknown',
        canonical_step_name='unknown',
        isolate_target_name='unknown',
        status=analysis_status.STATUS_TO_DESCRIPTION[analysis_status.ERROR],
        analysis_type=analysis_approach_type.STATUS_TO_DESCRIPTION[
            analysis_approach_type.PRE_ANALYSIS])

    return {}, False

  build_failure_type = build_util.GetFailureType(build_info)
  failed = (
      build_info.result != common_pb2.SUCCESS and bool(build_info.failed_steps))

  failure_info = {
      'failed': failed,
      'master_name': master_name,
      'builder_name': builder_name,
      'build_number': build_number,
      'chromium_revision': build_info.chromium_revision,
      'builds': {},
      'failed_steps': {},
      'failure_type': build_failure_type,
      'parent_mastername': build_info.parent_mastername,
      'parent_buildername': build_info.parent_buildername,
      'is_luci': build_info.is_luci,
      'buildbucket_bucket': build_info.buildbucket_bucket,
      'buildbucket_id': build_info.buildbucket_id,
  }

  if (not failed or not build_info.chromium_revision or
      build_failure_type not in _SUPPORTED_FAILURE_TYPE):
    # No real failure or lack of required information, so no need to start
    # an analysis.
    analysis.status = analysis_status.COMPLETED
    analysis.result_status = result_status.NOT_FOUND_UNTRIAGED
    analysis.put()

    monitoring.OnWaterfallAnalysisStateChange(
        master_name=master_name,
        builder_name=builder_name,
        failure_type='unknown',
        canonical_step_name='unknown',
        isolate_target_name='unknown',
        status=analysis_status.STATUS_TO_DESCRIPTION[analysis_status.COMPLETED],
        analysis_type=analysis_approach_type.STATUS_TO_DESCRIPTION[
            analysis_approach_type.PRE_ANALYSIS])

    return failure_info, False

  failure_info['builds'][build_info.build_number] = (
      _GetBlameListAndRevisionForBuild(build_info))

  failure_info['failed_steps'] = _CreateADictOfFailedSteps(build_info)

  analysis.not_passed_steps = build_info.not_passed_steps
  analysis.build_failure_type = build_failure_type
  analysis.build_start_time = (
      analysis.build_start_time or build_info.build_start_time)
  analysis.put()

  return failure_info, True