Merge "Fixed 'workflow_name' key error"

This commit is contained in:
Jenkins 2016-02-24 10:27:54 +00:00 committed by Gerrit Code Review
commit 6d3d73af9a
3 changed files with 22 additions and 3 deletions

View File

@ -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 {}

View File

@ -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)})

View File

@ -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)