Exemple #1
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)
Exemple #2
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)
Exemple #3
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)