示例#1
0
    def testSendNotificationForCulprit(self, mock_post, _):
        repo_name = 'chromium'
        revision = 'rev1'
        revert_status = None

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

        culprit_link = culprit.GetCulpritLink()
        false_positive_bug_link = gerrit.CreateFinditWrongBugLink(
            gerrit.FINDIT_BUILD_FAILURE_COMPONENT, culprit_link, revision)

        parameters = SendNotificationForCulpritParameters(
            cl_key=culprit.key.urlsafe(),
            force_notify=False,
            revert_status=revert_status,
            failure_type=failure_type.COMPILE)

        self.assertTrue(
            gerrit.SendNotificationForCulprit(parameters,
                                              self.codereview_info))
        message = textwrap.dedent("""
    Findit (https://goo.gl/kROfz5) %s this CL at revision %s as the culprit for
    failures in the build cycles as shown on:
    https://analysis.chromium.org/waterfall/culprit?key=%s
    If it is a false positive, please report it at %s.""") % (
            'identified', self.culprit_commit_position, culprit.key.urlsafe(),
            false_positive_bug_link)
        mock_post.assert_called_once_with(self.review_change_id, message, True)
    def testSendNotificationForTestCulpritNoRevert(self, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 124

        cl_key = 'mockurlsafekey'
        culprits = DictOfBasestring()
        culprits['r1'] = cl_key
        heuristic_cls = ListOfBasestring()
        heuristic_cls.append(cl_key)

        failure_to_culprit_map = FailureToCulpritMap.FromSerializable(
            {'step1': {
                't1': 'r1'
            }})

        input_object = SendNotificationForCulpritParameters(
            cl_key=cl_key,
            force_notify=True,
            revert_status=services_constants.SKIPPED,
            failure_type=failure_type.TEST)
        self.MockSynchronousPipeline(SendNotificationForCulpritPipeline,
                                     input_object, True)

        pipeline = RevertAndNotifyTestCulpritPipeline(
            CulpritActionParameters(
                build_key=BuildKey(master_name=master_name,
                                   builder_name=builder_name,
                                   build_number=build_number),
                culprits=culprits,
                heuristic_cls=heuristic_cls,
                failure_to_culprit_map=failure_to_culprit_map))
        pipeline.start(queue_name=constants.DEFAULT_QUEUE)
        self.execute_queued_tasks()
    def testSendNotification(self, _):
        pipeline_input = SendNotificationForCulpritParameters(
            cl_key='mockurlsafekey',
            force_notify=True,
            revert_status=constants.CREATED_BY_SHERIFF,
            failure_type=failure_type.COMPILE)

        pipeline = SendNotificationForCulpritPipeline(pipeline_input)
        self.assertTrue(pipeline.run(pipeline_input))
    def testSendNotificationToConfirmRevert(self, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 124
        build_key = 'm/b/124'

        cl_key = 'mockurlsafekey'
        culprits = DictOfBasestring()
        culprits['r1'] = cl_key
        heuristic_cls = ListOfBasestring()
        heuristic_cls.append(cl_key)

        self.MockSynchronousPipeline(
            CreateRevertCLPipeline,
            CreateRevertCLParameters(cl_key=cl_key,
                                     build_key=build_key,
                                     failure_type=failure_type.COMPILE),
            services_constants.CREATED_BY_FINDIT)
        self.MockSynchronousPipeline(
            SubmitRevertCLPipeline,
            SubmitRevertCLParameters(
                cl_key=cl_key,
                revert_status=services_constants.CREATED_BY_FINDIT,
                failure_type=failure_type.COMPILE),
            services_constants.COMMITTED)
        self.MockSynchronousPipeline(
            SendNotificationToIrcPipeline,
            SendNotificationToIrcParameters(
                cl_key=cl_key,
                revert_status=services_constants.CREATED_BY_FINDIT,
                commit_status=services_constants.COMMITTED,
                failure_type=failure_type.COMPILE), True)
        self.MockSynchronousPipeline(
            SendNotificationForCulpritPipeline,
            SendNotificationForCulpritParameters(
                cl_key=cl_key,
                force_notify=True,
                revert_status=services_constants.CREATED_BY_FINDIT,
                failure_type=failure_type.COMPILE), True)

        pipeline = wrapper_pipeline.RevertAndNotifyCompileCulpritPipeline(
            CulpritActionParameters(build_key=BuildKey(
                master_name=master_name,
                builder_name=builder_name,
                build_number=build_number),
                                    culprits=culprits,
                                    heuristic_cls=heuristic_cls,
                                    failure_to_culprit_map=None))
        pipeline.start(queue_name=constants.DEFAULT_QUEUE)
        self.execute_queued_tasks()
示例#5
0
    def testSendNotificationForCulpritNoCodeReview(self, _):
        repo_name = 'chromium'
        revision = 'rev1'
        revert_status = services_constants.CREATED_BY_SHERIFF

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

        parameters = SendNotificationForCulpritParameters(
            cl_key=culprit.key.urlsafe(),
            force_notify=False,
            revert_status=revert_status,
            failure_type=failure_type.COMPILE)
        self.assertFalse(
            gerrit.SendNotificationForCulprit(parameters,
                                              self.codereview_info))
示例#6
0
    def testSendNotification(self, mock_mo, *_):
        repo_name = 'chromium'
        revision = 'rev1'
        force_notify = True
        revert_status = constants.CREATED_BY_SHERIFF

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

        pipeline_input = SendNotificationForCulpritParameters(
            cl_key=culprit.key.urlsafe(),
            force_notify=force_notify,
            revert_status=revert_status,
            failure_type=failure_type.COMPILE)
        self.assertTrue(
            culprit_action.SendNotificationForCulprit(pipeline_input))
        parameters = {'type': 'compile', 'action_taken': 'culprit_notified'}
        mock_mo.assert_called_once_with(parameters)
    def testCreatedRevertButNotCommitted(self, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 124
        build_key = 'm/b/124'

        cl_key = 'mockurlsafekey'
        culprits = DictOfBasestring()
        culprits['r1'] = cl_key
        heuristic_cls = ListOfBasestring()
        heuristic_cls.append(cl_key)
        failure_to_culprit_map = FailureToCulpritMap.FromSerializable(
            {'step1': {
                't1': 'r1'
            }})

        self.MockSynchronousPipeline(
            CreateRevertCLPipeline,
            CreateRevertCLParameters(cl_key=cl_key,
                                     build_key=build_key,
                                     failure_type=failure_type.TEST),
            services_constants.CREATED_BY_FINDIT)
        self.MockSynchronousPipeline(
            SendNotificationForCulpritPipeline,
            SendNotificationForCulpritParameters(
                cl_key=cl_key,
                force_notify=True,
                revert_status=services_constants.CREATED_BY_FINDIT,
                failure_type=failure_type.TEST), True)

        pipeline = RevertAndNotifyTestCulpritPipeline(
            CulpritActionParameters(
                build_key=BuildKey(master_name=master_name,
                                   builder_name=builder_name,
                                   build_number=build_number),
                culprits=culprits,
                heuristic_cls=heuristic_cls,
                failure_to_culprit_map=failure_to_culprit_map))
        pipeline.start(queue_name=constants.DEFAULT_QUEUE)
        self.execute_queued_tasks()