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'))
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)
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)
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')
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)