Fixed 'workflow_name' key error
when workflow execution is created by workflow_id 'workflow_name' key error was raised. Now 'workflow_name' is extracted from dictionary using get() function. Change-Id: I5a648742b2653818d3bc4d4025ce1fe0b73a2d24 Closes-bug: #1549047
This commit is contained in:
parent
bdd5edb531
commit
4878202c0e
@ -232,7 +232,7 @@ class ExecutionsController(rest.RestController):
|
||||
)
|
||||
|
||||
result = engine.start_workflow(
|
||||
exec_dict.get('workflow_id', exec_dict['workflow_name']),
|
||||
exec_dict.get('workflow_id', exec_dict.get('workflow_name')),
|
||||
exec_dict.get('input'),
|
||||
exec_dict.get('description', ''),
|
||||
**exec_dict.get('params') or {}
|
||||
|
@ -19,6 +19,7 @@ import time
|
||||
import mock
|
||||
import six
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from tempest import clients
|
||||
from tempest import config
|
||||
from tempest import test as test
|
||||
@ -164,8 +165,11 @@ class MistralClientV2(MistralClientBase):
|
||||
|
||||
return resp, json.loads(body)
|
||||
|
||||
def create_execution(self, wf_name, wf_input=None, params=None):
|
||||
body = {"workflow_name": "%s" % wf_name}
|
||||
def create_execution(self, identifier, wf_input=None, params=None):
|
||||
if uuidutils.is_uuid_like(identifier):
|
||||
body = {"workflow_id": "%s" % identifier}
|
||||
else:
|
||||
body = {"workflow_name": "%s" % identifier}
|
||||
|
||||
if wf_input:
|
||||
body.update({'input': json.dumps(wf_input)})
|
||||
|
@ -408,6 +408,7 @@ class ExecutionTestsV2(base.TestCase):
|
||||
|
||||
self.direct_wf_name = 'wf'
|
||||
self.direct_wf2_name = 'wf2'
|
||||
self.direct_wf_id = body['workflows'][0]['id']
|
||||
reverse_wfs = [wf for wf in body['workflows'] if wf['name'] == 'wf1']
|
||||
self.reverse_wf = reverse_wfs[0]
|
||||
|
||||
@ -516,6 +517,20 @@ class ExecutionTestsV2(base.TestCase):
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual('SUCCESS', body['state'])
|
||||
|
||||
@test.attr(type='sanity')
|
||||
def test_create_execution_by_wf_id(self):
|
||||
resp, body = self.client.create_execution(self.direct_wf_id)
|
||||
exec_id = body['id']
|
||||
self.assertEqual(201, resp.status)
|
||||
self.assertEqual(self.direct_wf_id, body['workflow_id'])
|
||||
self.assertEqual('RUNNING', body['state'])
|
||||
|
||||
resp, body = self.client.get_list_obj('executions')
|
||||
self.assertIn(
|
||||
exec_id,
|
||||
[ex_id['id'] for ex_id in body['executions']]
|
||||
)
|
||||
|
||||
@test.attr(type='sanity')
|
||||
def test_get_execution(self):
|
||||
_, execution = self.client.create_execution(self.direct_wf_name)
|
||||
|
Loading…
Reference in New Issue
Block a user