コード例 #1
0
    def testOnSwarmingTaskStateChangedError(self, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 10
        step_name = 's'
        WfSwarmingTask.Create(master_name, builder_name, build_number,
                              step_name).put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['test'])

        self.assertFalse(
            test_swarming.OnSwarmingTaskStateChanged(parameters, 'task_id'))
コード例 #2
0
  def CallbackImpl(self, run_swarming_task_params, parameters):
    """Updates the WfSwarmingTask entity with status from swarming."""
    if not parameters.get('task_id'):
      # Task_id is not saved in callback parameters yet, retries the callback.
      return 'Task_id not found for pipeline %s' % self.pipeline_id, None

    task_id = parameters['task_id']
    try:
      pipeline_completed = test_swarming.OnSwarmingTaskStateChanged(
          run_swarming_task_params, task_id)
      if not pipeline_completed:
        return None
      return None, pipeline_completed
    except exceptions.RetryException as e:  # Indicate an error to retry.
      return ('Error on updating swarming task result: %s' % e.error_message,
              None)
コード例 #3
0
    def testOnSwarmingTaskStateChangedNoTaskData(self, mock_error, _):
        master_name = 'm'
        builder_name = 'b'
        build_number = 11
        step_name = 's'
        task = WfSwarmingTask.Create(master_name, builder_name, build_number,
                                     step_name)
        task.put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['test'])

        result = test_swarming.OnSwarmingTaskStateChanged(
            parameters, 'task_id')
        self.assertIsNone(result)
        mock_error.assert_called_once_with(master_name, builder_name,
                                           build_number, step_name, 'error',
                                           False)
コード例 #4
0
    def testOnSwarmingTaskStateChangedCompleted(self, mock_complete, *_):
        master_name = 'm'
        builder_name = 'b'
        build_number = 8
        step_name = 's'
        task = WfSwarmingTask.Create(master_name, builder_name, build_number,
                                     step_name)
        task.put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['test'])

        result = test_swarming.OnSwarmingTaskStateChanged(
            parameters, 'task_id')
        self.assertTrue(result)
        mock_complete.assert_called_once_with(
            master_name, builder_name, build_number, step_name,
            {'state': constants.STATE_COMPLETED}, 'content')
コード例 #5
0
    def testOnSwarmingTaskStateChangedRunning(self, mock_update, _):
        master_name = 'm'
        builder_name = 'b'
        build_number = 9
        step_name = 's'
        task = WfSwarmingTask.Create(master_name, builder_name, build_number,
                                     step_name)
        task.put()
        parameters = RunSwarmingTaskParameters(build_key=BuildKey(
            master_name=master_name,
            builder_name=builder_name,
            build_number=build_number),
                                               step_name=step_name,
                                               tests=['test'])

        result = test_swarming.OnSwarmingTaskStateChanged(
            parameters, 'task_id')
        self.assertIsNone(result)
        mock_update.assert_called_once_with(master_name,
                                            builder_name,
                                            build_number,
                                            step_name,
                                            status=analysis_status.RUNNING)