Ejemplo n.º 1
0
    def testRevertCulprit(self, mock_revert, *_):
        repo_name = 'chromium'
        revision = 'rev1'
        build_key = 'm/b/123'

        revert_cl = RevertCL()
        revert_cl.revert_cl_url = 'url'
        revert_cl.created_time = datetime.datetime(2018, 6, 20, 0, 0, 0)

        mock_revert.return_value = (constants.CREATED_BY_FINDIT, revert_cl,
                                    None)

        culprit = WfSuspectedCL.Create(repo_name, revision, 1)
        culprit.put()

        pipeline_input = CreateRevertCLParameters(
            cl_key=culprit.key.urlsafe(),
            build_key=build_key,
            failure_type=failure_type.COMPILE)
        self.assertEqual(
            constants.CREATED_BY_FINDIT,
            culprit_action.RevertCulprit(pipeline_input, 'pipeline_id'))
        culprit = WfSuspectedCL.Get(repo_name, revision)
        self.assertEqual(revert_cl, culprit.revert_cl)
        self.assertEqual(analysis_status.COMPLETED, culprit.revert_status)
Ejemplo n.º 2
0
def CreateAndSubmitRevert(parameters, runner_id):
    """Wraps the creation and submission of autoreverts for flaky tests."""
    analysis = ndb.Key(urlsafe=parameters.analysis_urlsafe_key).get()
    assert analysis
    culprit = ndb.Key(urlsafe=analysis.culprit_urlsafe_key).get()
    assert culprit

    # TODO(crbug.com/907675): Create, but not auto commit reverts for some
    # culprits.

    if not IsAutorevertEnabled():
        analysis.LogInfo('Autorevert is disabled.')
        return False

    if not UnderLimitForAutorevert():
        analysis.LogInfo('Not autoreverting since limit has been reached.')
        return False

    # Verify the conditions for revert are satisfied.
    if not CanRevertForAnalysis(analysis):
        analysis.LogInfo('Not reverting: CanRevertForAnalysis returned false.')
        return False

    # Create the revert, and check if it succeeded. If it succeeded, then
    # continue on and submit it.
    revert_culprit_parameters = CreateRevertCLParameters(
        cl_key=culprit.key.urlsafe(),
        build_key=parameters.build_key,
        failure_type=failure_type.FLAKY_TEST)
    revert_status = culprit_action.RevertCulprit(revert_culprit_parameters,
                                                 runner_id)
    if revert_status != constants.CREATED_BY_FINDIT:
        analysis.LogInfo(
            'Not reverting: RevertCulprit wasn\'t able to create a revert.')
        return False

    submit_revert_paramters = SubmitRevertCLParameters(
        cl_key=culprit.key.urlsafe(),
        revert_status=revert_status,
        failure_type=failure_type.FLAKY_TEST)
    submit_revert_status = culprit_action.CommitRevert(submit_revert_paramters,
                                                       runner_id)
    if submit_revert_status != constants.COMMITTED:
        analysis.LogInfo(
            'Not reverting: CommitRevert wasn\'t able to submit the revert')
        analysis.Update(has_created_autorevert=True)
        return False

    analysis.Update(has_created_autorevert=True,
                    has_submitted_autorevert=True,
                    autorevert_submission_time=time_util.GetUTCNow())
    return True
Ejemplo n.º 3
0
    def testRevertCulpritSkipped(self, _):
        repo_name = 'chromium'
        revision = 'rev1'
        build_key = 'm/b/123'

        culprit = WfSuspectedCL.Create(repo_name, revision, 1)
        culprit.put()

        pipeline_input = CreateRevertCLParameters(
            cl_key=culprit.key.urlsafe(),
            build_key=build_key,
            failure_type=failure_type.COMPILE)
        self.assertEqual(
            constants.SKIPPED,
            culprit_action.RevertCulprit(pipeline_input, 'pipeline_id'))
Ejemplo n.º 4
0
 def RunImpl(self, pipeline_input):
   return culprit_action.RevertCulprit(pipeline_input, self.pipeline_id)