Browse Source

Filter messages not from waiting execution

The convention is to use the same queue name ("tripleo") for all
workflows. This can lead to messages showing from other tripleoclient
triggered workflows showing up during message polling if multiple
workflows are running at the same time.

This patch adds a check that will filter out any messages that do not
belong to the execution that is being waited on by comparing the
execution id with the root_execution_id returned in the execution
payload.

Depends-On: Icbe80c338d69efc6ce8fceb0f73f833bec588536
Change-Id: Ie6473d6a1044cdf76552d62645b4d63da2df9398
Related-Bug: #1794277
(cherry picked from commit 339c1f334c)
tags/9.3.1
James Slagle 11 months ago
parent
commit
074bb6e3a0

+ 4
- 2
tripleoclient/tests/test_overcloud_credentials.py View File

@@ -45,7 +45,8 @@ class TestOvercloudCredentials(test_plugin.TestPluginV1):
45 45
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
46 46
 
47 47
         with mock.patch("tripleoclient.utils.open", create=True) as m:
48
-            self.cmd.take_action(parsed_args)
48
+            with mock.patch("json.loads"):
49
+                self.cmd.take_action(parsed_args)
49 50
 
50 51
         self.assertIn(mock.call('./overcloudrc', 'w'), m.call_args_list)
51 52
         mock_chmod.assert_has_calls([
@@ -69,7 +70,8 @@ class TestOvercloudCredentials(test_plugin.TestPluginV1):
69 70
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
70 71
 
71 72
         with mock.patch("tripleoclient.utils.open", create=True) as m:
72
-            self.cmd.take_action(parsed_args)
73
+            with mock.patch("json.loads"):
74
+                self.cmd.take_action(parsed_args)
73 75
 
74 76
         path = "{}/overcloudrc".format(temp)
75 77
 

+ 4
- 1
tripleoclient/tests/v1/overcloud_ceph_upgrade/fakes.py View File

@@ -48,7 +48,10 @@ class TestCephUpgrade(utils.TestCommand):
48 48
         self.app.client_manager.baremetal = mock.Mock()
49 49
         self.app.client_manager.orchestration = mock.Mock()
50 50
         self.app.client_manager.tripleoclient = FakeClientWrapper()
51
-        self.app.client_manager.workflow_engine = mock.Mock()
51
+        workflow = execution = mock.Mock()
52
+        execution.id = "IDID"
53
+        workflow.executions.create.return_value = execution
54
+        self.app.client_manager.workflow_engine = workflow
52 55
 
53 56
 
54 57
 class TestCephUpgradeConverge(utils.TestCommand):

+ 4
- 1
tripleoclient/tests/v1/overcloud_deploy/fakes.py View File

@@ -140,5 +140,8 @@ class TestDeployOvercloud(utils.TestCommand):
140 140
         self.app.client_manager.image = mock.Mock()
141 141
         self.app.client_manager.network = mock.Mock()
142 142
         self.app.client_manager.orchestration = mock.Mock()
143
-        self.app.client_manager.workflow_engine = mock.Mock()
143
+        workflow = execution = mock.Mock()
144
+        execution.id = "IDID"
145
+        workflow.executions.create.return_value = execution
146
+        self.app.client_manager.workflow_engine = workflow
144 147
         self.app.client_manager.tripleoclient = FakeClientWrapper()

+ 8
- 2
tripleoclient/tests/v1/overcloud_ffwd_upgrade/fakes.py View File

@@ -48,7 +48,10 @@ class TestFFWDUpgradePrepare(utils.TestCommand):
48 48
         self.app.client_manager.baremetal = mock.Mock()
49 49
         self.app.client_manager.orchestration = mock.Mock()
50 50
         self.app.client_manager.tripleoclient = FakeClientWrapper()
51
-        self.app.client_manager.workflow_engine = mock.Mock()
51
+        workflow = execution = mock.Mock()
52
+        execution.id = "IDID"
53
+        workflow.executions.create.return_value = execution
54
+        self.app.client_manager.workflow_engine = workflow
52 55
 
53 56
 
54 57
 class TestFFWDUpgradeRun(utils.TestCommand):
@@ -70,4 +73,7 @@ class TestFFWDUpgradeConverge(utils.TestCommand):
70 73
         self.app.client_manager.baremetal = mock.Mock()
71 74
         self.app.client_manager.orchestration = mock.Mock()
72 75
         self.app.client_manager.tripleoclient = FakeClientWrapper()
73
-        self.app.client_manager.workflow_engine = mock.Mock()
76
+        workflow = execution = mock.Mock()
77
+        execution.id = "IDID"
78
+        workflow.executions.create.return_value = execution
79
+        self.app.client_manager.workflow_engine = workflow

+ 43
- 8
tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py View File

@@ -13,6 +13,7 @@
13 13
 #   under the License.
14 14
 #
15 15
 
16
+import collections
16 17
 import copy
17 18
 import json
18 19
 import mock
@@ -46,6 +47,9 @@ class TestDeleteNode(fakes.TestDeleteNode):
46 47
         self.workflow = self.app.client_manager.workflow_engine
47 48
         self.stack_name = self.app.client_manager.orchestration.stacks.get
48 49
         self.stack_name.return_value = mock.Mock(stack_name="overcloud")
50
+        execution = mock.Mock()
51
+        execution.id = "IDID"
52
+        self.workflow.executions.create.return_value = execution
49 53
 
50 54
     # TODO(someone): This test does not pass with autospec=True, it should
51 55
     # probably be fixed so that it can pass with that.
@@ -132,6 +136,7 @@ class TestDeleteNode(fakes.TestDeleteNode):
132 136
 
133 137
         self.websocket.wait_for_messages.return_value = iter([{
134 138
             "status": "FAILED",
139
+            "execution": {"id": "IDID"},
135 140
             "message": """Failed to run action ERROR: Couldn't find \
136 141
                 following instances in stack overcloud: wrong_instance"""
137 142
         }])
@@ -155,6 +160,9 @@ class TestProvideNode(fakes.TestOvercloudNode):
155 160
         super(TestProvideNode, self).setUp()
156 161
 
157 162
         self.workflow = self.app.client_manager.workflow_engine
163
+        execution = mock.Mock()
164
+        execution.id = "IDID"
165
+        self.workflow.executions.create.return_value = execution
158 166
         client = self.app.client_manager.tripleoclient
159 167
         self.websocket = client.messaging_websocket()
160 168
 
@@ -163,7 +171,8 @@ class TestProvideNode(fakes.TestOvercloudNode):
163 171
 
164 172
         self.websocket.wait_for_messages.return_value = iter([{
165 173
             "status": "SUCCESS",
166
-            "message": "Success"
174
+            "message": "Success",
175
+            "execution": {"id": "IDID"}
167 176
         }])
168 177
 
169 178
     def test_provide_all_manageable_nodes(self):
@@ -227,6 +236,9 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
227 236
         super(TestIntrospectNode, self).setUp()
228 237
 
229 238
         self.workflow = self.app.client_manager.workflow_engine
239
+        execution = mock.Mock()
240
+        execution.id = "IDID"
241
+        self.workflow.executions.create.return_value = execution
230 242
         client = self.app.client_manager.tripleoclient
231 243
         self.websocket = client.messaging_websocket()
232 244
 
@@ -237,7 +249,8 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
237 249
         self.websocket.wait_for_messages.return_value = iter([{
238 250
             "status": "SUCCESS",
239 251
             "message": "Success",
240
-            "introspected_nodes": {}
252
+            "introspected_nodes": {},
253
+            "execution": {"id": "IDID"}
241 254
         }] * 2)
242 255
 
243 256
         self.cmd.take_action(parsed_args)
@@ -261,6 +274,7 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
261 274
         self.websocket.wait_for_messages.return_value = [{
262 275
             "status": "SUCCESS",
263 276
             "message": "Success",
277
+            "execution": {"id": "IDID"},
264 278
         }]
265 279
 
266 280
         self.cmd.take_action(parsed_args)
@@ -347,7 +361,6 @@ class TestImportNode(fakes.TestOvercloudNode):
347 361
                 "00:0b:d0:69:7e:58"
348 362
             ]
349 363
         }]
