Ejemplo n.º 1
0
    def RunImpl(self, parameters):
        analysis_urlsafe_key = parameters.analysis_urlsafe_key
        analysis = entity_util.GetEntityFromUrlsafeKey(analysis_urlsafe_key)
        assert analysis, 'Cannot retrieve analysis entry from datastore {}'.format(
            analysis_urlsafe_key)

        # Determine if flakiness is still persistent.
        still_flaky = flake_analysis_util.FlakyAtMostRecentlyAnalyzedCommit(
            analysis)

        # TODO(crbug.com/905754): Call auto actions as an async taskqueue task.
        flake_analysis_actions.OnCulpritIdentified(analysis_urlsafe_key)

        if not still_flaky:  # pragma: no cover.
            analysis.LogInfo(
                'No further actions taken due to latest commit being stable.')
            return

        # Data needed for reverts.
        build_key = BaseBuildModel.CreateBuildKey(
            analysis.original_master_name, analysis.original_builder_name,
            analysis.original_build_number)
        with pipeline.InOrder():
            # Revert culprit if applicable.
            yield CreateAndSubmitRevertPipeline(
                self.CreateInputObjectInstance(
                    CreateAndSubmitRevertInput,
                    analysis_urlsafe_key=analysis.key.urlsafe(),
                    build_key=build_key))

            # Update culprit code review.
            yield NotifyCulpritPipeline(
                self.CreateInputObjectInstance(
                    NotifyCulpritInput,
                    analysis_urlsafe_key=analysis_urlsafe_key))
Ejemplo n.º 2
0
    def testOnCulpritIdentified(self, mocked_update_monorail,
                                mocked_update_issues, mocked_merge):
        project = 'chromium'
        master_name = 'm'
        builder_name = 'b'
        build_number = 123
        step_name = 's'
        test_name = 't'
        label = 'l'
        bug_id = 12345
        merged_bug_id = 12344
        revision = 'r1000'
        commit_position = 1000

        merged_issue = FlakeIssue.Create(project, merged_bug_id)
        merged_issue.put()
        issue = FlakeIssue.Create(project, bug_id)
        issue.merge_destination_key = merged_issue.key
        issue.put()

        flake = Flake.Create(project, step_name, test_name, label)
        flake.flake_issue_key = issue.key
        flake.put()

        culprit = FlakeCulprit.Create(project, revision, commit_position)
        culprit.flake_issue_key = merged_issue.key
        culprit.put()

        mocked_merge.return_value = (issue.key, merged_issue.key)

        analysis = MasterFlakeAnalysis.Create(master_name, builder_name,
                                              build_number, step_name,
                                              test_name)
        analysis.flake_key = flake.key
        analysis.culprit_urlsafe_key = culprit.key.urlsafe()
        analysis.confidence_in_culprit = 0.9
        analysis.put()

        flake_analysis_actions.OnCulpritIdentified(analysis.key.urlsafe())

        mocked_merge.assert_called_once_with(issue.key, culprit.key)
        mocked_update_issues.assert_called_once_with(
            issue.key, issue.merge_destination_key)
        mocked_update_monorail.assert_called_once_with(analysis.key.urlsafe())
Ejemplo n.º 3
0
    def testOnCulpritIdentifiedAttachCulpritFlakeIssue(self,
                                                       mocked_update_monorail,
                                                       mocked_merge):
        project = 'chromium'
        master_name = 'm'
        builder_name = 'b'
        build_number = 123
        step_name = 's'
        test_name = 't'
        label = 'l'
        merged_bug_id = 12344
        revision = 'r1000'
        commit_position = 1000

        merged_issue = FlakeIssue.Create(project, merged_bug_id)
        merged_issue.put()

        flake = Flake.Create(project, step_name, test_name, label)
        flake.put()

        culprit = FlakeCulprit.Create(project, revision, commit_position)
        culprit.flake_issue_key = merged_issue.key
        culprit.put()

        analysis = MasterFlakeAnalysis.Create(master_name, builder_name,
                                              build_number, step_name,
                                              test_name)
        analysis.flake_key = flake.key
        analysis.culprit_urlsafe_key = culprit.key.urlsafe()
        analysis.confidence_in_culprit = 0.9
        analysis.put()

        flake_analysis_actions.OnCulpritIdentified(analysis.key.urlsafe())

        self.assertFalse(mocked_merge.called)
        mocked_update_monorail.assert_called_once_with(analysis.key.urlsafe())
        flake = flake.key.get()
        self.assertEqual(merged_issue.key, flake.flake_issue_key)