コード例 #1
0
ファイル: culprit_action.py プロジェクト: xinghun61/infra
def CommitRevert(parameters, analysis_id):
    commit_status = constants.SKIPPED
    codereview_info = GetCodeReviewDataForACulprit(parameters.cl_key)
    if _CanCommitRevert(parameters, analysis_id, codereview_info):
        commit_status = gerrit.CommitRevert(parameters, codereview_info)

    MonitorRevertAction(parameters.failure_type, parameters.revert_status,
                        commit_status)
    revert_submission_status = constants.AUTO_REVERT_STATUS_TO_ANALYSIS_STATUS[
        commit_status]
    _UpdateCulprit(parameters.cl_key,
                   revert_submission_status=revert_submission_status)
    return commit_status
コード例 #2
0
    def testSubmitRevertSucceed(self, mock_fn, mock_commit, mock_add, *_):
        repo_name = 'chromium'
        revision = 'rev1'
        commit_position = 123

        cl_info = ClInfo(self.review_server_host, self.review_change_id)
        cl_info.commits.append(
            Commit('20001', 'rev1', [], datetime(2017, 2, 1, 0, 0, 0)))
        mock_fn.return_value = cl_info
        mock_commit.return_value = True

        culprit = WfSuspectedCL.Create(repo_name, revision, commit_position)
        revert_for_culprit = RevertCL()
        revert_change_id = '54321'
        revert_for_culprit.revert_cl_url = 'https://%s/q/%s' % (
            self.review_server_host, revert_change_id)
        culprit.revert_cl = revert_for_culprit
        culprit.revert_status = status.COMPLETED
        culprit.put()
        revert_status = services_constants.CREATED_BY_FINDIT
        commit_status = gerrit.CommitRevert(
            SubmitRevertCLParameters(cl_key=culprit.key.urlsafe(),
                                     revert_status=revert_status),
            self.codereview_info)

        self.assertEqual(services_constants.COMMITTED, commit_status)

        mock_commit.assert_called_once_with(revert_change_id)

        culprit_link = (
            'https://analysis.chromium.org/waterfall/culprit?key=%s' %
            (culprit.key.urlsafe()))
        false_positive_bug_link = gerrit.CreateFinditWrongBugLink(
            gerrit.FINDIT_BUILD_FAILURE_COMPONENT, culprit_link, revision)
        message = textwrap.dedent("""
        Sheriffs, CL owner or CL reviewers:
        Please confirm this revert if it is correct.
        If it is a false positive, please reland the original CL and report this
        false positive at %s.

        For more information about Findit auto-revert: %s.

        Sheriffs, it'll be much appreciated if you could take a couple minutes
        to fill out this survey: %s.""") % (
            false_positive_bug_link, gerrit._MANUAL_LINK, gerrit._SURVEY_LINK)
        mock_add.assert_called_once_with(revert_change_id, ['*****@*****.**'],
                                         message)
コード例 #3
0
    def testCommitRevertNoCodeReview(self, _):
        repo_name = 'chromium'
        revision = 'rev1'
        commit_position = 123

        cl_info = ClInfo(self.review_server_host, self.review_change_id)
        cl_info.commits.append(
            Commit('20001', 'rev1', [], datetime(2017, 2, 1, 0, 0, 0)))

        culprit = WfSuspectedCL.Create(repo_name, revision, commit_position)
        revert_for_culprit = RevertCL()
        revert_change_id = '54321'
        revert_for_culprit.revert_cl_url = 'https://%s/q/%s' % (
            self.review_server_host, revert_change_id)
        culprit.revert_cl = revert_for_culprit
        culprit.revert_status = status.COMPLETED
        culprit.put()
        revert_status = services_constants.CREATED_BY_FINDIT
        self.assertEquals(
            services_constants.ERROR,
            gerrit.CommitRevert(
                SubmitRevertCLParameters(cl_key=culprit.key.urlsafe(),
                                         revert_status=revert_status), None))
コード例 #4
0
    def testSubmitRevertFailed(self, mock_fn, mock_commit, mock_add, *_):
        repo_name = 'chromium'
        revision = 'rev1'
        commit_position = 123

        cl_info = ClInfo(self.review_server_host, self.review_change_id)
        cl_info.commits.append(
            Commit('20001', 'rev1', [], datetime(2017, 2, 1, 0, 0, 0)))
        mock_fn.return_value = cl_info
        mock_commit.return_value = False

        culprit = WfSuspectedCL.Create(repo_name, revision, commit_position)
        revert_for_culprit = RevertCL()
        revert_change_id = '54321'
        revert_for_culprit.revert_cl_url = 'https://%s/q/%s' % (
            self.review_server_host, revert_change_id)
        culprit.revert_cl = revert_for_culprit
        culprit.revert_status = status.COMPLETED
        culprit.put()

        revert_status = services_constants.CREATED_BY_FINDIT
        commit_status = gerrit.CommitRevert(
            SubmitRevertCLParameters(cl_key=culprit.key.urlsafe(),
                                     revert_status=revert_status),
            self.codereview_info)

        self.assertEqual(services_constants.ERROR, commit_status)
        mock_commit.assert_called_once_with(revert_change_id)

        culprit_link = (
            'https://analysis.chromium.org/waterfall/culprit?key=%s' %
            culprit.key.urlsafe())
        false_positive_bug_link = gerrit.CreateFinditWrongBugLink(
            gerrit.FINDIT_BUILD_FAILURE_COMPONENT, culprit_link, revision)

        auto_revert_bug_query = urllib.urlencode({
            'status':
            'Available',
            'components':
            'Tools>Test>FindIt>Autorevert',
            'summary':
            'Auto Revert failed on %s' % revision,
            'comment':
            'Detail is %s' % culprit_link
        })
        auto_revert_bug_link = (
            'https://bugs.chromium.org/p/chromium/issues/entry?%s') % (
                auto_revert_bug_query)
        message = textwrap.dedent("""
        Sheriffs, CL owner or CL reviewers:
        Please submit this revert if it is correct.
        If it is a false positive, please abandon and report it
        at %s.
        If failed to submit the revert, please abandon it and report the failure
        at %s.

        For more information about Findit auto-revert: %s.

        Sheriffs, it'll be much appreciated if you could take a couple minutes
        to fill out this survey: %s.""") % (
            false_positive_bug_link, auto_revert_bug_link, gerrit._MANUAL_LINK,
            gerrit._SURVEY_LINK)
        mock_add.assert_called_once_with('54321', ['*****@*****.**'], message)