350
-
351 364
         self.json_file = tempfile.NamedTemporaryFile(
352 365
             mode='w', delete=False, suffix='.json')
353 366
         json.dump(self.nodes_list, self.json_file)
@@ -355,12 +368,23 @@ class TestImportNode(fakes.TestOvercloudNode):
355 368
         self.addCleanup(os.unlink, self.json_file.name)
356 369
 
357 370
         self.workflow = self.app.client_manager.workflow_engine
371
+        execution = mock.Mock()
372
+        execution.id = "IDID"
373
+        self.workflow.executions.create.return_value = execution
358 374
         client = self.app.client_manager.tripleoclient
359 375
         self.websocket = client.messaging_websocket()
360 376
 
361 377
         # Get the command object to test
362 378
         self.cmd = overcloud_node.ImportNode(self.app, None)
363 379
 
380
+        image = collections.namedtuple('image', ['id', 'name'])
381
+        self.app.client_manager.image = mock.Mock()
382
+        self.app.client_manager.image.images.list.return_value = [
383
+            image(id=1, name='bm-deploy-kernel'),
384
+            image(id=2, name='bm-deploy-ramdisk'),
385
+            image(id=3, name='overcloud-full'),
386
+        ]
387
+
364 388
     def _check_workflow_call(self, parsed_args, introspect=False,
365 389
                              provide=False, local=True, no_deploy_image=False):
