Browse Source

Merge "Remove execution from workflow message send" into stable/rocky

tags/10.7.1
Zuul 1 month ago
parent
commit
376d874403

+ 1
- 1
tripleoclient/tests/fakes.py View File

@@ -47,7 +47,7 @@ class FakeWebSocket(object):
47 47
 
48 48
     def wait_for_messages(self, timeout=None):
49 49
         yield {
50
-            'execution': {'id': 'IDID'},
50
+            'execution_id': 'IDID',
51 51
             'status': 'SUCCESS',
52 52
         }
53 53
 

+ 1
- 1
tripleoclient/tests/test_overcloud_credentials.py View File

@@ -38,7 +38,7 @@ class TestOvercloudCredentials(test_plugin.TestPluginV1):
38 38
         self.app.client_manager.tripleoclient = self.tripleoclient
39 39
 
40 40
         self.websocket.wait_for_messages.return_value = iter([{
41
-            "execution": {"id": "IDID"},
41
+            "execution_id": "IDID",
42 42
             "status": "SUCCESS",
43 43
             "message": {
44 44
                 "overcloudrc": "OVERCLOUDRC CONTENTS",

+ 2
- 2
tripleoclient/tests/test_plugin.py View File

@@ -66,7 +66,7 @@ class TestPlugin(base.TestCase):
66 66
                 "payload": {
67 67
                     "status": 200,
68 68
                     "message": "Result for IDID",
69
-                    "execution": {"id": "IDID"},
69
+                    "execution_id": "IDID",
70 70
                 }
71 71
             }
72 72
         }, send_ack]
@@ -84,7 +84,7 @@ class TestPlugin(base.TestCase):
84 84
                 self.assertEqual(payload, {
85 85
                     "status": 200,
86 86
                     "message": "Result for IDID",
87
-                    "execution": {"id": "IDID"},
87
+                    "execution_id": "IDID",
88 88
                 })
89 89
                 # We only want to test the first message, as there is only one.
90 90
                 # The last one, the send_ack will be used by the context

+ 90
- 12
tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py View File

@@ -63,7 +63,7 @@ class TestDeleteNode(fakes.TestDeleteNode):
63 63
         parsed_args = self.check_parser(self.cmd, argslist, verifylist)
64 64
 
65 65
         self.websocket.wait_for_messages.return_value = iter([{
66
-            "execution": {"id": "IDID"},
66
+            "execution_id": "IDID",
67 67
             "status": "SUCCESS"
68 68
         }])
69 69
 
@@ -109,7 +109,7 @@ class TestDeleteNode(fakes.TestDeleteNode):
109 109
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
110 110
 
111 111
         self.websocket.wait_for_messages.return_value = iter([{
112
-            "execution": {"id": "IDID"},
112
+            "execution_id": "IDID",
113 113
             "status": "SUCCESS"
114 114
         }])
115 115
 
@@ -136,7 +136,7 @@ class TestDeleteNode(fakes.TestDeleteNode):
136 136
 
137 137
         self.websocket.wait_for_messages.return_value = iter([{
138 138
             "status": "FAILED",
139
-            "execution": {"id": "IDID"},
139
+            "execution_id": "IDID",
140 140
             "message": """Failed to run action ERROR: Couldn't find \
141 141
                 following instances in stack overcloud: wrong_instance"""
142 142
         }])
@@ -172,7 +172,7 @@ class TestProvideNode(fakes.TestOvercloudNode):
172 172
         self.websocket.wait_for_messages.return_value = iter([{
173 173
             "status": "SUCCESS",
174 174
             "message": "Success",
175
-            "execution": {"id": "IDID"}
175
+            "execution_id": "IDID"
176 176
         }])
177 177
 
178 178
     def test_provide_all_manageable_nodes(self):
@@ -250,7 +250,7 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
250 250
             "status": "SUCCESS",
251 251
             "message": "Success",
252 252
             "introspected_nodes": {},
253
-            "execution": {"id": "IDID"}
253
+            "execution_id": "IDID"
254 254
         }] * 2)
255 255
 
256 256
         self.cmd.take_action(parsed_args)
@@ -274,7 +274,7 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
274 274
         self.websocket.wait_for_messages.return_value = [{
275 275
             "status": "SUCCESS",
276 276
             "message": "Success",
277
-            "execution": {"id": "IDID"},
277
+            "execution_id": "IDID",
278 278
         }]
279 279
 
280 280
         self.cmd.take_action(parsed_args)
