Testing timeout policy defined in "task-defaults" for reverse workflow
* Added a unit test * Added asynchronous version of no-op action (async_noop) Change-Id: Ia535d80fa7702f907f8df6e522d665c0bf0f263d Closes-Bug: #1401391
This commit is contained in:
parent
34793ef085
commit
5aa2930c5a
@ -69,6 +69,12 @@ class NoOpAction(base.Action):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class AsyncNoOpAction(NoOpAction):
|
||||||
|
"""Asynchronous no-operation action."""
|
||||||
|
def is_sync(self):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class FailAction(base.Action):
|
class FailAction(base.Action):
|
||||||
"""'Always fail' action.
|
"""'Always fail' action.
|
||||||
|
|
||||||
|
@ -98,6 +98,27 @@ wf:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
REVERSE_WF_TIMEOUT = """
|
||||||
|
---
|
||||||
|
version: '2.0'
|
||||||
|
|
||||||
|
wf:
|
||||||
|
type: reverse
|
||||||
|
|
||||||
|
task-defaults:
|
||||||
|
policies:
|
||||||
|
timeout: 1
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
task1:
|
||||||
|
action: std.async_noop
|
||||||
|
|
||||||
|
task2:
|
||||||
|
action: std.echo output=2
|
||||||
|
requires: [task1]
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TaskDefaultsReverseWorkflowEngineTest(base.EngineTestCase):
|
class TaskDefaultsReverseWorkflowEngineTest(base.EngineTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TaskDefaultsReverseWorkflowEngineTest, self).setUp()
|
super(TaskDefaultsReverseWorkflowEngineTest, self).setUp()
|
||||||
@ -130,3 +151,20 @@ class TaskDefaultsReverseWorkflowEngineTest(base.EngineTestCase):
|
|||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
task1.runtime_context['retry_task_policy']['retry_no'] > 0
|
task1.runtime_context['retry_task_policy']['retry_no'] > 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_task_defaults_timeout_policy(self):
|
||||||
|
wf_service.create_workflows(REVERSE_WF_TIMEOUT)
|
||||||
|
|
||||||
|
# Start workflow.
|
||||||
|
exec_db = self.engine.start_workflow('wf', {}, task_name='task2')
|
||||||
|
|
||||||
|
self._await(lambda: self.is_execution_error(exec_db.id))
|
||||||
|
|
||||||
|
# Note: We need to reread execution to access related tasks.
|
||||||
|
exec_db = db_api.get_execution(exec_db.id)
|
||||||
|
|
||||||
|
tasks = exec_db.tasks
|
||||||
|
|
||||||
|
self.assertEqual(1, len(tasks))
|
||||||
|
|
||||||
|
self._assert_single_item(tasks, name='task1', state=states.ERROR)
|
||||||
|
@ -40,6 +40,7 @@ mistral.executor.drivers =
|
|||||||
default = mistral.engine.drivers.default.executor:DefaultExecutor
|
default = mistral.engine.drivers.default.executor:DefaultExecutor
|
||||||
|
|
||||||
mistral.actions =
|
mistral.actions =
|
||||||
|
std.async_noop = mistral.actions.std_actions:AsyncNoOpAction
|
||||||
std.noop = mistral.actions.std_actions:NoOpAction
|
std.noop = mistral.actions.std_actions:NoOpAction
|
||||||
std.fail = mistral.actions.std_actions:FailAction
|
std.fail = mistral.actions.std_actions:FailAction
|
||||||
std.echo = mistral.actions.std_actions:EchoAction
|
std.echo = mistral.actions.std_actions:EchoAction
|
||||||
|
Loading…
Reference in New Issue
Block a user