Merge "Fix adhoc action lookup"

This commit is contained in:
Zuul 2019-05-31 08:10:03 +00:00 committed by Gerrit Code Review
commit e25da33607
2 changed files with 21 additions and 21 deletions

View File

@ -21,7 +21,6 @@ from mistral.db.v2.sqlalchemy import models
from mistral.engine import actions
from mistral.engine import task_handler
from mistral import exceptions as exc
from mistral.lang import parser as spec_parser
LOG = logging.getLogger(__name__)
@ -85,32 +84,14 @@ def _build_action(action_ex):
return actions.WorkflowAction(wf_name=action_ex.name,
action_ex=action_ex)
wf_name = None
wf_spec_name = None
if action_ex.workflow_name:
wf_name = action_ex.workflow_name
wf_spec = spec_parser.get_workflow_spec_by_execution_id(
action_ex.task_execution.workflow_execution_id
)
wf_spec_name = wf_spec.get_name()
adhoc_action_name = action_ex.runtime_context.get('adhoc_action_name')
if adhoc_action_name:
action_def = actions.resolve_action_definition(
adhoc_action_name,
wf_name,
wf_spec_name
)
action_def = actions.resolve_action_definition(adhoc_action_name)
return actions.AdHocAction(action_def, action_ex=action_ex)
action_def = actions.resolve_action_definition(
action_ex.name,
wf_name,
wf_spec_name
)
action_def = actions.resolve_action_definition(action_ex.name)
return actions.PythonAction(action_def, action_ex=action_ex)

View File

@ -304,3 +304,22 @@ class AdhocActionsTest(base.EngineTestCase):
wf_ex = self.engine.start_workflow('my_wb1.my_wf')
self.await_workflow_running(wf_ex.id)
def test_adhoc_action_runtime_context_name(self):
wf_ex = self.engine.start_workflow(
'my_wb.wf4',
wf_input={'str1': 'a'},
env={'foo': 'bar'}
)
self.await_workflow_success(wf_ex.id)
with db_api.transaction():
action_execs = db_api.get_action_executions(name='std.echo')
self.assertEqual(1, len(action_execs))
action_name = action_execs[0].runtime_context.get(
'adhoc_action_name'
)
self.assertEqual('my_wb.test_env', action_name)