@@ -339,6 +339,84 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
339 339
                           self.cmd, argslist, verifylist)
340 340
 
341 341
 
342
+class TestCleanNode(fakes.TestOvercloudNode):
343
+
344
+    def setUp(self):
345
+        super(TestCleanNode, self).setUp()
346
+
347
+        self.workflow = self.app.client_manager.workflow_engine
348
+        execution = mock.Mock()
349
+        execution.id = "IDID"
350
+        self.workflow.executions.create.return_value = execution
351
+        client = self.app.client_manager.tripleoclient
352
+        self.websocket = client.messaging_websocket()
353
+
354
+        # Get the command object to test
355
+        self.cmd = overcloud_node.CleanNode(self.app, None)
356
+
357
+    def _check_clean_all_manageable(self, parsed_args, provide=False):
358
+        self.websocket.wait_for_messages.return_value = iter([{
359
+            "status": "SUCCESS",
360
+            "message": "Success",
361
+            "cleaned_nodes": {},
362
+            "execution_id": "IDID"
363
+        }] * 2)
364
+
365
+        self.cmd.take_action(parsed_args)
366
+
367
+        call_list = [mock.call(
368
+            'tripleo.baremetal.v1.clean_manageable_nodes',
369
+            workflow_input={}
370
+        )]
371
+
372
+        if provide:
373
+            call_list.append(mock.call(
374
+                'tripleo.baremetal.v1.provide_manageable_nodes',
375
+                workflow_input={}
376
+            ))
377
+
378
+        self.workflow.executions.create.assert_has_calls(call_list)
379
+        self.assertEqual(self.workflow.executions.create.call_count,
380
+                         2 if provide else 1)
381
+
382
+    def _check_clean_nodes(self, parsed_args, nodes, provide=False):
383
+        self.websocket.wait_for_messages.return_value = [{
384
+            "status": "SUCCESS",
385
+            "message": "Success",
386
+            "execution_id": "IDID"
387
+        }]
388
+
389
+        self.cmd.take_action(parsed_args)
390
+
391
+        call_list = [mock.call(
392
+            'tripleo.baremetal.v1.clean_nodes', workflow_input={
393
+                'node_uuids': nodes}
394
+        )]
395
+
396
+        if provide:
397
+            call_list.append(mock.call(
398
+                'tripleo.baremetal.v1.provide', workflow_input={
399
+                    'node_uuids': nodes}
400
+            ))
401
+
402
+        self.workflow.executions.create.assert_has_calls(call_list)
403
+        self.assertEqual(self.workflow.executions.create.call_count,
404
+                         2 if provide else 1)
405
+
406
+    def test_clean_all_manageable_nodes_without_provide(self):
407
+        parsed_args = self.check_parser(self.cmd,
408
+                                        ['--all-manageable'],
409
+                                        [('all_manageable', True)])
410
+        self._check_clean_all_manageable(parsed_args, provide=False)
411
+
412
+    def test_clean_nodes_without_provide(self):
413
+        nodes = ['node_uuid1', 'node_uuid2']
414
+        parsed_args = self.check_parser(self.cmd,
415
+                                        nodes,
416
+                                        [('node_uuids', nodes)])
417
+        self._check_clean_nodes(parsed_args, nodes, provide=False)
418
+
419
+
342 420
 class TestImportNode(fakes.TestOvercloudNode):
343 421
 
344 422
     def setUp(self):
@@ -393,7 +471,7 @@ class TestImportNode(fakes.TestOvercloudNode):
393 471
             "registered_nodes": [{
394 472
                 "uuid": "MOCK_NODE_UUID"
395 473
             }],
396
-            "execution": {"id": "IDID"}
474
+            "execution_id": "IDID"
397 475
         }]
398 476
 
399 477
         self.cmd.take_action(parsed_args)
@@ -549,7 +627,7 @@ class TestImportNodeMultiArch(fakes.TestOvercloudNode):
549 627
             "registered_nodes": [{
550 628
                 "uuid": "MOCK_NODE_UUID"
551 629
             }],
552
-            "execution": {"id": "IDID"}
630
+            "execution_id": "IDID"
553 631
         }]
554 632
 
555 633
         self.cmd.take_action(parsed_args)
@@ -654,7 +732,7 @@ class TestConfigureNode(fakes.TestOvercloudNode):
654 732
         self.websocket.wait_for_messages.return_value = iter([{
655 733
             "status": "SUCCESS",
656 734
             "message": "",
657
-            "execution": {"id": "IDID"}
735
+            "execution_id": "IDID"
658 736
         }])
