示例#1
0
def test_fix_deprecated_kumo_config_no_parameters():
    config = {
        'kumo': {
            'cloudformation': {
                'StackName': 'my_stack_name',
            }
        }
    }
    exp_config = {'kumo': {'stack': {'StackName': 'my_stack_name'}}}

    fix_deprecated_kumo_config(config)
    assert config == exp_config
示例#2
0
def test_fix_deprecated_kumo_config():
    config = {
        'kumo': {
            'cloudformation': {
                'StackName': 'my_stack_name',
                'InstanceType': 't2.micro'
            }
        }
    }
    exp_config = {
        'kumo': {
            'stack': {
                'StackName': 'my_stack_name'
            },
            'parameters': {
                'InstanceType': 't2.micro'
            }
        }
    }

    fix_deprecated_kumo_config(config)
    assert config == exp_config
示例#3
0
def test_generate_template_no_arguments():
    cloudformation_simple_stack, _ = load_cloudformation_template(
        here('resources/simple_cloudformation_stack/cloudformation.py'))
    context = {}
    config_simple_stack = fix_deprecated_kumo_config(
        read_json_config(
            here('resources/simple_cloudformation_stack/gcdt_dev.json'))
    )['kumo']
    expected_template_body = read_json_config(
        here(
            'resources/simple_cloudformation_stack/expected_template_body.json'
        ))
    template_body = json.loads(
        generate_template(context, config_simple_stack,
                          cloudformation_simple_stack))
    assert template_body == expected_template_body
示例#4
0
def test_generate_template_invalid_arguments():
    cloudformation_simple_stack, _ = load_cloudformation_template(
        here(
            'resources/simple_cloudformation_stack/cloudformation_invalid_arguments.py'
        ))
    context = {'foo': 'bar'}
    config_simple_stack = fix_deprecated_kumo_config(
        read_json_config(
            here('resources/simple_cloudformation_stack/gcdt_dev.json'))
    )['kumo']

    with pytest.raises(Exception) as einfo:
        generate_template(context, config_simple_stack,
                          cloudformation_simple_stack)
    assert einfo.match(
        r"Arguments of 'generate_template' not as expected: \['invalid_context', 'invalid_config'\]"
    )
示例#5
0
def sample_cloudformation_stack_with_hooks(awsclient):
    # create a stack we use for the test lifecycle
    are_credentials_still_valid(awsclient)
    cloudformation_stack, _ = load_cloudformation_template(
        here('resources/sample_cloudformation_stack_with_hooks/cloudformation.py')
    )
    config_stack = fix_deprecated_kumo_config(read_json_config(
        here('resources/sample_cloudformation_stack_with_hooks/gcdt_dev.json')
    ))['kumo']
    exit_code = deploy_stack(awsclient, {}, config_stack,
                             cloudformation_stack,
                             override_stack_policy=False)
    assert not exit_code

    yield 'infra-dev-kumo-sample-stack-with-hooks'
    # cleanup
    exit_code = delete_stack(awsclient, config_stack)
    # check whether delete was completed!
    assert not exit_code, 'delete_stack was not completed please make sure to clean up the stack manually'
示例#6
0
from gcdt_kumo.kumo_core import load_cloudformation_template, \
    get_parameter_diff, deploy_stack, \
    delete_stack, create_change_set, _get_stack_name, describe_change_set, \
    _get_artifact_bucket, _s3_upload, _get_stack_state, delete_change_set, \
    generate_template, wait_for_stack_delete_complete, wait_for_stack_create_complete, \
    wait_for_stack_update_complete, get_stack_id, stop_stack, start_stack, \
    _stop_ec2_instances, _start_ec2_instances
from gcdt_kumo.kumo_util import ensure_ebs_volume_tags_ec2_instance, \
    ensure_ebs_volume_tags_autoscaling_group, fix_deprecated_kumo_config

from . import here


# read template and config
config_simple_stack = fix_deprecated_kumo_config(read_json_config(
    here('resources/simple_cloudformation_stack/gcdt_dev.json')
))['kumo']

# all things are hardcoded here :(
config_ec2 = fix_deprecated_kumo_config(read_json_config(
    here('resources/sample_ec2_cloudformation_stack/gcdt_dev.json')
))['kumo']

config_autoscaling = fix_deprecated_kumo_config(read_json_config(
    here('resources/sample_autoscaling_cloudformation_stack/gcdt_dev.json')
))['kumo']

config_rds_stack = read_json_config(
    here('resources/simple_cloudformation_stack_with_rds/gcdt_dev_lookups.json')
)['kumo']