예제 #1
0
  def RunImpl(self, parameters):
    """Returns whether or not a notification was sent."""
    # This pipeline should only be called on an existing analysis with an
    # existing culprit.
    analysis = ndb.Key(urlsafe=parameters.analysis_urlsafe_key).get()
    assert analysis

    culprit_urlsafe_key = analysis.culprit_urlsafe_key
    assert culprit_urlsafe_key

    culprit = ndb.Key(urlsafe=culprit_urlsafe_key).get()
    assert culprit

    # Bail out if the identified culprit doesn't meet the minimum requirements
    # to be sent.
    if not culprit_util.ShouldNotifyCulprit(analysis):
      return False

    # Notify the culprit if it hasn't already been notified by another analysis.
    if culprit_util.PrepareCulpritForSendingNotification(culprit_urlsafe_key):
      success = culprit_util.NotifyCulprit(culprit, analysis.bug_id)
      if success:
        analysis.Update(has_commented_on_cl=True)
      return success

    return False
예제 #2
0
  def testShouldSendNotificationAlreadyProcessed(self, _):
    repo_name = 'repo'
    revision = 'r1'
    url = 'code.review.url'
    commit_position = 1000

    analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't')

    culprit = FlakeCulprit.Create(repo_name, revision, commit_position, url)
    culprit.cr_notification_status = analysis_status.COMPLETED
    culprit.put()
    analysis.culprit_urlsafe_key = culprit.key.urlsafe()
    analysis.put()

    self.assertFalse(culprit_util.ShouldNotifyCulprit(analysis))
예제 #3
0
  def testShouldSendNotification(self, *_):
    repo_name = 'repo'
    revision = 'r1'
    url = 'code.review.url'
    commit_position = 1000

    analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't')
    analysis.confidence_in_culprit = 0.6

    culprit = FlakeCulprit.Create(repo_name, revision, commit_position, url)
    culprit.put()
    analysis.culprit_urlsafe_key = culprit.key.urlsafe()
    analysis.data_points = [
        DataPoint.Create(pass_rate=1.0, commit_position=commit_position - 1),
        DataPoint.Create(pass_rate=0.4, commit_position=commit_position),
    ]
    analysis.confidence_in_culprit = 0.6
    analysis.put()

    self.assertTrue(culprit_util.ShouldNotifyCulprit(analysis))
예제 #4
0
  def testShouldSendNotificationConfigSetFalse(self, _):
    analysis = MasterFlakeAnalysis.Create('m', 'b', 123, 's', 't')
    analysis.Save()

    self.assertFalse(culprit_util.ShouldNotifyCulprit(analysis))