本文整理汇总了Python中mistral.db.api.tasks_get函数的典型用法代码示例。如果您正苦于以下问题:Python tasks_get函数的具体用法?Python tasks_get怎么用?Python tasks_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tasks_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_engine_one_task
def test_engine_one_task(self):
# Start workflow.
execution = ENGINE.start_workflow_execution(WB_NAME, "create-vms",
CONTEXT)
tasks = db_api.tasks_get(WB_NAME, execution['id'])
self.assertEqual(1, len(tasks))
self._assert_single_item(tasks,
name='create-vms',
state=states.RUNNING)
# Make 'create-vms' task successful.
ENGINE.convey_task_result(WB_NAME, execution['id'], tasks[0]['id'],
states.SUCCESS, None)
execution = db_api.execution_get(WB_NAME, execution['id'])
self.assertEqual(execution['state'], states.SUCCESS)
tasks = db_api.tasks_get(WB_NAME, execution['id'])
self.assertEqual(1, len(tasks))
self._assert_single_item(tasks,
name='create-vms',
state=states.SUCCESS)
示例2: test_engine_tasks_on_success_finish
def test_engine_tasks_on_success_finish(self):
# Start workflow.
execution = self.engine.start_workflow_execution(WB_NAME,
"test_subsequent",
CONTEXT)
tasks = db_api.tasks_get(WB_NAME, execution['id'])
self.assertEqual(len(tasks), 1)
execution = db_api.execution_get(WB_NAME, execution['id'])
task = self._assert_single_item(tasks, name='test_subsequent')
# Make 'test_subsequent' task successful.
self.engine.convey_task_result(WB_NAME, execution['id'],
task['id'],
states.SUCCESS, None)
tasks = db_api.tasks_get(WB_NAME, execution['id'])
self.assertEqual(len(tasks), 4)
self._assert_single_item(tasks,
name='test_subsequent',
state=states.SUCCESS)
self._assert_single_item(tasks,
name='attach-volumes',
state=states.IDLE)
tasks2 = self._assert_multiple_items(tasks, 2,
name='create-vms',
state=states.RUNNING)
# Make 2 'create-vms' tasks successful.
self.engine.convey_task_result(WB_NAME, execution['id'],
tasks2[0]['id'],
states.SUCCESS, None)
self.engine.convey_task_result(WB_NAME, execution['id'],
tasks2[1]['id'],
states.SUCCESS, None)
tasks = db_api.tasks_get(WB_NAME, execution['id'])
self._assert_multiple_items(tasks, 2,
name='create-vms',
state=states.SUCCESS)
task = self._assert_single_item(tasks,
name='attach-volumes',
state=states.RUNNING)
# Make 'attach-volumes' task successful.
self.engine.convey_task_result(WB_NAME, execution['id'],
task['id'],
states.SUCCESS, None)
execution = db_api.execution_get(WB_NAME, execution['id'])
tasks = db_api.tasks_get(WB_NAME, execution['id'])
self.assertEqual(execution['state'], states.SUCCESS)
self._assert_multiple_items(tasks, 4, state=states.SUCCESS)
示例3: test_with_one_task
def test_with_one_task(self):
execution = self.engine.start_workflow_execution(WB_NAME, "build_name",
CONTEXT)
task = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])[0]
executor.ExecutorClient.handle_task\
.assert_called_once_with(auth_context.ctx(),
params={'output': 'Stormin Stanley'},
task_id=task['id'],
action_name='std.echo')
self.engine.convey_task_result(task['id'],
states.SUCCESS,
{'output': 'Stormin Stanley'})
task = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])[0]
execution = db_api.execution_get(execution['id'])
self.assertEqual(execution['state'], states.SUCCESS)
self.assertEqual(task['state'], states.SUCCESS)
self.assertEqual(
task['output'],
{'task': {'build_name': {'string': 'Stormin Stanley'}}})
示例4: test_require_flow
def test_require_flow(self):
execution = self.engine.start_workflow_execution(WB_NAME, "greet",
CONTEXT)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self.engine.convey_task_result(tasks[0]['id'],
states.SUCCESS, None)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self.assertIsNotNone(tasks)
self.assertEqual(2, len(tasks))
self.assertEqual(tasks[0]['state'], states.SUCCESS)
self.assertEqual(tasks[1]['state'], states.RUNNING)
self.assertEqual(states.RUNNING,
self.engine.get_workflow_execution_state(
WB_NAME, execution['id']))
self.engine.convey_task_result(tasks[1]['id'],
states.SUCCESS, None)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
execution = db_api.execution_get(execution['id'])
self.assertEqual(execution['state'], states.SUCCESS)
self.assertEqual(tasks[0]['state'], states.SUCCESS)
self.assertEqual(tasks[1]['state'], states.SUCCESS)
self.assertEqual(states.SUCCESS,
self.engine.get_workflow_execution_state(
WB_NAME, execution['id']))
示例5: test_direct_flow_on_success_finish
def test_direct_flow_on_success_finish(self):
# Start workflow.
execution = self.engine.start_workflow_execution(WB_NAME,
"start-task",
CONTEXT)
# Only the first task is RUNNING
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self.assertEqual(len(tasks), 1)
task = self._assert_single_item(tasks,
name='start-task',
state=states.RUNNING)
# Make 'start-task' successful.
self.engine.convey_task_result(task['id'],
states.SUCCESS, None)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self.assertEqual(len(tasks), 3)
self._assert_single_item(tasks,
name='start-task',
state=states.SUCCESS)
task1 = self._assert_single_item(tasks,
name='task-one',
state=states.RUNNING)
self._assert_single_item(tasks,
name='task-two',
state=states.RUNNING)
# Make 'task-one' tasks successful.
self.engine.convey_task_result(task1['id'],
states.SUCCESS, None)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
tasks_2 = self._assert_multiple_items(tasks, 2,
name='task-two',
state=states.RUNNING)
# Make both 'task-two' task successful.
self.engine.convey_task_result(tasks_2[0]['id'],
states.SUCCESS, None)
self.engine.convey_task_result(tasks_2[1]['id'],
states.SUCCESS, None)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
execution = db_api.execution_get(execution['id'])
self._assert_multiple_items(tasks, 4, state=states.SUCCESS)
self.assertEqual(execution['state'], states.SUCCESS)
示例6: test_engine_one_task
def test_engine_one_task(self):
execution = self.engine.start_workflow_execution(WB_NAME, "create-vms",
CONTEXT)
task = db_api.tasks_get(WB_NAME, execution['id'])[0]
self.engine.convey_task_result(WB_NAME, execution['id'], task['id'],
states.SUCCESS, None)
task = db_api.tasks_get(WB_NAME, execution['id'])[0]
execution = db_api.execution_get(WB_NAME, execution['id'])
self.assertEqual(execution['state'], states.SUCCESS)
self.assertEqual(task['state'], states.SUCCESS)
示例7: test_from_no_retry_to_retry_task
def test_from_no_retry_to_retry_task(self):
task_name_1 = 'no_retry_task'
task_name_2 = 'delay_retry_task'
workbook = _get_workbook(WB_NAME)
execution = self.engine.start_workflow_execution(WB_NAME,
task_name_1, None)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self._assert_single_item(tasks, name=task_name_1)
self.engine.convey_task_result(tasks[0]['id'], states.SUCCESS,
{'output': 'result'})
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self._assert_single_item(tasks, name=task_name_2)
task_spec = workbook.tasks.get(task_name_2)
retry_count, _, delay = task_spec.get_retry_parameters()
for x in xrange(0, retry_count):
self.engine.convey_task_result(tasks[1]['id'], states.ERROR,
{'output': 'result'})
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
# TODO(rakhmerov): It's not stable, need to avoid race condition.
self._assert_single_item(tasks, name=task_name_1)
self._assert_single_item(tasks, state=states.DELAYED)
eventlet.sleep(delay * 2)
# Convey final result outside the loop.
self.engine.convey_task_result(tasks[1]['id'], states.ERROR,
{'output': 'result'})
# TODO(rakhmerov): It's not stable, need to avoid race condition.
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self._assert_single_item(tasks, name=task_name_2)
self._assert_single_item(tasks, task_runtime_context={
'retry_no': retry_count - 1})
self._assert_single_item(tasks, state=states.ERROR)
示例8: test_transport
def test_transport(self):
"""Test if engine request traversed through the oslo.messaging
transport.
"""
execution = self.engine.start_workflow_execution(
WB_NAME, 'create-vms', CONTEXT)
task = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])[0]
# Check task execution state. There is no timeout mechanism in
# unittest. There is an example to add a custom timeout decorator that
# can wrap this test function in another process and then manage the
# process time. However, it seems more straightforward to keep the
# loop finite.
for i in range(0, 50):
db_task = db_api.task_get(task['id'])
# Ensure the request reached the executor and the action has ran.
if db_task['state'] != states.IDLE:
# We have to wait sometime due to time interval between set
# task state to RUNNING and invocation action.run()
time.sleep(0.1)
self.assertIn(db_task['state'],
[states.RUNNING, states.SUCCESS, states.ERROR])
return
time.sleep(0.1)
# Task is not being processed. Throw an exception here.
raise Exception('Timed out waiting for task to be processed.')
示例9: test_add_token_to_context
def test_add_token_to_context(self):
task_name = "create-vms"
cfg.CONF.pecan.auth_enable = True
try:
workbook = create_workbook("test_rest.yaml")
db_api.workbook_update(workbook['name'], {'trust_id': '123'})
execution = self.engine.start_workflow_execution(workbook['name'],
task_name, {})
tasks = db_api.tasks_get(workbook_name=workbook['name'],
execution_id=execution['id'])
task = self._assert_single_item(tasks, name=task_name)
openstack_context = task['in_context']['openstack']
self.assertIn("auth_token", openstack_context)
self.assertEqual(TOKEN, openstack_context['auth_token'])
self.assertEqual(USER_ID, openstack_context["user_id"])
self.engine.convey_task_result(task['id'], states.SUCCESS, {})
execution = db_api.execution_get(execution['id'])
self.assertEqual(states.SUCCESS, execution['state'])
finally:
cfg.CONF.pecan.auth_enable = False
示例10: get_all
def get_all(self, workbook_name, execution_id):
LOG.debug("Fetch tasks [workbook_name=%s, execution_id=%s]" %
(workbook_name, execution_id))
tasks = [Task.from_dict(values)
for values in db_api.tasks_get(workbook_name, execution_id)]
return Tasks(tasks=tasks)
示例11: test_direct_flow_on_error_finish
def test_direct_flow_on_error_finish(self):
# Start workflow.
execution = self.engine.start_workflow_execution(WB_NAME,
"start-task",
CONTEXT)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self.assertEqual(execution['state'], states.RUNNING)
start_task = self._assert_single_item(tasks,
name='start-task',
state=states.RUNNING)
# Make 'start-task' task fail.
self.engine.convey_task_result(start_task['id'],
states.ERROR, CONTEXT)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
self.assertEqual(len(tasks), 4)
task3 = self._assert_single_item(tasks,
name='task-three',
state=states.RUNNING)
task2 = self._assert_single_item(tasks,
name='task-two',
state=states.RUNNING)
task4 = self._assert_single_item(tasks,
name='task-four',
state=states.RUNNING)
# Make all running tasks successful.
self.engine.convey_task_result(task2['id'],
states.SUCCESS, None)
self.engine.convey_task_result(task3['id'],
states.SUCCESS, None)
self.engine.convey_task_result(task4['id'],
states.SUCCESS, None)
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
execution = db_api.execution_get(execution['id'])
self._assert_multiple_items(tasks, 3, state=states.SUCCESS)
self._assert_single_item(tasks, state=states.ERROR)
self.assertEqual(execution['state'], states.SUCCESS)
示例12: test_engine_sync_task
def test_engine_sync_task(self):
execution = ENGINE.start_workflow_execution(WB_NAME, "create-vm-nova",
CONTEXT)
task = db_api.tasks_get(WB_NAME, execution['id'])[0]
execution = db_api.execution_get(WB_NAME, execution['id'])
self.assertEqual(execution['state'], states.SUCCESS)
self.assertEqual(task['state'], states.SUCCESS)
示例13: test_with_one_sync_task
def test_with_one_sync_task(self):
execution = self.engine.start_workflow_execution(WB_NAME, "build_name",
CONTEXT)
task = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])[0]
execution = db_api.execution_get(execution['id'])
self.assertEqual(execution['state'], states.SUCCESS)
self.assertEqual(task['state'], states.SUCCESS)
示例14: test_engine_with_no_namespaces
def test_engine_with_no_namespaces(self):
execution = self.engine.start_workflow_execution(WB_NAME, "task1", {})
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
execution = db_api.execution_get(execution['id'])
self.assertIsNotNone(tasks)
self.assertEqual(1, len(tasks))
self.assertEqual(tasks[0]['state'], states.SUCCESS)
self.assertEqual(execution['state'], states.SUCCESS)
示例15: test_engine_task_std_action_with_namespaces
def test_engine_task_std_action_with_namespaces(self):
execution = self.engine.start_workflow_execution(WB_NAME,
"std_http_task", {})
tasks = db_api.tasks_get(workbook_name=WB_NAME,
execution_id=execution['id'])
execution = db_api.execution_get(execution['id'])
self.assertEqual(1, len(tasks))
self.assertEqual(states.SUCCESS, tasks[0]['state'])
self.assertEqual(states.SUCCESS, execution['state'])