CloudFormation module: get StackEvents when ClientRequestToken is not used (#32434)

* When getting the stack events we need to consider the case where we don't have ClientRequestToken fixes #32396

* Adding tests for the case when the ClientRequestToken is not present in the stack creation.

* Renaming the stack that the test for Client Request Token requires so it won't cause collisions with the basic test.
This commit is contained in:
Jonathan Nuñez 2017-11-02 16:41:49 +01:00 committed by Ryan Brown
parent 43914b3837
commit 67b1d0f274
25 changed files with 935 additions and 29 deletions

View file

@ -18,7 +18,7 @@
import pytest
from mock import patch
from . placebo_fixtures import placeboify, maybe_sleep
from .placebo_fixtures import placeboify, maybe_sleep
from ansible.modules.cloud.amazon import cloudformation as cfn_module
basic_yaml_tpl = """
@ -73,12 +73,28 @@ def test_invalid_template_json(placeboify):
assert "ValidationError" in m.exit_kwargs['msg']
def test_client_request_token_s3_stack(maybe_sleep, placeboify):
connection = placeboify.client('cloudformation')
params = {
'StackName': 'ansible-test-client-request-token-yaml',
'TemplateBody': basic_yaml_tpl,
'ClientRequestToken': '3faf3fb5-b289-41fc-b940-44151828f6cf',
}
m = FakeModule(disable_rollback=False)
result = cfn_module.create_stack(m, params, connection)
assert result['changed']
assert len(result['events']) > 1
# require that the final recorded stack state was CREATE_COMPLETE
# events are retrieved newest-first, so 0 is the latest
assert 'CREATE_COMPLETE' in result['events'][0]
connection.delete_stack(StackName='ansible-test-client-request-token-yaml')
def test_basic_s3_stack(maybe_sleep, placeboify):
connection = placeboify.client('cloudformation')
params = {
'StackName': 'ansible-test-basic-yaml',
'TemplateBody': basic_yaml_tpl,
'ClientRequestToken': '3faf3fb5-b289-41fc-b940-44151828f6cf',
'TemplateBody': basic_yaml_tpl
}
m = FakeModule(disable_rollback=False)
result = cfn_module.create_stack(m, params, connection)