예제 #1
0
    def setUp(self):
        helpers.patch(self, [
            'libs.issue_management.monorail.issue_tracker_manager.'
            'IssueTrackerManager.get_issues',
        ])

        mock_issue = MonorailIssue()
        mock_issue.id = 1337
        mock_issue.summary = 'summary'
        mock_issue.body = 'body'
        mock_issue.owner = 'owner'
        mock_issue.reporter = 'reporter'
        mock_issue.status = 'New'
        mock_issue.add_label('label1')
        mock_issue.add_label('label2')
        mock_issue.add_component('A>B')
        mock_issue.add_component('C>D')
        mock_issue.add_cc('*****@*****.**')

        mock_comment0 = MonorailComment()
        mock_comment0.author = 'author'
        mock_comment0.cc = ['*****@*****.**', '*****@*****.**']
        mock_comment0.labels = ['-label0', 'label1']
        mock_comment0.components = ['-E>F', 'A>B']
        mock_comment0.comment = 'comment'
        mock_comment0.summary = 'summary'
        mock_comment0.status = 'status'
        mock_comment0.owner = 'owner'

        mock_comment1 = MonorailComment()
        mock_comment1.author = 'author'
        mock_comment1.comment = 'comment'

        mock_issue.comments = [
            mock_comment0,
            mock_comment1,
        ]

        mock_issue_merged = MonorailIssue()
        mock_issue_merged.id = 1338
        mock_issue_merged.merged_into = 1337
        mock_issue_merged.merged_into_project = 'project'
        mock_issue_merged.closed = datetime.datetime(2019, 1, 1)

        mock_issue_merged_another_project = MonorailIssue()
        mock_issue_merged_another_project.id = 1339
        mock_issue_merged_another_project.merged_into = 1
        mock_issue_merged_another_project.merged_into_project = 'different-project'

        mock_issues = {
            1337: mock_issue,
            1338: mock_issue_merged,
            1339: mock_issue_merged_another_project,
        }

        self.itm = IssueTrackerManager('project', mock_issues)
        self.issue_tracker = monorail.IssueTracker(self.itm)
    def test_recovered_build_failure(self):
        """Test fixed build failures."""
        # Use the same status for all build types.
        self.mock.get.return_value = MockResponse(
            json.dumps({
                'projects': [{
                    'history': [{
                        'finish_time': '2018-02-01T00:00:00.000000Z',
                        'build_id': 'proj0-id',
                        'success': True
                    }],
                    'name':
                    'proj0',
                }]
            }))

        data_types.OssFuzzBuildFailure(
            id='proj0',
            project_name='proj0',
            last_checked_timestamp=datetime.datetime(2018, 1, 31),
            issue_id='1',
            consecutive_failures=2,
            build_type='fuzzing').put()

        issue = Issue()
        issue.open = True
        issue.add_label('Type-Build-Failure')
        issue.add_label('Proj-proj2')
        issue.summary = 'Build failure in proj2'
        issue.body = 'Build failure'

        self.itm.issues[1] = issue

        self.app.get('/build-status')
        self.assertEqual(0, data_types.OssFuzzBuildFailure.query().count())

        issue = self.itm.issues[1]
        self.assertEqual('Verified', issue.status)
        self.assertEqual('The latest build has succeeded, closing this issue.',
                         issue.comment)