366 390
         self.websocket.wait_for_messages.return_value = [{
@@ -368,7 +392,8 @@ class TestImportNode(fakes.TestOvercloudNode):
368 392
             "message": "Success",
369 393
             "registered_nodes": [{
370 394
                 "uuid": "MOCK_NODE_UUID"
371
-            }]
395
+            }],
396
+            "execution": {"id": "IDID"}
372 397
         }]
373 398
 
374 399
         self.cmd.take_action(parsed_args)
@@ -459,11 +484,15 @@ class TestConfigureNode(fakes.TestOvercloudNode):
459 484
         super(TestConfigureNode, self).setUp()
460 485
 
461 486
         self.workflow = self.app.client_manager.workflow_engine
487
+        execution = mock.Mock()
488
+        execution.id = "IDID"
489
+        self.workflow.executions.create.return_value = execution
462 490
         client = self.app.client_manager.tripleoclient
463 491
         self.websocket = client.messaging_websocket()
464 492
         self.websocket.wait_for_messages.return_value = iter([{
465 493
             "status": "SUCCESS",
466
-            "message": ""
494
+            "message": "",
495
+            "execution": {"id": "IDID"}
467 496
         }])
468 497
 
469 498
         # Get the command object to test
@@ -490,7 +519,8 @@ class TestConfigureNode(fakes.TestOvercloudNode):
490 519
     def test_failed_to_configure_all_manageable_nodes(self):
491 520
         self.websocket.wait_for_messages.return_value = iter([{
492 521
             "status": "FAILED",
493
-            "message": "Test failure."
522
+            "message": "Test failure.",
523
+            "execution": {"id": "IDID"}
494 524
         }])
495 525
 
496 526
         parsed_args = self.check_parser(self.cmd, ['--all-manageable'], [])
@@ -518,7 +548,8 @@ class TestConfigureNode(fakes.TestOvercloudNode):
518 548
     def test_failed_to_configure_specified_nodes(self):
519 549
         self.websocket.wait_for_messages.return_value = iter([{
520 550
             "status": "FAILED",
521
-            "message": "Test failure."
551
+            "message": "Test failure.",
552
+            "execution": {"id": "IDID"}
522 553
         }])
523 554
 
524 555
         parsed_args = self.check_parser(self.cmd, ['node_uuid1'], [])
@@ -631,6 +662,9 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
631 662
         super(TestDiscoverNode, self).setUp()
632 663
 
633 664
         self.workflow = self.app.client_manager.workflow_engine
665
+        execution = mock.Mock()
666
+        execution.id = "IDID"
667
+        self.workflow.executions.create.return_value = execution
634 668
         client = self.app.client_manager.tripleoclient
635 669
         self.websocket = client.messaging_websocket()
636 670
 
@@ -641,7 +675,8 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
641 675
             "message": "Success",
642 676
             "registered_nodes": [{
643 677
                 "uuid": "MOCK_NODE_UUID"
644
-            }]
678
+            }],
679
+            "execution": {"id": "IDID"}
645 680
         }]
646 681
 
647 682
     def test_with_ip_range(self):

+ 4
- 1
tripleoclient/tests/v1/overcloud_update/fakes.py View File

@@ -48,7 +48,10 @@ class TestOvercloudUpdatePrepare(utils.TestCommand):
48 48
         self.app.client_manager.baremetal = mock.Mock()
49 49
         self.app.client_manager.orchestration = mock.Mock()
50 50
         self.app.client_manager.tripleoclient = FakeClientWrapper()
