Support multiple messages from create/update_deployment_plan

This updates the workflow wrapper to use the multiple message interface.

Change-Id: I972a4f5baebf4e719243b7519eb3189cd2036dde
Partial-Bug: #1646887
This commit is contained in:
Dougal Matthews 2017-03-16 08:25:33 +00:00
parent f7c032fb58
commit ad0aae9cff
4 changed files with 26 additions and 15 deletions

View File

@ -48,6 +48,12 @@ class FakeWebSocket(object):
'status': 'SUCCESS'
}
def wait_for_messages(self, timeout=None):
yield {
'execution': {'id': 'IDID'},
'status': 'SUCCESS',
}
def __enter__(self):
return self

View File

@ -179,9 +179,10 @@ class TestOvercloudCreatePlan(utils.TestCommand):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.websocket.wait_for_message.return_value = {
self.websocket.wait_for_messages.return_value = iter([{
"execution": {"id": "IDID"},
"status": "SUCCESS"
}
}])
mock_result = mock.Mock(output='{"result": null}')
self.workflow.action_executions.create.return_value = mock_result
@ -213,9 +214,10 @@ class TestOvercloudCreatePlan(utils.TestCommand):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.websocket.wait_for_message.return_value = {
self.websocket.wait_for_messages.return_value = iter([{
"execution": {"id": "IDID"},
"status": "ERROR", "message": "failed"
}
}])
mock_result = mock.Mock(output='{"result": null}')
self.workflow.action_executions.create.return_value = mock_result

View File

@ -32,6 +32,11 @@ class TestPlanCreationWorkflows(utils.TestCommand):
self.tripleoclient.messaging_websocket.return_value = self.websocket
self.app.client_manager.tripleoclient = self.tripleoclient
self.message_success = iter([{
"execution": {"id": "IDID"},
"status": "SUCCESS",
}])
uuid4_patcher = mock.patch('uuid.uuid4', return_value="UUID4")
self.mock_uuid4 = uuid4_patcher.start()
self.addCleanup(self.mock_uuid4.stop)
@ -41,9 +46,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
def test_create_plan_from_templates_success(self, mock_tarball):
output = mock.Mock(output='{"result": ""}')
self.workflow.action_executions.create.return_value = output
self.websocket.wait_for_message.return_value = {
"status": "SUCCESS",
}
self.websocket.wait_for_messages.return_value = self.message_success
plan_management.create_plan_from_templates(
self.app.client_manager,
@ -86,9 +89,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
def test_create_plan_from_templates_roles_data(self, mock_tarball):
output = mock.Mock(output='{"result": ""}')
self.workflow.action_executions.create.return_value = output
self.websocket.wait_for_message.return_value = {
"status": "SUCCESS",
}
self.websocket.wait_for_messages.return_value = self.message_success
mock_open_context = mock.mock_open()
with mock.patch('six.moves.builtins.open', mock_open_context):
@ -133,9 +134,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
def test_create_plan_with_password_gen_disabled(self, mock_tarball):
output = mock.Mock(output='{"result": ""}')
self.workflow.action_executions.create.return_value = output
self.websocket.wait_for_message.return_value = {
"status": "SUCCESS",
}
self.websocket.wait_for_messages.return_value = self.message_success
plan_management.create_plan_from_templates(
self.app.client_manager,

View File

@ -78,8 +78,12 @@ def _create_update_deployment_plan(clients, workflow, **workflow_input):
)
with tripleoclients.messaging_websocket(queue_name) as ws:
return base.wait_for_message(workflow_client, ws, execution,
_WORKFLOW_TIMEOUT)
for payload in base.wait_for_messages(workflow_client, ws, execution,
_WORKFLOW_TIMEOUT):
if 'message' in payload:
print(payload['message'])
return payload
def create_deployment_plan(clients, **workflow_input):