Remove output from list action executions API
output field should be returned only when getting one action execution Change-Id: I9913f4893b3eaf30faca1a747eeeda493dbc0fb2 Closes-Bug: #1610817
This commit is contained in:
parent
0c4fa17425
commit
5fef53c4cd
|
@ -75,6 +75,9 @@ class MistralClientV2(base.MistralClientBase):
|
|||
|
||||
return resp, json.loads(body)
|
||||
|
||||
def get_action_execution(self, action_execution_id):
|
||||
return self.get('action_executions/%s' % action_execution_id)
|
||||
|
||||
def create_execution(self, identifier, wf_input=None, params=None):
|
||||
if uuidutils.is_uuid_like(identifier):
|
||||
body = {"workflow_id": "%s" % identifier}
|
||||
|
@ -130,9 +133,11 @@ class MistralClientV2(base.MistralClientBase):
|
|||
return [t for t in all_tasks if t['workflow_name'] == wf_name]
|
||||
|
||||
def create_action_execution(self, request_body, extra_headers={}):
|
||||
resp, body = self.post_json('action_executions',
|
||||
request_body,
|
||||
extra_headers)
|
||||
resp, body = self.post_json(
|
||||
'action_executions',
|
||||
request_body,
|
||||
extra_headers
|
||||
)
|
||||
|
||||
params = json.loads(request_body.get('params', '{}'))
|
||||
if params.get('save_result', False):
|
||||
|
|
|
@ -28,6 +28,17 @@ LOG = logging.getLogger(__name__)
|
|||
class ActionExecutionTestsV2(base.TestCase):
|
||||
_service = 'workflowv2'
|
||||
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(ActionExecutionTestsV2, cls).resource_setup()
|
||||
|
||||
cls.client.create_action_execution(
|
||||
{
|
||||
'name': 'std.echo',
|
||||
'input': '{"output": "Hello, Mistral!"}'
|
||||
}
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def resource_cleanup(cls):
|
||||
for action_ex in cls.client.action_executions:
|
||||
|
@ -58,6 +69,60 @@ class ActionExecutionTestsV2(base.TestCase):
|
|||
output
|
||||
)
|
||||
|
||||
@test.attr(type='sanity')
|
||||
def test_list_action_executions(self):
|
||||
resp, body = self.client.get_list_obj('action_executions')
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
|
||||
@test.attr(type='sanity')
|
||||
def test_output_appear_in_response_only_when_needed(self):
|
||||
resp, body = self.client.get_list_obj('action_executions')
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
action_execution = body['action_executions'][0]
|
||||
self.assertNotIn("output", action_execution)
|
||||
|
||||
resp, body = self.client.get_list_obj(
|
||||
'action_executions?include_output=True'
|
||||
)
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
action_execution = body['action_executions'][0]
|
||||
self.assertIn("output", action_execution)
|
||||
|
||||
resp, body = self.client.get_action_execution(action_execution['id'])
|
||||
self.assertIn("output", body)
|
||||
|
||||
# Test when passing task execution ID
|
||||
|
||||
resp, body = self.client.create_workflow('wf_v2.yaml')
|
||||
wf_name = body['workflows'][0]['name']
|
||||
self.assertEqual(201, resp.status)
|
||||
resp, body = self.client.create_execution(wf_name)
|
||||
self.assertEqual(201, resp.status)
|
||||
resp, body = self.client.get_list_obj('tasks')
|
||||
self.assertEqual(200, resp.status)
|
||||
task_id = body['tasks'][0]['id']
|
||||
|
||||
resp, body = self.client.get_list_obj(
|
||||
'action_executions?include_output=true&task_execution_id=%s' %
|
||||
task_id
|
||||
)
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
action_execution = body['action_executions'][0]
|
||||
self.assertIn("output", action_execution)
|
||||
|
||||
resp, body = self.client.get_list_obj(
|
||||
'action_executions?&task_execution_id=%s' %
|
||||
task_id
|
||||
)
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
action_execution = body['action_executions'][0]
|
||||
self.assertNotIn("output", action_execution)
|
||||
|
||||
@test.attr(type='sanity')
|
||||
def test_run_action_std_http(self):
|
||||
resp, body = self.client.create_action_execution(
|
||||
|
|
|
@ -28,6 +28,7 @@ class TasksTestsV2(base.TestCase):
|
|||
_, body = self.client.create_workflow('wf_v2.yaml')
|
||||
self.direct_wf_name = body['workflows'][0]['name']
|
||||
_, execution = self.client.create_execution(self.direct_wf_name)
|
||||
self.execution_id = execution['id']
|
||||
|
||||
def tearDown(self):
|
||||
for wf in self.client.workflows:
|
||||
|
@ -56,6 +57,17 @@ class TasksTestsV2(base.TestCase):
|
|||
self.direct_wf_name, body['tasks'][-1]['workflow_name']
|
||||
)
|
||||
|
||||
@test.attr(type='sanity')
|
||||
def test_get_tasks_of_execution(self):
|
||||
resp, body = self.client.get_list_obj(
|
||||
'tasks?workflow_execution_id=%s' % self.execution_id
|
||||
)
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual(
|
||||
self.direct_wf_name, body['tasks'][-1]['workflow_name']
|
||||
)
|
||||
|
||||
|
||||
class TaskTypesTestsV2(base.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue