コード例 #1
0
 def testExistCQedDependingChangesNoDependingCL(self, mock_query, _):
     cl_info = ClInfo(self.review_server_host, self.review_change_id)
     cl_info.patchsets['12345-rev1'] = PatchSet('1', '12345-rev1', [])
     cl_info.patchsets['12345-rev1'] = PatchSet('2', '12345-rev2', [])
     mock_query.return_value = [cl_info]
     self.assertFalse(gerrit.ExistCQedDependingChanges(
         self.codereview_info))
コード例 #2
0
    def testRevertCLSucceed(self, mock_fn, mock_revert, *_):
        repo_name = 'chromium'
        revision = 'rev1'
        commit_position = 123
        build_key = 'm/b/123'

        cl_info = ClInfo(self.review_server_host, self.review_change_id)
        cl_info.commits.append(
            Commit('20001', 'rev1', ['rev0'], datetime(2017, 2, 1, 0, 0, 0)))
        cl_info.owner_email = '*****@*****.**'
        mock_fn.return_value = cl_info
        mock_revert.return_value = '54321'

        culprit = WfSuspectedCL.Create(repo_name, revision, commit_position)
        culprit.builds = {
            build_key: {
                'status': None,
                'failures': {
                    'step': ['test1']
                }
            }
        }
        culprit.put()

        pipeline_input = CreateRevertCLParameters(
            cl_key=culprit.key.urlsafe(),
            build_key=build_key,
            failure_type=failure_type.COMPILE)
        pipeline = CreateRevertCLPipeline(pipeline_input)
        revert_status = pipeline.run(pipeline_input)

        self.assertEquals(revert_status, constants.CREATED_BY_FINDIT)

        culprit = WfSuspectedCL.Get(repo_name, revision)
        self.assertEqual(culprit.revert_status, status.COMPLETED)
        self.assertIsNotNone(culprit.revert_cl)

        reason = textwrap.dedent("""
        Findit (https://goo.gl/kROfz5) identified CL at revision %s as the
        culprit for failures in the build cycles as shown on:
        https://analysis.chromium.org/waterfall/culprit?key=%s\n
        Sample Failed Build: %s\n
        Sample Failed Step: %s""") % (commit_position, culprit.key.urlsafe(),
                                      buildbot.CreateBuildUrl('m', 'b',
                                                              '123'), 'step')
        mock_revert.assert_called_with(reason,
                                       self.review_change_id,
                                       '20001',
                                       bug_id=None)
コード例 #3
0
    def testSubmitRevertSucceed(self, mock_fn, mock_commit, *_):
        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 = RevertCL()
        revert_change_id = '54321'
        revert.revert_cl_url = 'https://%s/q/%s' % (self.review_server_host,
                                                    revert_change_id)
        culprit.revert_cl = revert
        culprit.revert_status = status.COMPLETED
        culprit.put()
        revert_status = constants.CREATED_BY_FINDIT
        pipeline_input = SubmitRevertCLParameters(
            cl_key=culprit.key.urlsafe(),
            revert_status=revert_status,
            failure_type=failure_type.COMPILE)
        pipeline = SubmitRevertCLPipeline(pipeline_input)
        self.assertEqual(constants.COMMITTED, pipeline.run(pipeline_input))

        culprit = WfSuspectedCL.Get(repo_name, revision)
        self.assertEqual(culprit.revert_submission_status, status.COMPLETED)

        mock_commit.assert_called_with(revert_change_id)
コード例 #4
0
    def testAutoRevertOff(self, mock_fn, _):
        repo_name = 'chromium'
        revision = 'rev1'

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

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

        revert_status, revert, reason = gerrit.RevertCulprit(
            culprit.key.urlsafe(), 'm/b/1', failure_type.COMPILE, 'compile',
            self.codereview_info)

        self.assertEquals(services_constants.SKIPPED, revert_status)
        self.assertEquals(services_constants.AUTO_REVERT_OFF, reason)
        self.assertIsNone(revert)
コード例 #5
0
    def testRevertCLSucceed(self, mock_fn, *_):
        repo_name = 'chromium'
        revision = 'rev1'

        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)))
        cl_info.owner_email = '*****@*****.**'
        mock_fn.return_value = cl_info

        WfSuspectedCL.Create(repo_name, revision, 123).put()
        pipeline = CreateRevertCLPipeline('m', 'b', 123, repo_name, revision)
        revert_status = pipeline.run('m', 'b', 123, repo_name, revision)

        self.assertEquals(revert_status,
                          create_revert_cl_pipeline.CREATED_BY_FINDIT)

        culprit = WfSuspectedCL.Get(repo_name, revision)
        self.assertEqual(culprit.revert_status, status.COMPLETED)
        self.assertIsNotNone(culprit.revert_cl)
