Beispiel #1
0
def SaveSuspectedCLs(suspected_cls, master_name, builder_name, build_number,
                     current_failure_type):
    """Saves suspected CLs to dataStore."""
    for suspected_cl in suspected_cls:
        suspected_cl_util.UpdateSuspectedCL(
            suspected_cl['repo_name'], suspected_cl['revision'],
            suspected_cl['commit_position'], analysis_approach_type.HEURISTIC,
            master_name, builder_name, build_number, current_failure_type,
            suspected_cl['failures'], suspected_cl['top_score'])
Beispiel #2
0
    def testUpdateWfSuspectedCLAddSameBuild(self):
        approach = analysis_approach_type.HEURISTIC
        master_name = 'm'
        builder_name = 'b'
        build_number = 122
        test_failure_type = failure_type.TEST
        repo_name = 'chromium'
        revision = 'r2'
        commit_position = 2
        failures = {'step_1': ['test1', 'test2']}
        top_score = 4

        suspected_cl = WfSuspectedCL.Create(repo_name, revision,
                                            commit_position)
        suspected_cl.approaches = [analysis_approach_type.HEURISTIC]
        suspected_cl.builds = {
            build_util.CreateBuildId(master_name, builder_name, build_number):
            {
                'approaches': [analysis_approach_type.HEURISTIC],
                'failure_type': test_failure_type,
                'failures': failures,
                'status': None,
                'top_score': 4
            }
        }
        suspected_cl.failure_type = [test_failure_type]
        suspected_cl.put()

        suspected_cl_util.UpdateSuspectedCL(repo_name, revision,
                                            commit_position, approach,
                                            master_name, builder_name,
                                            build_number, test_failure_type,
                                            failures, top_score)

        expected_builds = {
            build_util.CreateBuildId(master_name, builder_name, build_number):
            {
                'approaches': [analysis_approach_type.HEURISTIC],
                'failure_type': test_failure_type,
                'failures': failures,
                'status': None,
                'top_score': 4
            }
        }

        expected_approaches = [analysis_approach_type.HEURISTIC]

        suspected_cl = WfSuspectedCL.Get(repo_name, revision)

        self.assertIsNotNone(suspected_cl)
        self.assertEqual(expected_approaches, suspected_cl.approaches)
        self.assertEqual([test_failure_type], suspected_cl.failure_type)
        self.assertEqual(expected_builds, suspected_cl.builds)
Beispiel #3
0
def UpdateSuspectedCLs(master_name, builder_name, build_number, culprits):
    if not culprits:
        return

    # Creates or updates each suspected_cl.
    for culprit in culprits.values():
        revision = culprit['revision']
        failures = {'compile': []}

        suspected_cl_util.UpdateSuspectedCL(culprit['repo_name'], revision,
                                            culprit.get('commit_position'),
                                            analysis_approach_type.TRY_JOB,
                                            master_name, builder_name,
                                            build_number, failure_type.COMPILE,
                                            failures, None)
Beispiel #4
0
def UpdateSuspectedCLs(master_name, builder_name, build_number, culprits,
                       result):
    if not culprits:
        return

    # Creates or updates each suspected_cl.
    for culprit in culprits.values():
        revision = culprit['revision']
        failures = _GetTestFailureCausedByCL(
            result.report.result.get(revision) if result else None)

        suspected_cl_util.UpdateSuspectedCL(culprit['repo_name'], revision,
                                            culprit.get('commit_position'),
                                            analysis_approach_type.TRY_JOB,
                                            master_name, builder_name,
                                            build_number, failure_type.TEST,
                                            failures, None)
Beispiel #5
0
    def testCreateWfSuspectedCL(self):
        approach = analysis_approach_type.HEURISTIC
        master_name = 'm'
        builder_name = 'b'
        build_number = 123
        compile_failure_type = failure_type.COMPILE
        repo_name = 'chromium'
        revision = 'r1'
        commit_position = 1
        failures = {'compile': []}
        top_score = 5

        mocked_utcnow = datetime.datetime(2016, 10, 4, 0, 0, 0)
        self.MockUTCNow(mocked_utcnow)

        self.assertIsNone(WfSuspectedCL.Get(repo_name, revision))

        suspected_cl_util.UpdateSuspectedCL(repo_name, revision,
                                            commit_position, approach,
                                            master_name, builder_name,
                                            build_number, compile_failure_type,
                                            failures, top_score)

        expected_builds = {
            build_util.CreateBuildId(master_name, builder_name, build_number):
            {
                'approaches': [approach],
                'failure_type': compile_failure_type,
                'failures': failures,
                'status': None,
                'top_score': top_score
            }
        }

        suspected_cl = WfSuspectedCL.Get(repo_name, revision)

        self.assertIsNotNone(suspected_cl)
        self.assertEqual([analysis_approach_type.HEURISTIC],
                         suspected_cl.approaches)
        self.assertEqual([compile_failure_type], suspected_cl.failure_type)
        self.assertEqual(expected_builds, suspected_cl.builds)
        self.assertEqual(mocked_utcnow, suspected_cl.identified_time)
        self.assertEqual(mocked_utcnow, suspected_cl.updated_time)