From 7963809930538c5a4c68a78f6772ab1c28853833 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Thu, 3 Aug 2017 16:13:53 +0100 Subject: [PATCH] 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 (cherry picked from commit 28130bb862b33c57f5513fbe139eee3e4444fdac) --- .../tests/api/v2/test_action_executions.py | 5 +++-- .../tests/api/v2/test_executions.py | 22 +++++++++++++++++++ .../tests/resources/wf_v2.yaml | 21 ++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/mistral_tempest_tests/tests/api/v2/test_action_executions.py b/mistral_tempest_tests/tests/api/v2/test_action_executions.py index 40821f5..2b6d773 100644 --- a/mistral_tempest_tests/tests/api/v2/test_action_executions.py +++ b/mistral_tempest_tests/tests/api/v2/test_action_executions.py @@ -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) diff --git a/mistral_tempest_tests/tests/api/v2/test_executions.py b/mistral_tempest_tests/tests/api/v2/test_executions.py index 96abe43..b577ff2 100644 --- a/mistral_tempest_tests/tests/api/v2/test_executions.py +++ b/mistral_tempest_tests/tests/api/v2/test_executions.py @@ -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']) diff --git a/mistral_tempest_tests/tests/resources/wf_v2.yaml b/mistral_tempest_tests/tests/resources/wf_v2.yaml index 37bedbb..189c0fb 100755 --- a/mistral_tempest_tests/tests/resources/wf_v2.yaml +++ b/mistral_tempest_tests/tests/resources/wf_v2.yaml @@ -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