Cleanup multi-region support for ELB, SQS, Cloudformation, EC2, Autoscaling.
This commit is contained in:
parent
b39861052b
commit
bd847bd941
16 changed files with 184 additions and 90 deletions
|
|
@ -1,9 +1,12 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
import boto
|
||||
import boto.cloudformation
|
||||
import sure # noqa
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
import tests.backport_assert_raises
|
||||
import tests.backport_assert_raises # noqa
|
||||
from nose.tools import assert_raises
|
||||
|
||||
from moto import mock_cloudformation
|
||||
|
|
@ -38,6 +41,18 @@ def test_create_stack():
|
|||
stack.get_template().should.equal(dummy_template)
|
||||
|
||||
|
||||
@mock_cloudformation
|
||||
def test_creating_stacks_across_regions():
|
||||
west1_conn = boto.cloudformation.connect_to_region("us-west-1")
|
||||
west1_conn.create_stack("test_stack", template_body=dummy_template_json)
|
||||
|
||||
west2_conn = boto.cloudformation.connect_to_region("us-west-2")
|
||||
west2_conn.create_stack("test_stack", template_body=dummy_template_json)
|
||||
|
||||
list(west1_conn.describe_stacks()).should.have.length_of(1)
|
||||
list(west2_conn.describe_stacks()).should.have.length_of(1)
|
||||
|
||||
|
||||
@mock_cloudformation
|
||||
def test_create_stack_with_notification_arn():
|
||||
conn = boto.connect_cloudformation()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ from __future__ import unicode_literals
|
|||
import json
|
||||
|
||||
import boto
|
||||
import boto.cloudformation
|
||||
import boto.ec2
|
||||
import sure # noqa
|
||||
|
||||
from moto import (
|
||||
|
|
@ -464,13 +466,13 @@ def test_iam_roles():
|
|||
def test_single_instance_with_ebs_volume():
|
||||
|
||||
template_json = json.dumps(single_instance_with_ebs_volume.template)
|
||||
conn = boto.connect_cloudformation()
|
||||
conn = boto.cloudformation.connect_to_region("us-west-1")
|
||||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=template_json,
|
||||
)
|
||||
|
||||
ec2_conn = boto.connect_ec2()
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
|
||||
|
|
@ -490,10 +492,7 @@ def test_classic_eip():
|
|||
|
||||
template_json = json.dumps(ec2_classic_eip.template)
|
||||
conn = boto.connect_cloudformation()
|
||||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=template_json,
|
||||
)
|
||||
conn.create_stack("test_stack", template_body=template_json)
|
||||
ec2_conn = boto.connect_ec2()
|
||||
eip = ec2_conn.get_all_addresses()[0]
|
||||
|
||||
|
|
@ -509,10 +508,7 @@ def test_vpc_eip():
|
|||
|
||||
template_json = json.dumps(vpc_eip.template)
|
||||
conn = boto.connect_cloudformation()
|
||||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=template_json,
|
||||
)
|
||||
conn.create_stack("test_stack", template_body=template_json)
|
||||
ec2_conn = boto.connect_ec2()
|
||||
eip = ec2_conn.get_all_addresses()[0]
|
||||
|
||||
|
|
@ -528,10 +524,7 @@ def test_fn_join():
|
|||
|
||||
template_json = json.dumps(fn_join.template)
|
||||
conn = boto.connect_cloudformation()
|
||||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=template_json,
|
||||
)
|
||||
conn.create_stack("test_stack", template_body=template_json)
|
||||
ec2_conn = boto.connect_ec2()
|
||||
eip = ec2_conn.get_all_addresses()[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ def test_parse_stack_resources():
|
|||
stack_id="test_id",
|
||||
name="test_stack",
|
||||
template=dummy_template_json,
|
||||
)
|
||||
region_name='us-west-1')
|
||||
|
||||
stack.resource_map.should.have.length_of(1)
|
||||
list(stack.resource_map.keys())[0].should.equal('Queue')
|
||||
|
|
@ -101,7 +101,8 @@ def test_parse_stack_with_name_type_resource():
|
|||
stack = FakeStack(
|
||||
stack_id="test_id",
|
||||
name="test_stack",
|
||||
template=name_type_template_json)
|
||||
template=name_type_template_json,
|
||||
region_name='us-west-1')
|
||||
|
||||
stack.resource_map.should.have.length_of(1)
|
||||
list(stack.resource_map.keys())[0].should.equal('Queue')
|
||||
|
|
@ -113,7 +114,8 @@ def test_parse_stack_with_outputs():
|
|||
stack = FakeStack(
|
||||
stack_id="test_id",
|
||||
name="test_stack",
|
||||
template=output_type_template_json)
|
||||
template=output_type_template_json,
|
||||
region_name='us-west-1')
|
||||
|
||||
stack.output_map.should.have.length_of(1)
|
||||
list(stack.output_map.keys())[0].should.equal('Output1')
|
||||
|
|
@ -126,7 +128,8 @@ def test_parse_stack_with_get_attribute_outputs():
|
|||
stack = FakeStack(
|
||||
stack_id="test_id",
|
||||
name="test_stack",
|
||||
template=get_attribute_outputs_template_json)
|
||||
template=get_attribute_outputs_template_json,
|
||||
region_name='us-west-1')
|
||||
|
||||
stack.output_map.should.have.length_of(1)
|
||||
list(stack.output_map.keys())[0].should.equal('Output1')
|
||||
|
|
@ -137,4 +140,4 @@ def test_parse_stack_with_get_attribute_outputs():
|
|||
|
||||
def test_parse_stack_with_bad_get_attribute_outputs():
|
||||
FakeStack.when.called_with(
|
||||
"test_id", "test_stack", bad_output_template_json).should.throw(BotoServerError)
|
||||
"test_id", "test_stack", bad_output_template_json, "us-west-1").should.throw(BotoServerError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue