def testAnnotateFailingBuilders(self):
    """Tests that _AnnotateFailingBuilders is free of syntax errors."""
    stage = self.ConstructStage()

    annotate_mock = self.PatchObject(
        completion_stages.MasterSlaveSyncCompletionStage,
        '_AnnotateNoStatBuilders')

    failing = {'failing_build'}
    inflight = {'inflight_build'}
    no_stat = {'no_stat_build'}
    failed_msg = build_failure_message.BuildFailureMessage(
        'message', [], True, 'reason', 'bot')
    failed_status = builder_status_lib.BuilderStatus(
        'failed', failed_msg, 'url')
    inflight_status = builder_status_lib.BuilderStatus('inflight', None, 'url')
    statuses = {'failing_build' : failed_status,
                'inflight_build': inflight_status}

    stage._AnnotateFailingBuilders(failing, inflight, set(), statuses, {},
                                   False)
    self.assertEqual(annotate_mock.call_count, 1)

    stage._AnnotateFailingBuilders(failing, inflight, no_stat, statuses, {},
                                   False)
    self.assertEqual(annotate_mock.call_count, 2)

    stage._AnnotateFailingBuilders(failing, inflight, no_stat, statuses, {},
                                   True)
    self.assertEqual(annotate_mock.call_count, 3)
Example #2
0
 def ConstructBuildFailureMessage(self,
                                  message_summary='message_summary',
                                  failure_messages=None,
                                  internal=True,
                                  reason='reason',
                                  builder='builder'):
     return build_failure_message.BuildFailureMessage(
         message_summary, failure_messages, internal, reason, builder)
Example #3
0
 def GetFailedMessage(failure_messages,
                      stage='Build',
                      internal=False,
                      bot='daisy_spring-paladin'):
     """Returns a build_failure_message.BuildFailureMessage object."""
     return build_failure_message.BuildFailureMessage(
         'Stage %s failed' % stage, failure_messages, internal,
         'failure reason string', bot)
Example #4
0
    def CreateBuildFailureMessage(cls,
                                  build_config,
                                  overlays,
                                  dashboard_url,
                                  failure_messages,
                                  aborted_by_self_destruction=False):
        """Creates a message summarizing the failures.

    Args:
      build_config: Build config name (string) of a slave build.
      overlays: The overlays used for the build.
      dashboard_url: The URL of the build.
      failure_messages: A list of stage failure messages (instances of
        StageFailureMessage or its sub-classes) of the given build.
      aborted_by_self_destruction: Whether the build was canceled by master.

    Returns:
      A build_failure_message.BuildFailureMessage object.
    """
        internal = overlays in [
            constants.PRIVATE_OVERLAYS, constants.BOTH_OVERLAYS
        ]
        details = []

        if failure_messages:
            for x in failure_messages:
                details.append('The %s stage failed: %s' %
                               (x.stage_name, x.exception_message))

        if not details:
            details = ['cbuildbot failed']
            if aborted_by_self_destruction:
                details = ['aborted by self-destruction']

        # reason does not include builder name or URL. This is mainly for
        # populating the "failure message" column in the stats sheet.
        reason = ' '.join(details)
        details.append('in %s' % dashboard_url)
        msg_summary = '%s: %s' % (build_config, ' '.join(details))

        return build_failure_message.BuildFailureMessage(
            msg_summary, failure_messages, internal, reason, build_config)
  def testAnnotateFailingExperimentalBuilders(self):
    """Tests _AnnotateFailingBuilders with experimental builders."""
    stage = self.ConstructStage()

    print_build_message_mock = self.PatchObject(
        completion_stages.MasterSlaveSyncCompletionStage,
        '_PrintBuildMessage')

    failed_msg = build_failure_message.BuildFailureMessage(
        'message', [], True, 'reason', 'bot')
    experimental_statuses = {
        'passed_experimental' : builder_status_lib.BuilderStatus(
            constants.BUILDER_STATUS_PASSED, None, 'url'),
        'failing_experimental' : builder_status_lib.BuilderStatus(
            constants.BUILDER_STATUS_FAILED, failed_msg, 'url'),
        'inflight_experimental': builder_status_lib.BuilderStatus(
            constants.BUILDER_STATUS_INFLIGHT, None, 'url')
    }

    stage._AnnotateFailingBuilders(set(), set(), set(), {},
                                   experimental_statuses, False)
    # Build message should not be printed for the passed builder.
    self.assertEqual(print_build_message_mock.call_count, 2)