659 737
 
660 738
         # Get the command object to test
@@ -682,7 +760,7 @@ class TestConfigureNode(fakes.TestOvercloudNode):
682 760
         self.websocket.wait_for_messages.return_value = iter([{
683 761
             "status": "FAILED",
684 762
             "message": "Test failure.",
685
-            "execution": {"id": "IDID"}
763
+            "execution_id": "IDID"
686 764
         }])
687 765
 
688 766
         parsed_args = self.check_parser(self.cmd, ['--all-manageable'], [])
@@ -711,7 +789,7 @@ class TestConfigureNode(fakes.TestOvercloudNode):
711 789
         self.websocket.wait_for_messages.return_value = iter([{
712 790
             "status": "FAILED",
713 791
             "message": "Test failure.",
714
-            "execution": {"id": "IDID"}
792
+            "execution_id": "IDID"
715 793
         }])
716 794
 
717 795
         parsed_args = self.check_parser(self.cmd, ['node_uuid1'], [])
@@ -838,7 +916,7 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
838 916
             "registered_nodes": [{
839 917
                 "uuid": "MOCK_NODE_UUID"
840 918
             }],
841
-            "execution": {"id": "IDID"}
919
+            "execution_id": "IDID"
842 920
         }]
843 921
 
844 922
     def test_with_ip_range(self):

+ 9
- 9
tripleoclient/tests/v1/test_overcloud_plan.py View File

@@ -88,7 +88,7 @@ class TestOvercloudDeletePlan(utils.TestCommand):
88 88
                                         [('plans', ['test-plan'])])
89 89
 
90 90
         self.websocket.wait_for_messages.return_value = iter([{
91
-            "execution": {"id": "IDID"},
91
+            "execution_id": "IDID",
92 92
             "status": "SUCCESS"
93 93
         }])
94 94
 
@@ -104,7 +104,7 @@ class TestOvercloudDeletePlan(utils.TestCommand):
104 104
         parsed_args = self.check_parser(self.cmd, argslist, verifylist)
105 105
 
106 106
         self.websocket.wait_for_messages.return_value = iter([{
107
-            "execution": {"id": "IDID"},
107
+            "execution_id": "IDID",
108 108
             "status": "SUCCESS"
109 109
         }])
110 110
 
@@ -151,7 +151,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
151 151
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
152 152
 
153 153
         self.websocket.wait_for_messages.return_value = iter([{
154
-            "execution": {"id": "IDID"},
154
+            "execution_id": "IDID",
155 155
             "status": "SUCCESS"
156 156
         }])
157 157
 
@@ -179,7 +179,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
179 179
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
180 180
 
181 181
         self.websocket.wait_for_messages.return_value = iter([{
182
-            "execution": {"id": "IDID"},
182
+            "execution_id": "IDID",
183 183
             "status": "ERROR", "message": "failed"
184 184
         }])
185 185
 
@@ -209,7 +209,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
209 209
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
210 210
 
211 211
         self.websocket.wait_for_messages.return_value = iter([{
212
-            "execution": {"id": "IDID"},
212
+            "execution_id": "IDID",
213 213
             "status": "SUCCESS"
214 214
         }])
215 215
         mock_result = mock.Mock(output='{"result": null}')
@@ -244,7 +244,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
244 244
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
245 245
 
246 246
         self.websocket.wait_for_messages.return_value = iter([{
247
-            "execution": {"id": "IDID"},
247
+            "execution_id": "IDID",
248 248
             "status": "ERROR", "message": "failed"
249 249
         }])
250 250
         mock_result = mock.Mock(output='{"result": null}')
@@ -312,7 +312,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
312 312
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
313 313
 
314 314
         self.websocket.wait_for_messages.return_value = iter([{
315
-            "execution": {"id": "IDID"},
315
+            "execution_id": "IDID",
316 316
             "status": "SUCCESS"
317 317
         }])
318 318
         mock_result = mock.Mock(output='{"result": null}')
@@ -354,7 +354,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
354 354
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
355 355
 
356 356
         self.websocket.wait_for_messages.return_value = iter([{
357
-            "execution": {"id": "IDID"},
357
+            "execution_id": "IDID",
358 358
             "status": "SUCCESS"
359 359
         }])
360 360
 
@@ -413,7 +413,7 @@ class TestOvercloudDeployPlan(utils.TestCommand):
413 413
         self.orch.stacks.get.return_value = None