51
-        self.app.client_manager.workflow_engine = mock.Mock()
51
+        workflow = execution = mock.Mock()
52
+        execution.id = "IDID"
53
+        workflow.executions.create.return_value = execution
54
+        self.app.client_manager.workflow_engine = workflow
52 55
 
53 56
 
54 57
 class TestOvercloudUpdateRun(utils.TestCommand):

+ 1
- 1
tripleoclient/tests/v1/overcloud_update/test_overcloud_update.py View File

@@ -47,7 +47,7 @@ class TestOvercloudUpdatePrepare(fakes.TestOvercloudUpdatePrepare):
47 47
     @mock.patch('shutil.copytree', autospec=True)
48 48
     @mock.patch('six.moves.builtins.open')
49 49
     @mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
50
-                '_deploy_tripleo_heat_templates', autospec=True)
50
+                '_deploy_tripleo_heat_templates_tmpdir', autospec=True)
51 51
     def test_update_out(self, mock_deploy, mock_open, mock_copy, mock_yaml,
52 52
                         mock_abspath, mock_update, mock_logger,
53 53
                         mock_get_stack):

+ 4
- 1
tripleoclient/tests/v1/overcloud_upgrade/fakes.py View File

@@ -48,7 +48,10 @@ class TestOvercloudUpgradePrepare(utils.TestCommand):
48 48
         self.app.client_manager.baremetal = mock.Mock()
49 49
         self.app.client_manager.orchestration = mock.Mock()
50 50
         self.app.client_manager.tripleoclient = FakeClientWrapper()
51
-        self.app.client_manager.workflow_engine = mock.Mock()
51
+        workflow = execution = mock.Mock()
52
+        execution.id = "IDID"
53
+        workflow.executions.create.return_value = execution
54
+        self.app.client_manager.workflow_engine = workflow
52 55
 
53 56
 
54 57
 class TestOvercloudUpgradeRun(utils.TestCommand):

+ 6
- 0
tripleoclient/tests/v1/test_overcloud_plan.py View File

@@ -120,6 +120,9 @@ class TestOvercloudCreatePlan(utils.TestCommand):
120 120
         self.app.client_manager.tripleoclient = self.tripleoclient
121 121
 
122 122
         self.workflow = self.app.client_manager.workflow_engine
123
+        execution = mock.Mock()
124
+        execution.id = "IDID"
125
+        self.workflow.executions.create.return_value = execution
123 126
         self.swift = self.app.client_manager.tripleoclient.object_store
124 127
 
125 128
     def test_create_default_plan(self):
@@ -364,6 +367,9 @@ class TestOvercloudDeployPlan(utils.TestCommand):
364 367
         self.cmd = overcloud_plan.DeployPlan(self.app, app_args)
365 368
 
366 369
         self.workflow = self.app.client_manager.workflow_engine = mock.Mock()
370
+        execution = mock.Mock()
371
+        execution.id = "IDID"
372
+        self.workflow.executions.create.return_value = execution
367 373
         self.orch = self.app.client_manager.orchestration = mock.Mock()
368 374
 
369 375
         self.websocket = mock.Mock()

+ 5
- 2
tripleoclient/tests/v1/test_overcloud_raid.py View File

@@ -37,15 +37,18 @@ class TestCreateRAID(fakes.TestBaremetal):
37 37
         tripleoclient = self.app.client_manager.tripleoclient
38 38
         websocket = tripleoclient.messaging_websocket()
39 39
         websocket.wait_for_messages.return_value = iter([
40
-            {'status': "SUCCESS"}
40
+            {'status': "SUCCESS",
41
+             'execution': {'id': 'IDID'}}
41 42
         ])
42 43
         self.websocket = websocket
43 44
 
