Beispiel #1
0
    def ConvertToStageFailureMessage(self,
                                     build_stage_id,
                                     stage_name,
                                     stage_prefix_name=None):
        """Convert CompoundFailure to StageFailureMessage.

    Args:
      build_stage_id: The id of the build stage.
      stage_name: The name (string) of the failed stage.
      stage_prefix_name: The prefix name (string) of the failed stage,
          default to None.

    Returns:
      An instance of failure_message_lib.StageFailureMessage.
    """
        stage_failure = failure_message_lib.StageFailure(
            None, build_stage_id, None,
            self.__class__.__name__, str(self), self.EXCEPTION_CATEGORY,
            self.EncodeExtraInfo(), None, stage_name, None, None, None, None,
            None, None, None, None, None, None)
        compound_failure_message = failure_message_lib.CompoundFailureMessage(
            stage_failure, stage_prefix_name=stage_prefix_name)

        for exc_class, exc_str, _ in self.exc_infos:
            inner_failure = failure_message_lib.StageFailure(
                None, build_stage_id, None, exc_class.__name__, exc_str,
                _GetExceptionCategory(exc_class), None, None, stage_name, None,
                None, None, None, None, None, None, None, None, None)
            innner_failure_message = failure_message_lib.StageFailureMessage(
                inner_failure, stage_prefix_name=stage_prefix_name)
            compound_failure_message.inner_failures.append(
                innner_failure_message)

        return compound_failure_message
Beispiel #2
0
 def CreateStageFailure(
         cls,
         failure_id=1,
         build_stage_id=1,
         outer_failure_id=None,
         exception_type='StepFailure',
         exception_message='exception message',
         exception_category=constants.EXCEPTION_CATEGORY_UNKNOWN,
         extra_info=None,
         timestamp=None,
         stage_name='stage_1',
         board='board_1',
         stage_status=constants.BUILDER_STATUS_PASSED,
         build_id=1,
         master_build_id=None,
         builder_name='builder_name_1',
         build_number='build_number_1',
         build_config='config_1',
         build_status=constants.BUILDER_STATUS_PASSED,
         important=True,
         buildbucket_id='bb_id'):
     return failure_message_lib.StageFailure(
         failure_id, build_stage_id, outer_failure_id, exception_type,
         exception_message, exception_category, extra_info, timestamp,
         stage_name, board, stage_status, build_id, master_build_id,
         builder_name, build_number, build_config, build_status, important,
         buildbucket_id)
Beispiel #3
0
  def GetBuildsFailures(self, buildbucket_ids=None):
    """Gets the failure entries for all listed buildbucket_ids.

    Args:
      buildbucket_ids: list of build ids of the builds to fetch failures for.

    Returns:
      A list of failure_message_lib.StageFailure instances. This will change
      with Buildbucket implementation.
    """
    if not self.InitializeClients():
      raise BuildStoreException('BuildStore clients could not be initialized.')
    if not buildbucket_ids:
      return []
    elif self._read_from_bb:
      failure_list = []
      for buildbucket_id in buildbucket_ids:
        bb_list = self.bb_client.GetStageFailures(int(buildbucket_id))
        for stage in bb_list:
          failure_list.append(failure_message_lib.StageFailure(
              id=None, build_stage_id=None, outer_failure_id=None,
              exception_type=None, exception_message=None,
              exception_category=None, extra_info=None, timestamp=None,
              stage_name=stage['stage_name'], board=None,
              stage_status=stage['stage_status'], build_id=None,
              master_build_id=None, builder_name=None, build_number=None,
              build_config=stage['build_config'],
              build_status=stage['build_status'],
              important=stage['important'], buildbucket_id=buildbucket_id))
      return failure_list
    else:
      return self.cidb_conn.GetBuildsFailures(buildbucket_ids)
Beispiel #4
0
def GetStageFailureMessageFromException(stage_name,
                                        build_stage_id,
                                        exception,
                                        stage_prefix_name=None):
    """Get StageFailureMessage from an exception.

  Args:
    stage_name: The name (string) of the failed stage.
    build_stage_id: The id of the failed build stage.
    exception: The BaseException instance to convert to StageFailureMessage.
    stage_prefix_name: The prefix name (string) of the failed stage,
        default to None.

  Returns:
    An instance of failure_message_lib.StageFailureMessage.
  """
    if isinstance(exception, StepFailure):
        return exception.ConvertToStageFailureMessage(
            build_stage_id, stage_name, stage_prefix_name=stage_prefix_name)
    else:
        stage_failure = failure_message_lib.StageFailure(
            None, build_stage_id, None,
            type(exception).__name__, str(exception),
            _GetExceptionCategory(type(exception)), None, None, stage_name,
            None, None, None, None, None, None, None, None, None, None)

        return failure_message_lib.StageFailureMessage(
            stage_failure, stage_prefix_name=stage_prefix_name)
Beispiel #5
0
    def ConvertToStageFailureMessage(self,
                                     build_stage_id,
                                     stage_name,
                                     stage_prefix_name=None):
        """Convert StepFailure to StageFailureMessage.

    Args:
      build_stage_id: The id of the build stage.
      stage_name: The name (string) of the failed stage.
      stage_prefix_name: The prefix name (string) of the failed stage,
          default to None.

    Returns:
      An instance of failure_message_lib.StageFailureMessage.
    """
        stage_failure = failure_message_lib.StageFailure(
            None, build_stage_id, None,
            self.__class__.__name__, str(self), self.EXCEPTION_CATEGORY,
            self.EncodeExtraInfo(), None, stage_name, None, None, None, None,
            None, None, None, None, None, None)
        return failure_message_lib.StageFailureMessage(
            stage_failure, stage_prefix_name=stage_prefix_name)