コード例 #6
0
    def testAddedReviewerFailedBefore(self, mock_fn, mock_send, *_):
        repo_name = 'chromium'
        revision = 'rev1'

        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)))
        cl_info.owner_email = '*****@*****.**'
        revert_cl = ClInfo('revert_review_host', '123V3127')
        revert_cl.url = 'https://chromium-review.googlesource.com/54321'
        cl_info.reverts.append(
            Revert('20001', revert_cl, constants.DEFAULT_SERVICE_ACCOUNT,
                   datetime(2017, 2, 1, 1, 0, 0)))
        mock_fn.return_value = cl_info

        culprit = WfSuspectedCL.Create(repo_name, revision, 123)
        culprit.revert_cl = RevertCL()
        culprit.revert_status = status.RUNNING
        culprit.cr_notification_status = status.COMPLETED
        culprit.put()
        revert_status, _, _ = gerrit.RevertCulprit(culprit.key.urlsafe(),
                                                   'm/b/1',
                                                   failure_type.COMPILE,
                                                   'compile',
                                                   self.codereview_info)

        self.assertEquals(revert_status, services_constants.CREATED_BY_FINDIT)
コード例 #7
0
    def testLatestBuildSucceeded(self, mock_fn, *_):
        repo_name = 'chromium'
        revision = 'rev1'

        cl_info = ClInfo(self.review_server_host, self.review_change_id)
        cl_info.owner_email = '*****@*****.**'
        cl_info.commits.append(
            Commit('20001', 'rev1', datetime(2017, 2, 1, 0, 0, 0)))
        revert_cl = ClInfo('revert_review_host', '123V3127')
        revert_cl.url = 'https://codereview.chromium.org/54321'
        cl_info.reverts.append(
            Revert('20001', revert_cl, constants.DEFAULT_SERVICE_ACCOUNT,
                   datetime(2017, 2, 1, 1, 0, 0)))
        mock_fn.return_value = cl_info

        culprit = WfSuspectedCL.Create(repo_name, revision, 123)
        culprit.revert_cl = RevertCL()
        culprit.revert_status = status.RUNNING
        culprit.put()
        pipeline = CreateRevertCLPipeline('m', 'b', 123, repo_name, revision)
        revert_status = pipeline.run('m', 'b', 123, repo_name, revision)

        self.assertEquals(revert_status, create_revert_cl_pipeline.SKIPPED)

        culprit = WfSuspectedCL.Get(repo_name, revision)
        self.assertEqual(culprit.revert_status, status.SKIPPED)
        self.assertIsNotNone(culprit.revert_cl)
        self.assertEqual(culprit.skip_revert_reason,
                         create_revert_cl_pipeline.NEWEST_BUILD_GREEN)
コード例 #8
0
    def testRevertCLNotSaved(self, mock_fn, *_):
        repo_name = 'chromium'
        revision = 'rev1'

        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)))
        cl_info.owner_email = '*****@*****.**'
        revert_cl = ClInfo('revert_review_host', '123V3127')
        revert_cl.url = 'https://codereview.chromium.org/54321'
        cl_info.reverts.append(
            Revert('20001', revert_cl, constants.DEFAULT_SERVICE_ACCOUNT,
                   datetime(2017, 2, 1, 1, 0, 0)))
        mock_fn.return_value = cl_info

        WfSuspectedCL.Create(repo_name, revision, 123).put()
        pipeline = CreateRevertCLPipeline('m', 'b', 123, repo_name, revision)
        revert_status = pipeline.run('m', 'b', 123, repo_name, revision)

        self.assertEquals(revert_status,
                          create_revert_cl_pipeline.CREATED_BY_FINDIT)

        culprit = WfSuspectedCL.Get(repo_name, revision)
        self.assertEqual(culprit.revert_status, status.COMPLETED)
        self.assertIsNotNone(culprit.revert_cl)
コード例 #9
0
    def testSheriffRevertedIt(self, mock_fn, _):
        repo_name = 'chromium'
        revision = 'rev1'

        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)))
        cl_info.owner_email = '*****@*****.**'
        revert_cl = ClInfo('revert_review_host', '123V3137')
        cl_info.reverts.append(
            Revert('20001', revert_cl, 'a@b', datetime(2017, 2, 1, 1, 0, 0)))
        mock_fn.return_value = cl_info

        suspect_cl = WfSuspectedCL.Create(repo_name, revision, 123)
        suspect_cl.put()

        revert_status, revert, reason = gerrit.RevertCulprit(
            suspect_cl.key.urlsafe(), 'm/b/1', failure_type.COMPILE, 'compile',
            self.codereview_info)
        self.assertIsNone(revert)
        self.assertEqual(services_constants.REVERTED_BY_SHERIFF, reason)
        self.assertEquals(revert_status, services_constants.CREATED_BY_SHERIFF)