44
-        self.workflow.executions.create.return_value = mock.MagicMock(
45
+        execution = mock.MagicMock(
45 46
             output=json.dumps({
46 47
                 "result": None
47 48
             })
48 49
         )
50
+        execution.id = "IDID"
51
+        self.workflow.executions.create.return_value = execution
49 52
 
50 53
     def test_ok(self):
51 54
         conf = json.dumps(self.conf)

+ 3
- 0
tripleoclient/tests/workflows/test_baremetal.py View File

@@ -32,6 +32,9 @@ class TestBaremetalWorkflows(utils.TestCommand):
32 32
         self.websocket.__exit__ = lambda s, *exc: None
33 33
         self.tripleoclient.messaging_websocket.return_value = self.websocket
34 34
         self.app.client_manager.tripleoclient = self.tripleoclient
35
+        execution = mock.Mock()
36
+        execution.id = "IDID"
37
+        self.workflow.executions.create.return_value = execution
35 38
 
36 39
         self.message_success = iter([{
37 40
             "execution": {"id": "IDID"},

+ 29
- 2
tripleoclient/tests/workflows/test_base.py View File

@@ -25,11 +25,13 @@ class TestBaseWorkflows(utils.TestCommand):
25 25
     def test_wait_for_messages_success(self):
26 26
         payload_a = {
27 27
             'status': 'ERROR',
28
-            'execution': {'id': 2}
28
+            'execution': {'id': 2,
29
+                          'root_execution_id': 1}
29 30
         }
30 31
         payload_b = {
31 32
             'status': 'ERROR',
32
-            'execution': {'id': 1}
33
+            'execution': {'id': 1,
34
+                          'root_execution_id': 1}
33 35
         }
34 36
 
35 37
         mistral = mock.Mock()
@@ -74,6 +76,31 @@ class TestBaseWorkflows(utils.TestCommand):
74 76
         self.assertTrue(mistral.executions.get.called)
75 77
         websocket.wait_for_messages.assert_called_with(timeout=None)
76 78
 
79
+    def test_wait_for_messages_different_execution(self):
80
+        payload_a = {
81
+            'status': 'RUNNING',
82
+            'execution': {'id': 'aaaa',
83
+                          'root_execution_id': 'aaaa'}
84
+        }
85
+        payload_b = {
86
+            'status': 'RUNNING',
87
+            'execution': {'id': 'bbbb',
88
+                          'root_execution_id': 'bbbb'}
89
+        }
90
+
91
+        mistral = mock.Mock()
92
+        websocket = mock.Mock()
93
+        websocket.wait_for_messages.return_value = iter([payload_a, payload_b])
94
+        execution = mock.Mock()
95
+        execution.id = 'aaaa'
96
+
97
+        messages = list(base.wait_for_messages(mistral, websocket, execution))
98
+
99
+        # Assert only payload_a was returned
100
+        self.assertEqual([payload_a], messages)
101
+
102
+        websocket.wait_for_messages.assert_called_with(timeout=None)
103
+
77 104
     def test_call_action_success(self):
78 105
         mistral = mock.Mock()
79 106
         action = 'test-action'

+ 3
- 0
tripleoclient/tests/workflows/test_parameters.py View File

@@ -42,6 +42,9 @@ class TestParameterWorkflows(utils.TestCommand):
42 42
         self.websocket.__exit__ = lambda s, *exc: None
43 43
         self.tripleoclient.messaging_websocket.return_value = self.websocket
44 44
         self.app.client_manager.tripleoclient = self.tripleoclient
45
+        execution = mock.Mock()
46
+        execution.id = "IDID"
47
+        self.workflow.executions.create.return_value = execution
45 48
 
46 49
     def test_get_overcloud_passwords(self):
47 50
         self.websocket.wait_for_messages.return_value = iter([{

+ 21
- 4
tripleoclient/tests/workflows/test_plan_management.py View File

@@ -43,7 +43,9 @@ class TestPlanCreationWorkflows(utils.TestCommand):
43 43
                 autospec=True)
44 44
     def test_create_plan_from_templates_success(self, mock_tarball):
45 45
         output = mock.Mock(output='{"result": ""}')
46
+        output.id = "IDID"
46 47
         self.workflow.action_executions.create.return_value = output
48
+        self.workflow.executions.create.return_value = output
47 49
         self.websocket.wait_for_messages.return_value = self.message_success
48 50
 
49 51
         plan_management.create_plan_from_templates(
@@ -67,7 +69,9 @@ class TestPlanCreationWorkflows(utils.TestCommand):
67 69
                 autospec=True)
68 70
     def test_create_plan_from_templates_container_error(self, mock_tarball):
69 71
         error = mock.Mock(output='{"result": "Error"}')
72
+        error.id = "IDID"
70 73
         self.workflow.action_executions.create.return_value = error
74
+        self.workflow.executions.create.return_value = error
71 75
 
72 76
         self.assertRaises(
73 77
             exceptions.PlanCreationError,
@@ -88,7 +92,9 @@ class TestPlanCreationWorkflows(utils.TestCommand):
88 92
                 autospec=True)
89 93
     def test_create_plan_from_templates_roles_data(self, mock_tarball):
90 94
         output = mock.Mock(output='{"result": ""}')
95
+        output.id = "IDID"
91 96
         self.workflow.action_executions.create.return_value = output
97
+        self.workflow.executions.create.return_value = output
92 98
         self.websocket.wait_for_messages.return_value = self.message_success
93 99
 
94 100
         mock_open_context = mock.mock_open()
@@ -121,7 +127,9 @@ class TestPlanCreationWorkflows(utils.TestCommand):
121 127
                 autospec=True)
122 128
     def test_create_plan_from_templates_plan_env_data(self, mock_tarball):
123 129
         output = mock.Mock(output='{"result": ""}')
130
+        output.id = "IDID"
124 131
         self.workflow.action_executions.create.return_value = output
132
+        self.workflow.executions.create.return_value = output
125 133
         self.websocket.wait_for_messages.return_value = self.message_success
126 134
 
127 135
         mock_open_context = mock.mock_open()
@@ -154,7 +162,9 @@ class TestPlanCreationWorkflows(utils.TestCommand):
154 162
                 autospec=True)
155 163
     def test_create_plan_from_templates_networks_data(self, mock_tarball):
156 164
         output = mock.Mock(output='{"result": ""}')
165
+        output.id = "IDID"
157 166
         self.workflow.action_executions.create.return_value = output
167
+        self.workflow.executions.create.return_value = output
158 168
         self.websocket.wait_for_messages.return_value = self.message_success
159 169
 
160 170
         mock_open_context = mock.mock_open()
@@ -184,8 +194,11 @@ class TestPlanCreationWorkflows(utils.TestCommand):
184 194
             'test-overcloud', 'network_data.yaml', mock_open_context())
185 195
 
186 196
     def test_delete_plan(self):
187
-        self.workflow.action_executions.create.return_value = (
188
-            mock.Mock(output='{"result": null}'))
197
+        output = mock.Mock(output='{"result": ""}')
198
+        output.id = "IDID"
199
+        self.workflow.action_executions.create.return_value = output
200
+        self.workflow.executions.create.return_value = output
201
+        self.websocket.wait_for_messages.return_value = self.message_success
189 202
 
190 203
         plan_management.delete_deployment_plan(
191 204
             self.workflow,
@@ -200,7 +213,9 @@ class TestPlanCreationWorkflows(utils.TestCommand):
200 213
                 autospec=True)
201 214
     def test_create_plan_with_password_gen_disabled(self, mock_tarball):
202 215
         output = mock.Mock(output='{"result": ""}')
216
+        output.id = "IDID"
203 217
         self.workflow.action_executions.create.return_value = output
218
+        self.workflow.executions.create.return_value = output
204 219
         self.websocket.wait_for_messages.return_value = self.message_success
205 220
 
206 221
         plan_management.create_plan_from_templates(
@@ -235,8 +250,10 @@ class TestPlanUpdateWorkflows(base.TestCommand):
235 250
         self.websocket.__enter__ = lambda s: self.websocket
236 251
         self.websocket.__exit__ = lambda s, *exc: None
237 252
         self.tripleoclient.messaging_websocket.return_value = self.websocket
238
-        self.workflow.action_executions.create.return_value = mock.Mock(
239
-            output='{"result": ""}')
253
+        output = mock.Mock(output='{"result": ""}')
254
+        output.id = "IDID"
255
+        self.workflow.action_executions.create.return_value = output
256
+        self.workflow.executions.create.return_value = output
240 257
         self.message_success = iter([{
241 258
             "execution": {"id": "IDID"},
242 259
             "status": "SUCCESS",

+ 10
- 1
tripleoclient/workflows/base.py View File

@@ -59,7 +59,16 @@ def wait_for_messages(mistral, websocket, execution, timeout=None):
59 59
     """
60 60
     try:
61 61
         for payload in websocket.wait_for_messages(timeout=timeout):
62
-            yield payload
62
+            # Ignore messages whose root_execution_id does not match the
63
+            # id of the execution for which we are waiting.
64
+            if payload['execution']['id'] != execution.id and \
65
+                payload['execution'].get('root_execution_id', '') != \
66
+                    execution.id:
67
+
68
+                    LOG.debug("Ignoring message from execution %s"
69
+                              % payload['execution']['id'])
70
+            else:
71
+                yield payload
63 72
             # If the message is from a sub-workflow, we just need to pass it
64 73
             # on to be displayed. This should never be the last message - so
65 74
             # continue and wait for the next.

Loading…
Cancel
Save