Пример #1
0
  def _GetAdditionalInformationForCL(
      self, repo_name, revision, confidences, build, reference_build_key):
    """Gets additional information for a cl.

    Currently additional information contains:
        confidence of the result;
        approaches that found this cl: HEURISTIC, TRY_JOB or both;
        revert_cl_url if the cl has been reverted by Findit.
    """
    additional_info = {}

    cl = WfSuspectedCL.Get(repo_name, revision)
    if not cl:
      return additional_info

    master_name = buildbot.GetMasterNameFromUrl(build.master_url)
    builder_name = build.builder_name
    current_build = build.build_number

    # If the CL is found by a try job, only the first failure will be recorded.
    # So we might need to go to the first failure to get CL information.
    build_info = cl.GetBuildInfo(master_name, builder_name, current_build)
    first_build_info = None if not reference_build_key else cl.GetBuildInfo(
        *build_util.GetBuildInfoFromId(reference_build_key))
    additional_info['confidence'], additional_info['cl_approach'] = (
        suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach(
            confidences, build_info, first_build_info))

    # Gets the revert_cl_url for the CL if there is one.
    if cl.revert_cl_url:
      additional_info['revert_cl_url'] = cl.revert_cl_url

    return additional_info
Пример #2
0
    def testGetSuspectedCLConfidenceScoreAndApproachUseFirstBuild(self):
        build = {
            'failure_type': failure_type.COMPILE,
            'failures': None,
            'status': suspected_cl_status.CORRECT,
            'approaches': [analysis_approach_type.TRY_JOB],
            'top_score': 5
        }

        first_build = {
            'failure_type':
            failure_type.COMPILE,
            'failures':
            None,
            'status':
            suspected_cl_status.CORRECT,
            'approaches':
            [analysis_approach_type.TRY_JOB, analysis_approach_type.HEURISTIC],
            'top_score':
            5
        }

        confidence, approach = (
            suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach(
                self.cl_confidences, build, first_build))

        self.assertEqual(
            suspected_cl_util._RoundConfidentToInteger(
                self.cl_confidences.compile_heuristic_try_job.confidence),
            confidence)
        self.assertEqual(analysis_approach_type.TRY_JOB, approach)
Пример #3
0
    def testGetSuspectedCLConfidenceScoreAndApproachUseLessTest(self):
        build = {
            'failure_type': failure_type.TEST,
            'failures': {
                'a': ['t1']
            },
            'status': suspected_cl_status.CORRECT,
            'approaches': [analysis_approach_type.HEURISTIC],
            'top_score': 5
        }

        first_build = {
            'failure_type':
            failure_type.TEST,
            'failures': {
                'a': ['t1', 't2']
            },
            'status':
            suspected_cl_status.CORRECT,
            'approaches':
            [analysis_approach_type.TRY_JOB, analysis_approach_type.HEURISTIC],
            'top_score':
            5
        }

        confidence, approach = (
            suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach(
                self.cl_confidences, build, first_build))

        self.assertEqual(
            suspected_cl_util._RoundConfidentToInteger(
                self.cl_confidences.test_heuristic_try_job.confidence),
            confidence)
        self.assertEqual(analysis_approach_type.TRY_JOB, approach)
Пример #4
0
 def testGetSuspectedCLConfidenceScoreAndApproachNone(self):
     confidence, approach = (
         suspected_cl_util.GetSuspectedCLConfidenceScoreAndApproach(
             self.cl_confidences, None, None))
     self.assertIsNone(confidence)
     self.assertIsNone(approach)