414 414
 
415 415
         self.websocket.wait_for_messages.return_value = iter([{
416
-            'execution': {'id': 'IDID'},
416
+            'execution_id': 'IDID',
417 417
             'status': 'SUCCESS'
418 418
         }])
419 419
 

+ 5
- 5
tripleoclient/tests/v1/test_overcloud_plan_roles.py View File

@@ -151,7 +151,7 @@ class TestOvercloudListRole(utils.TestCommand):
151 151
 
152 152
     def test_list_empty(self):
153 153
         self.websocket.wait_for_messages.return_value = [{
154
-            'execution': {'id': 'IDID'},
154
+            'execution_id': 'IDID',
155 155
             'status': 'SUCCESS',
156 156
             'available_roles': []
157 157
         }]
@@ -169,7 +169,7 @@ class TestOvercloudListRole(utils.TestCommand):
169 169
 
170 170
     def test_list(self):
171 171
         self.websocket.wait_for_messages.return_value = [{
172
-            'execution': {'id': 'IDID'},
172
+            'execution_id': 'IDID',
173 173
             'status': 'SUCCESS',
174 174
             'available_roles': [{'name': 'ObjectStorage'},
175 175
                                 {'name': 'Compute'}]
@@ -188,7 +188,7 @@ class TestOvercloudListRole(utils.TestCommand):
188 188
 
189 189
     def test_list_with_details(self):
190 190
         self.websocket.wait_for_messages.return_value = [{
191
-            'execution': {'id': 'IDID'},
191
+            'execution_id': 'IDID',
192 192
             'status': 'SUCCESS',
193 193
             'available_roles': [
194 194
                 {'name': 'Controller', 'description': 'Test description',
@@ -233,7 +233,7 @@ class TestOvercloudShowRole(utils.TestCommand):
233 233
 
234 234
     def test_role_not_found(self):
235 235
         self.websocket.wait_for_messages.return_value = [{
236
-            'execution': {'id': 'IDID'},
236
+            'execution_id': 'IDID',
237 237
             'status': 'SUCCESS',
238 238
             'available_roles': []
239 239
         }]
@@ -248,7 +248,7 @@ class TestOvercloudShowRole(utils.TestCommand):
248 248
 
249 249
     def test_role(self):
250 250
         self.websocket.wait_for_messages.return_value = [{
251
-            'execution': {'id': 'IDID'},
251
+            'execution_id': 'IDID',
252 252
             'status': 'SUCCESS',
253 253
             'available_roles': [
254 254
                 {"name": "Test", "a": "b"},

+ 1
- 1
tripleoclient/tests/v1/test_overcloud_raid.py View File

@@ -38,7 +38,7 @@ class TestCreateRAID(fakes.TestBaremetal):
38 38
         websocket = tripleoclient.messaging_websocket()
39 39
         websocket.wait_for_messages.return_value = iter([
40 40
             {'status': "SUCCESS",
41
-             'execution': {'id': 'IDID'}}
41
+             'execution_id': 'IDID'}
42 42
         ])
43 43
         self.websocket = websocket
44 44
 

+ 6
- 6
tripleoclient/tests/workflows/test_baremetal.py View File

@@ -37,13 +37,13 @@ class TestBaremetalWorkflows(utils.TestCommand):
37 37
         self.workflow.executions.create.return_value = execution
38 38
 
39 39
         self.message_success = iter([{
40
-            "execution": {"id": "IDID"},
40
+            "execution_id": "IDID",
41 41
             "status": "SUCCESS",
42 42
             "message": "Success.",
43 43
             "registered_nodes": [],
44 44
         }])
45 45
         self.message_failed = iter([{
46
-            "execution": {"id": "IDID"},
46
+            "execution_id": "IDID",
47 47
             "status": "FAIL",
48 48
             "message": "Fail.",
49 49
         }])
@@ -127,7 +127,7 @@ class TestBaremetalWorkflows(utils.TestCommand):
127 127
     def test_provide_error_with_format_message(self):
128 128
 
129 129
         self.websocket.wait_for_messages.return_value = iter([{
130
-            "execution": {"id": "IDID"},
130
+            "execution_id": "IDID",
131 131
             "status": "FAIL",
132 132
             "message": ['Error1', 'Error2']
133 133
         }])
@@ -175,7 +175,7 @@ class TestBaremetalWorkflows(utils.TestCommand):
175 175
     def test_introspect_manageable_nodes_success(self):
176 176
 
177 177
         self.websocket.wait_for_messages.return_value = iter([{
178
-            "execution": {"id": "IDID"},
178
+            "execution_id": "IDID",
179 179
             "status": "SUCCESS",
180 180
             "introspected_nodes": {},
181 181
         }])
@@ -209,7 +209,7 @@ class TestBaremetalWorkflows(utils.TestCommand):
209 209
     def test_introspect_manageable_nodes_mixed_status(self):
210 210
 
211 211
         self.websocket.wait_for_messages.return_value = iter([{
212
-            "execution": {"id": "IDID"},
212
+            "execution_id": "IDID",
213 213
             "status": "SUCCESS",
214 214
             "introspected_nodes": {'node1': {'error': None},
215 215
                                    'node2': {'error': 'Error'}}
@@ -342,7 +342,7 @@ class TestBaremetalWorkflows(utils.TestCommand):
342 342
     def test_clean_manageable_nodes_success(self):
343 343
 
344 344
         self.websocket.wait_for_messages.return_value = iter([{
345
-            "execution": {"id": "IDID"},
345
+            "execution_id": "IDID",
346 346
             "status": "SUCCESS",
347 347
             "cleaned_nodes": [],
348 348
         }])

+ 54
- 4
tripleoclient/tests/workflows/test_base.py View File

@@ -25,13 +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,
29
-                          'root_execution_id': 1}
28
+            'execution_id': 2,
29
+            'root_execution_id': 1
30 30
         }
31 31
         payload_b = {
32 32
             'status': 'ERROR',
33
-            'execution': {'id': 1,
34
-                          'root_execution_id': 1}
33
+            'execution_id': 1,
34
+            'root_execution_id': 1
35 35
         }
36 36
 
37 37
         mistral = mock.Mock()
@@ -77,6 +77,56 @@ class TestBaseWorkflows(utils.TestCommand):
77 77
         websocket.wait_for_messages.assert_called_with(timeout=None)
78 78
 
79 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
+
104
+    def test_backwards_compat_wait_for_messages_success(self):
105
+        payload_a = {
106
+            'status': 'ERROR',
107
+            'execution': {'id': 2,
108
+                          'root_execution_id': 1}
109
+        }
110
+        payload_b = {
111
+            'status': 'ERROR',
112
+            'execution': {'id': 1,
113
+                          'root_execution_id': 1}
114
+        }
115
+
116
+        mistral = mock.Mock()
117
+        websocket = mock.Mock()
118
+        websocket.wait_for_messages.return_value = iter([payload_a, payload_b])
119
+        execution = mock.Mock()
120
+        execution.id = 1
121
+
122
+        messages = list(base.wait_for_messages(mistral, websocket, execution))
123
+
124
+        self.assertEqual([payload_a, payload_b], messages)
125
+
126
+        self.assertFalse(mistral.executions.get.called)
127
+        websocket.wait_for_messages.assert_called_with(timeout=None)
128
+
129
+    def test_backwards_compatible_call_with_different_execution(self):
80 130
         payload_a = {
81 131
             'status': 'RUNNING',
82 132
             'execution': {'id': 'aaaa',

+ 7
- 7
tripleoclient/tests/workflows/test_parameters.py View File

@@ -48,7 +48,7 @@ class TestParameterWorkflows(utils.TestCommand):
48 48
 
49 49
     def test_get_overcloud_passwords(self):
50 50
         self.websocket.wait_for_messages.return_value = iter([{
51
-            "execution": {"id": "IDID"},
51
+            "execution_id": "IDID",
52 52
             "status": "SUCCESS",
53 53
             "message": "passwords",
54 54
         }])
@@ -77,7 +77,7 @@ class TestParameterWorkflows(utils.TestCommand):
77 77
         mock_safe_load.return_value = plan_env_data
78 78
 
79 79
         self.websocket.wait_for_messages.return_value = iter([{
80
-            "execution": {"id": "IDID"},
80
+            "execution_id": "IDID",
81 81
             "status": "SUCCESS",
82 82
             "message": "",
83 83
             "result": {}
@@ -110,7 +110,7 @@ class TestParameterWorkflows(utils.TestCommand):
110 110
         mock_safe_load.return_value = plan_env_data
111 111
 
112 112
         self.websocket.wait_for_messages.return_value = iter([{
113
-            "execution": {"id": "IDID"},
113
+            "execution_id": "IDID",
114 114
             "status": "FAILED",
115 115
             "message": "workflow failure",
116 116
             "result": ""
@@ -158,7 +158,7 @@ class TestParameterWorkflows(utils.TestCommand):
158 158
 
159 159
     def test_check_deprecated_params_no_output(self):
160 160
         self.websocket.wait_for_messages.return_value = iter([{
161
-            "execution": {"id": "IDID"},
161
+            "execution_id": "IDID",
162 162
             "status": "SUCCESS",
163 163
         }])
164 164
 
@@ -176,7 +176,7 @@ class TestParameterWorkflows(utils.TestCommand):
176 176
                               'deprecated': True,
177 177
                               'user_defined': True}]
178 178
         self.websocket.wait_for_messages.return_value = iter([{
179
-            "execution": {"id": "IDID"},
179
+            "execution_id": "IDID",
180 180
             "status": "SUCCESS",
181 181
             "deprecated": deprecated_params
182 182
         }])
@@ -197,7 +197,7 @@ class TestParameterWorkflows(utils.TestCommand):
197 197
         deprecated_params = [{'parameter': 'TestParameter1',
198 198
                               'deprecated': True}]
199 199
         self.websocket.wait_for_messages.return_value = iter([{
200
-            "execution": {"id": "IDID"},
200
+            "execution_id": "IDID",
201 201
             "status": "SUCCESS",
202 202
             "deprecated": deprecated_params
203 203
         }])
@@ -215,7 +215,7 @@ class TestParameterWorkflows(utils.TestCommand):
215 215
 
216 216
     def test_generate_fencing_parameters(self):
217 217
         self.websocket.wait_for_messages.return_value = iter([{
218
-            "execution": {"id": "IDID"},
218
+            "execution_id": "IDID",
219 219
             "status": "SUCCESS",
220 220
             "fencing_parameters": "{}"
221 221
         }])

+ 2
- 2
tripleoclient/tests/workflows/test_plan_management.py View File

@@ -35,7 +35,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
35 35
         self.app.client_manager.tripleoclient = self.tripleoclient
36 36
 
37 37
         self.message_success = iter([{
38
-            "execution": {"id": "IDID"},
38
+            "execution_id": "IDID",
39 39
             "status": "SUCCESS",
40 40
         }])
41 41
 
@@ -256,7 +256,7 @@ class TestPlanUpdateWorkflows(base.TestCommand):
256 256
         self.workflow.action_executions.create.return_value = output
257 257
         self.workflow.executions.create.return_value = output
258 258
         self.message_success = iter([{
259
-            "execution": {"id": "IDID"},
259
+            "execution_id": "IDID",
260 260
             "status": "SUCCESS",
261 261
         }])
262 262
         self.websocket.wait_for_messages.return_value = self.message_success

+ 19
- 6
tripleoclient/workflows/base.py View File

@@ -60,19 +60,32 @@ def wait_for_messages(mistral, websocket, execution, timeout=None):
60 60
     try:
61 61
         for payload in websocket.wait_for_messages(timeout=timeout):
62 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:
63
+            # id of the execution for which we are waiting
64
+
65
+            # New versions of tripleo-common don't sent the execution anymore
66
+            # but keeping the old way ot getting it is important to keep
67
+            # backwards compatibility.
68
+
69
+            # TODO(apetrich) payload.execution is deprecated and will be
70
+            # removed from stein. We should keep this until payload.execution
71
+            #  is removed from the LTS
72
+            payload_exec_id = payload.get('execution_id') or \
73
+                payload.get('execution', {}).get('id')
74
+
75
+            payload_root_exec_id = payload.get('root_execution_id', '') or \
76
+                payload.get('execution', {}).get('root_execution_id', '')
77
+
78
+            if payload_exec_id != execution.id and \
79
+                    payload_root_exec_id != execution.id:
67 80
 
68 81
                     LOG.debug("Ignoring message from execution %s"
69
-                              % payload['execution']['id'])
82
+                              % payload_exec_id)
70 83
             else:
71 84
                 yield payload
72 85
             # If the message is from a sub-workflow, we just need to pass it
73 86
             # on to be displayed. This should never be the last message - so
74 87
             # continue and wait for the next.
75
-            if payload['execution']['id'] != execution.id:
88
+            if payload_exec_id != execution.id:
76 89
                 continue
77 90
             # Check the status of the payload, if we are not given one
78 91
             # default to running and assume it is just an "in progress"

Loading…
Cancel
Save