コード例 #10
0
    def testAutoRevertOff(self, mock_fn, _):
        repo_name = 'chromium'
        revision = 'rev1'

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

        culprit = WfSuspectedCL.Create(repo_name, revision, 123)
        culprit.put()
        pipeline = CreateRevertCLPipeline('m', 'b', 123, repo_name, revision)
        revert_status = pipeline.run('m', 'b', 123, repo_name, revision)

        self.assertEquals(revert_status, create_revert_cl_pipeline.SKIPPED)

        culprit = WfSuspectedCL.Get(repo_name, revision)
        self.assertEqual(culprit.revert_status, status.SKIPPED)
        self.assertIsNone(culprit.revert_cl)
        self.assertEqual(culprit.skip_revert_reason,
                         create_revert_cl_pipeline.AUTO_REVERT_OFF)
コード例 #11
0
    def testCulpritCreatedByFindit(self, mock_fn, _):
        repo_name = 'chromium'
        revision = 'rev1'

        cl_info = ClInfo(self.review_server_host, self.review_change_id)
        cl_info.owner_email = constants.DEFAULT_SERVICE_ACCOUNT
        cl_info.commits.append(
            Commit('20001', 'rev1', datetime(2017, 2, 1, 0, 0, 0)))
        mock_fn.return_value = cl_info

        culprit = WfSuspectedCL.Create(repo_name, revision, 123)
        culprit.put()
        pipeline = CreateRevertCLPipeline('m', 'b', 123, repo_name, revision)
        revert_status = pipeline.run('m', 'b', 123, repo_name, revision)

        self.assertEquals(revert_status, create_revert_cl_pipeline.SKIPPED)

        culprit = WfSuspectedCL.Get(repo_name, revision)
        self.assertEqual(culprit.revert_status, status.SKIPPED)
        self.assertIsNone(culprit.revert_cl)
        self.assertEqual(culprit.skip_revert_reason,
                         create_revert_cl_pipeline.CULPRIT_OWNED_BY_FINDIT)
コード例 #12
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)
コード例 #13
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))
コード例 #14
0
    def testRevertCLSucceed(self, mock_fn, mock_gerrit, mock_add, *_):
        repo_name = 'chromium'
        revision = 'rev1'
        commit_position = 123
        sample_failed_step = 'compile'

        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)))
        cl_info.owner_email = '*****@*****.**'
        mock_fn.return_value = cl_info
        mock_gerrit.return_value = '54321'

        culprit = WfSuspectedCL.Create(repo_name, revision, commit_position)
        culprit.builds = {
            'm/b/2': {
                'status': None
            },
            'm/b/1': {
                'status': None
            },
            'm/b/3': {
                'status': None
            },
            'm1/b/0': {
                'status': None
            },
        }
        culprit.put()

        revert_status, _, _ = gerrit.RevertCulprit(culprit.key.urlsafe(),
                                                   'm/b/1',
                                                   failure_type.COMPILE,
                                                   sample_failed_step,
                                                   self.codereview_info)

        self.assertEquals(revert_status, services_constants.CREATED_BY_FINDIT)

        reason = textwrap.dedent("""
        Findit (https://goo.gl/kROfz5) identified CL at revision %s as the
        culprit for failures in the build cycles as shown on:
        https://analysis.chromium.org/waterfall/culprit?key=%s\n
        Sample Failed Build: %s\n
        Sample Failed Step: %s""") % (commit_position, culprit.key.urlsafe(),
                                      buildbot.CreateBuildUrl(
                                          'm', 'b', '1'), sample_failed_step)
        mock_gerrit.assert_called_once_with(reason,
                                            self.review_change_id,
                                            '20001',
                                            bug_id=None)

        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)
コード例 #15
0
    def testExistCQedDependingChanges(self, mock_query, _):
        cl_info = ClInfo(self.review_server_host, self.review_change_id)
        cl_info.patchsets['12345-rev1'] = PatchSet('1', '12345-rev1', [])
        cl_info.patchsets['12345-rev1'] = PatchSet('2', '12345-rev2', [])

        cl_info_1 = ClInfo(self.review_server_host, '12346')
        cl_info_1.patchsets['12346-rev1'] = PatchSet('1', '12346-rev1',
                                                     ['unrelated'])
        cl_info_1.patchsets['12346-rev2'] = PatchSet('2', '12346-rev2',
                                                     ['unrelated'])

        cl_info_2 = ClInfo(self.review_server_host, '12347')
        cl_info_2.patchsets['12347-rev1'] = PatchSet('1', '12347-rev1',
                                                     ['12345-rev1'])
        cl_info_2.patchsets['12347-rev2'] = PatchSet('2', '12347-rev2',
                                                     ['unrelated'])

        cl_info_3 = ClInfo(self.review_server_host, '12348')
        cl_info_3.patchsets['12348-rev1'] = PatchSet('1', '12348-rev1',
                                                     ['unrelated'])
        cl_info_3.patchsets['12348-rev2'] = PatchSet('2', '12348-rev2',
                                                     ['unrelated'])
        mock_query.return_value = [cl_info, cl_info_1, cl_info_2, cl_info_3]
        self.assertTrue(gerrit.ExistCQedDependingChanges(self.codereview_info))
コード例 #16
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)