Ejemplo n.º 1
0
  def testGetGoodRevisionNoLastPass(self):
    failed_steps = {
        'a': {
            'current_failure': 124,
            'first_failure': 124,
        }
    }
    builds = {
        124: {
            'chromium_revision': '124_git_hash',
            'blame_list': ['124_git_hash']
        }
    }
    failed_steps = BaseFailedSteps.FromSerializable(failed_steps)
    builds = FailureInfoBuilds.FromSerializable(builds)
    failure_info = CompileFailureInfo(
        build_number=124, failed_steps=failed_steps, builds=builds)

    self.assertIsNone(ci_failure.GetGoodRevision(failure_info))
Ejemplo n.º 2
0
  def testGetGoodRevision(self):
    failed_steps = {
        'a': {
            'current_failure': 124,
            'first_failure': 124,
            'last_pass': 123
        },
        'b': {
            'current_failure': 124,
            'first_failure': 124,
        },
        'c': {
            'current_failure': 124,
            'first_failure': 123,
            'last_pass': 122
        },
    }
    builds = {
        122: {
            'chromium_revision': '122_git_hash',
            'blame_list': ['122_git_hash']
        },
        123: {
            'chromium_revision': '123_git_hash',
            'blame_list': ['123_git_hash']
        },
        124: {
            'chromium_revision': '124_git_hash',
            'blame_list': ['124_git_hash']
        }
    }
    failed_steps = BaseFailedSteps.FromSerializable(failed_steps)
    builds = FailureInfoBuilds.FromSerializable(builds)
    failure_info = CompileFailureInfo(
        build_number=124, failed_steps=failed_steps, builds=builds)

    self.assertEqual('122_git_hash', ci_failure.GetGoodRevision(failure_info))
def HeuristicAnalysisForTest(heuristic_params):
  """Identifies culprit CL.

  Args:
    heuristic_params (TestHeuristicAnalysisParameters): A structured object
    with 2 fields:
      failure_info (TestFailureInfo): An object of failure info for the
      current failed build.
      build_completed (bool): If the build is completed.

  Returns:
    A TestHeuristicAnalysisOutput object with information about
    failure_info and heuristic_result.
  """
  failure_info = heuristic_params.failure_info
  master_name = failure_info.master_name
  builder_name = failure_info.builder_name
  build_number = failure_info.build_number

  # 1. Detects first failed builds for failed test step, updates failure_info.
  failure_info = ci_failure.CheckForFirstKnownFailure(
      master_name, builder_name, build_number, failure_info)

  # Checks first failed builds for each failed test.
  ci_test_failure.CheckFirstKnownFailureForSwarmingTests(
      master_name, builder_name, build_number, failure_info)

  analysis = WfAnalysis.Get(master_name, builder_name, build_number)
  analysis.failure_info = failure_info.ToSerializable()
  analysis.put()

  # Lacking chromium_revision indicates something is wrong in Findit,
  assert failure_info.chromium_revision, (
      'No end_revision when pulling change logs.')

  # 2. Extracts failure signal.
  signals = extract_test_signal.ExtractSignalsForTestFailure(
      failure_info, FinditHttpClient())

  # 3. Gets change_logs.
  change_logs = git.PullChangeLogs(
      ci_failure.GetGoodRevision(failure_info), failure_info.chromium_revision)

  # 4. Gets deps info.
  deps_info = deps.ExtractDepsInfo(failure_info, change_logs)

  # 5. Analyzes the test failure using information collected above.
  heuristic_result, suspected_cls = AnalyzeTestFailure(
      failure_info, change_logs, deps_info, signals)

  # Save results and other info to analysis.
  build_failure_analysis.SaveAnalysisAfterHeuristicAnalysisCompletes(
      master_name, builder_name, build_number, heuristic_result, suspected_cls)

  # Save suspected_cls to data_store.
  build_failure_analysis.SaveSuspectedCLs(
      suspected_cls, failure_info.master_name, failure_info.builder_name,
      failure_info.build_number, failure_info.failure_type)

  # Monitors analysis status change.
  # Only record one metric for each analysis.
  RecordTestFailureAnalysisStateChange(master_name, builder_name,
                                       analysis_status.COMPLETED,
                                       analysis_approach_type.HEURISTIC)

  return TestHeuristicAnalysisOutput(
      failure_info=failure_info,
      heuristic_result=TestHeuristicResult.FromSerializable(heuristic_result))