Ejemplo n.º 1
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.º 2
0
    def testCommitSkipped(self, *_):
        repo_name = 'chromium'
        revision = 'rev1'

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

        pipeline_input = SubmitRevertCLParameters(
            cl_key=culprit.key.urlsafe(),
            revert_status=constants.CREATED_BY_FINDIT,
            failure_type=failure_type.COMPILE)

        self.assertEqual(
            constants.SKIPPED,
            culprit_action.CommitRevert(pipeline_input, 'pipeline_id'))
Ejemplo n.º 3
0
    def testCommit(self, *_):
        culprit = WfSuspectedCL.Create('chromium', 'rev1', 1)
        culprit.put()

        pipeline_input = SubmitRevertCLParameters(
            cl_key=culprit.key.urlsafe(),
            revert_status=constants.CREATED_BY_FINDIT,
            failure_type=failure_type.COMPILE)

        self.assertEqual(
            constants.COMMITTED,
            culprit_action.CommitRevert(pipeline_input, 'pipeline_id'))

        culprit = WfSuspectedCL.Get('chromium', 'rev1')
        self.assertEqual(analysis_status.COMPLETED,
                         culprit.revert_submission_status)
Ejemplo n.º 4
0
 def RunImpl(self, pipeline_input):
     return culprit_action.CommitRevert(pipeline_input, self.pipeline_id)