Merge "Add "root_execution" mapped property to WorkflowExecution model"

This commit is contained in:
Zuul 2019-03-22 13:23:37 +00:00 committed by Gerrit Code Review
commit 3116a15ed2
3 changed files with 13 additions and 7 deletions

View File

@ -353,6 +353,13 @@ WorkflowExecution.root_execution_id = sa.Column(
nullable=True
)
WorkflowExecution.root_execution = relationship(
WorkflowExecution,
remote_side=WorkflowExecution.id,
lazy='select'
)
# Many-to-one for 'TaskExecution' and 'WorkflowExecution'.
TaskExecution.workflow_execution_id = sa.Column(

View File

@ -453,9 +453,11 @@ class SubworkflowsTest(base.EngineTestCase):
wf2_ex = db_api.get_workflow_execution(wf2_ex.id)
wf3_ex = db_api.get_workflow_execution(wf3_ex.id)
self.assertIsNone(wf1_ex.root_execution_id, None)
self.assertEqual(wf2_ex.root_execution_id, wf1_ex.id)
self.assertEqual(wf3_ex.root_execution_id, wf1_ex.id)
self.assertIsNone(wf1_ex.root_execution_id, None)
self.assertEqual(wf2_ex.root_execution_id, wf1_ex.id)
self.assertEqual(wf2_ex.root_execution, wf1_ex)
self.assertEqual(wf3_ex.root_execution_id, wf1_ex.id)
self.assertEqual(wf3_ex.root_execution, wf1_ex)
def test_cascade_delete(self):
wf_text = """

View File

@ -17,7 +17,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from mistral import context as auth_ctx
from mistral.db.v2 import api as db_api
from mistral.db.v2.sqlalchemy import models
from mistral import exceptions as exc
from mistral import expressions as expr
@ -333,9 +332,7 @@ def get_workflow_environment_dict(wf_ex):
return {}
if wf_ex.root_execution_id:
return get_workflow_environment_dict(
db_api.get_workflow_execution(wf_ex.root_execution_id)
)
return get_workflow_environment_dict(wf_ex.root_execution)
env_dict = wf_ex.params['env'] if 'env' in wf_ex.params else {}