Allow filtering executions by their root_execution_id

With this filter, it will be possible to find all the workflow
executions started by a root execution.

Implements: blueprint mistral-root-execution-id
Change-Id: Ie18493c8f59f5d77107f0adf5db491b0db05cee2
This commit is contained in:
Dougal Matthews 2017-08-03 16:13:53 +01:00
parent a944cdb98e
commit 28130bb862
5 changed files with 60 additions and 9 deletions

View File

@ -248,15 +248,16 @@ class ExecutionsController(rest.RestController):
@wsme_pecan.wsexpose(resources.Executions, types.uuid, int,
types.uniquelist, types.list, types.uniquelist,
wtypes.text, types.uuid, wtypes.text, types.jsontype,
types.uuid, STATE_TYPES, wtypes.text, types.jsontype,
types.jsontype, wtypes.text, wtypes.text, bool,
types.uuid, bool)
types.uuid, types.uuid, STATE_TYPES, wtypes.text,
types.jsontype, types.jsontype, wtypes.text,
wtypes.text, bool, types.uuid, bool)
def get_all(self, marker=None, limit=None, sort_keys='created_at',
sort_dirs='asc', fields='', workflow_name=None,
workflow_id=None, description=None, params=None,
task_execution_id=None, state=None, state_info=None,
input=None, output=None, created_at=None, updated_at=None,
include_output=None, project_id=None, all_projects=False):
task_execution_id=None, root_execution_id=None, state=None,
state_info=None, input=None, output=None, created_at=None,
updated_at=None, include_output=None, project_id=None,
all_projects=False):
"""Return all Executions.
:param marker: Optional. Pagination marker for large data sets.
@ -282,6 +283,8 @@ class ExecutionsController(rest.RestController):
:param params: Optional. Keep only resources with specific parameters.
:param task_execution_id: Optional. Keep only resources with a
specific task execution ID.
:param root_execution_id: Optional. Keep only resources with a
specific root execution ID.
:param state: Optional. Keep only resources with a specific state.
:param state_info: Optional. Keep only resources with specific
state information.
@ -315,7 +318,8 @@ class ExecutionsController(rest.RestController):
output=output,
updated_at=updated_at,
description=description,
project_id=project_id
project_id=project_id,
root_execution_id=root_execution_id,
)
LOG.info(

View File

@ -241,6 +241,9 @@ class Execution(resource.Resource):
task_execution_id = wtypes.text
"reference to the parent task execution"
root_execution_id = wtypes.text
"reference to the root execution"
state = wtypes.text
"state can be one of: IDLE, RUNNING, SUCCESS, ERROR, PAUSED"

View File

@ -232,13 +232,14 @@ class ActionExecutionTestsV2(base.TestCase):
def test_action_execution_of_workflow_within_namespace(self):
resp, body = self.client.create_workflow('wf_v2.yaml', namespace='abc')
wf_name = body['workflows'][0]['name']
wf_name = "wf"
wf_namespace = body['workflows'][0]['namespace']
self.assertEqual(201, resp.status)
resp, body = self.client.create_execution(
resp, execution = self.client.create_execution(
wf_name,
wf_namespace=wf_namespace
)
self.client.wait_execution_success(execution)
self.assertEqual(201, resp.status)
resp, body = self.client.get_list_obj('tasks')
self.assertEqual(200, resp.status)

View File

@ -33,6 +33,7 @@ class ExecutionTestsV2(base.TestCase):
self.direct_wf_name = 'wf'
self.direct_wf2_name = 'wf2'
self.sub_wf_name = 'subwf1'
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]
@ -416,3 +417,24 @@ class ExecutionTestsV2(base.TestCase):
self.assertEqual('lowest_level_wf', action_execution['workflow_name'])
self.assertEqual(namespace, action_execution['workflow_namespace'])
@decorators.attr(type='sanity')
@decorators.idempotent_id('2baa25c5-0b65-4fbe-8d90-2c6599831b6b')
def test_root_execution_id(self):
resp, execution = self.client.create_execution(self.sub_wf_name)
self.assertEqual(201, resp.status)
self.assertEqual('RUNNING', execution['state'])
self.client.wait_execution_success(execution)
resp, body = self.client.get_list_obj(
'executions?root_execution_id={}'.format(execution['id']))
self.assertEqual(200, resp.status)
self.assertNotEmpty(body['executions'])
self.assertEqual(2, len(body['executions']))
for exc in body['executions']:
self.assertEqual(exc['root_execution_id'], execution['id'])

View File

@ -32,3 +32,24 @@ wf2:
tasks:
hello:
action: std.echo output="Doe"
subwf1:
type: direct
tasks:
task1:
workflow: subwf2
subwf2:
type: direct
tasks:
task1:
workflow: subwf3
subwf3:
type: direct
tasks:
task1:
action: std.noop