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 testSendNotificationLatestBuildPassed(self, mocked_pipeline, _): 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' }}) 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() self.assertFalse(mocked_pipeline.called)
def testCanAutoCreateRevert(self, _): repo_name = 'chromium' revision = 'rev1' culprit = WfSuspectedCL.Create(repo_name, revision, 123) culprit.failure_type.append(failure_type.TEST) culprit.revert_created_time = datetime(2018, 2, 14, 12, 0, 0) culprit.put() culprit_dict = DictOfBasestring() culprit_dict[revision] = culprit.key.urlsafe() heuristic_cls = ListOfBasestring() heuristic_cls.append(culprit.key.urlsafe()) parameters_dict = { 'build_key': { 'master_name': 'm', 'builder_name': 'b', 'build_number': 123 }, 'culprits': { 'rev1': culprit.key.urlsafe() }, 'heuristic_cls': heuristic_cls } parameters = CulpritActionParameters.FromSerializable(parameters_dict) self.assertTrue( test_culprit_action.CanAutoCreateRevert(culprit.key.urlsafe(), parameters))
def setUp(self): super(TestCulpritActionTest, self).setUp() repo_name = 'chromium' revision = 'rev1' self.culprit = WfSuspectedCL.Create(repo_name, revision, 100).put().urlsafe() culprit_dict = DictOfBasestring() culprit_dict[revision] = self.culprit heuristic_cls = ListOfBasestring() heuristic_cls.append(self.culprit) parameters_dict = { 'build_key': { 'master_name': 'm', 'builder_name': 'b', 'build_number': 123 }, 'culprits': { 'rev1': self.culprit }, 'heuristic_cls': heuristic_cls } self.parameters = CulpritActionParameters.FromSerializable( parameters_dict)
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()
def GetHeuristicSuspectedCLs(master_name, builder_name, build_number): """Gets revisions of suspected cls found by heuristic approach.""" analysis = WfAnalysis.Get(master_name, builder_name, build_number) suspects = ListOfBasestring() if analysis and analysis.suspected_cls: for cl in analysis.suspected_cls: culprit = WfSuspectedCL.Get(cl['repo_name'], cl['revision']) if not culprit: # pragma: no cover logging.warning( 'No culprit found for repo_name %s and revision %s', cl['repo_name'], cl['revision']) continue suspects.append(culprit.key.urlsafe()) return suspects
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()
def testShouldForceNotify(self): cl_key = 'mockurlsafekey' culprit_dict = DictOfBasestring() culprit_dict['rev1'] = cl_key heuristic_cls = ListOfBasestring() heuristic_cls.append(cl_key) parameters_dict = { 'build_key': { 'master_name': 'm', 'builder_name': 'b', 'build_number': 123 }, 'culprits': { 'rev1': culprit_dict }, 'heuristic_cls': heuristic_cls } self.assertTrue( culprit_action.ShouldForceNotify( cl_key, CulpritActionParameters.FromSerializable(parameters_dict)))