Merge "Fix event-triggers workflow namespace"

This commit is contained in:
Jenkins 2017-08-09 07:45:22 +00:00 committed by Gerrit Code Review
commit bb30b1b51a
5 changed files with 13 additions and 4 deletions

View File

@ -497,6 +497,7 @@ class EventTrigger(mb.MistralSecureModelBase):
sa.String(36),
sa.ForeignKey(WorkflowDefinition.id)
)
workflow = relationship('WorkflowDefinition', lazy='joined')
workflow_params = sa.Column(st.JsonDictType())
workflow_input = sa.Column(st.JsonDictType())

View File

@ -220,6 +220,7 @@ class DefaultEventEngine(base.EventEngine):
self.exchange_topic_events_map[exchange_topic].add(trigger.event)
trigger_info = trigger.to_dict()
trigger_info['workflow_namespace'] = trigger.workflow.namespace
self.event_triggers_map[trigger.event].append(trigger_info)
for (ex_t, events) in self.exchange_topic_events_map.items():
@ -253,6 +254,7 @@ class DefaultEventEngine(base.EventEngine):
try:
self.engine_client.start_workflow(
t['workflow_id'],
t['workflow_namespace'],
t['workflow_input'],
description=json.dumps(description),
**workflow_params

View File

@ -190,8 +190,11 @@ def create_event_trigger(name, exchange, topic, event, workflow_id,
# NOTE(kong): Send RPC message within the db transaction, rollback if
# any error occurs.
trig_dict = trig.to_dict()
trig_dict['workflow_namespace'] = wf_def.namespace
rpc.get_event_engine_client().create_event_trigger(
trig.to_dict(),
trig_dict,
events
)

View File

@ -100,8 +100,11 @@ class TestEventTriggerController(base.APITest):
self.assertEqual(201, resp.status_int)
self.assertEqual(1, client.create_event_trigger.call_count)
trigger_db = TRIGGER_DB.to_dict()
trigger_db['workflow_namespace'] = None
self.assertDictEqual(
TRIGGER_DB.to_dict(),
trigger_db,
client.create_event_trigger.call_args[0][0]
)
self.assertListEqual(

View File

@ -140,7 +140,7 @@ class EventEngineTest(base.DbTestCase):
args, kwargs = client_mock.start_workflow.call_args
self.assertEqual((EVENT_TRIGGER['workflow_id'], {}), args)
self.assertEqual((EVENT_TRIGGER['workflow_id'], '', {}), args)
self.assertDictEqual(
{
'service': 'fake_publisher',
@ -181,7 +181,7 @@ class EventEngineTest(base.DbTestCase):
args, kwargs = client_mock.start_workflow.call_args
self.assertEqual((EVENT_TRIGGER['workflow_id'], {}), args)
self.assertEqual((EVENT_TRIGGER['workflow_id'], '', {}), args)
self.assertDictEqual(
{
'service': 'fake_publisher',