Filter workflow executions by creating task execution id

This will enable the mistral UI to go from task execution screen
to the workflow execution screen of the workflow execution created
by the task.

Change-Id: Ia2ac765a26acc8dcd27134f5f467cddef03fea95
Implements: blueprint filter-workflow-executions-by-creating-task-id
This commit is contained in:
Michal Gershenzon
2016-11-28 18:24:17 +00:00
committed by Renat Akhmerov
parent 0913abe2d1
commit 817a237267
6 changed files with 56 additions and 8 deletions

View File

@@ -0,0 +1,8 @@
---
version: '2.0'
wrapping_wf:
type: direct
tasks:
hello:
workflow: wf

View File

@@ -69,9 +69,13 @@ class ExecutionManager(base.ResourceManager):
return self._update('/executions/%s' % id, data)
def list(self, marker='', limit=None, sort_keys='', sort_dirs=''):
def list(self, task=None, marker='', limit=None, sort_keys='',
sort_dirs=''):
qparams = {}
if task:
qparams['task_execution_id'] = task
if marker:
qparams['marker'] = marker

View File

@@ -76,7 +76,12 @@ class List(base.MistralLister):
def get_parser(self, parsed_args):
parser = super(List, self).get_parser(parsed_args)
parser.add_argument(
'--task',
nargs='?',
help="Parent task execution ID associated with workflow "
"execution list.",
)
parser.add_argument(
'--marker',
type=str,
@@ -113,6 +118,7 @@ class List(base.MistralLister):
def _get_resources(self, parsed_args):
mistral_client = self.app.client_manager.workflow_engine
return mistral_client.executions.list(
task=parsed_args.task,
marker=parsed_args.marker,
limit=parsed_args.limit,
sort_keys=parsed_args.sort_keys,

View File

@@ -51,6 +51,10 @@ class MistralClientTestBase(base.MistralCLIAuth, base.MistralCLIAltAuth):
'functionaltests/resources/v2/wf_delay_v2.yaml', os.getcwd()
)
cls.wf_wrapping_wf = os.path.relpath(
'functionaltests/resources/v2/wf_wrapping_wf_v2.yaml', os.getcwd()
)
cls.act_def = os.path.relpath(
'functionaltests/resources/v2/action_v2.yaml', os.getcwd()
)

View File

@@ -501,14 +501,38 @@ class ExecutionCLITests(base_v2.MistralClientTestBase):
self.assertEqual([], ex_output)
def test_executions_list_with_task(self):
wrapping_wf = self.workflow_create(self.wf_wrapping_wf)
decoy = self.execution_create(wrapping_wf[-1]['Name'])
wrapping_wf_ex = self.execution_create(wrapping_wf[-1]['Name'])
wrapping_wf_ex_id = self.get_field_value(wrapping_wf_ex, 'ID')
self.assertIsNot(wrapping_wf_ex_id, self.get_field_value(decoy, 'ID'))
tasks = self.mistral_admin(
'task-list',
params=wrapping_wf_ex_id
)
wrapping_task_id = tasks[-1]['ID']
wf_execs = self.mistral_cli(
True,
'execution-list',
params="--task {}".format(wrapping_task_id)
)
self.assertEqual(1, len(wf_execs))
wf_exec = wf_execs[0]
self.assertEqual(wrapping_task_id, wf_exec['Task Execution ID'])
def test_executions_list_with_pagination(self):
wf_ex1 = self.mistral_admin(
'execution-create',
wf_ex1 = self.execution_create(
params='{0} -d "a"'.format(self.direct_wf['Name'])
)
wf_ex2 = self.mistral_admin(
'execution-create',
wf_ex2 = self.execution_create(
params='{0} -d "b"'.format(self.direct_wf['Name'])
)

View File

@@ -232,7 +232,8 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
limit=None,
marker='',
sort_dirs='asc',
sort_keys='created_at'
sort_keys='created_at',
task=None
)
self.call(
@@ -249,7 +250,8 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
limit=5,
marker='abc',
sort_dirs='id, Workflow',
sort_keys='desc'
sort_keys='desc',
task=None
)
def test_get(self):