Autoscaling instance azs (#2030)
* Add instance AZ support in autoscaling * Resolve py36-py27 format string error in test_autoscaling
This commit is contained in:
parent
fb2a76fd66
commit
868d0107bf
10 changed files with 157 additions and 111 deletions
|
|
@ -16,7 +16,7 @@ from moto import mock_ec2_deprecated, mock_ec2
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_create_and_delete_volume():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume = conn.create_volume(80, "us-east-1a")
|
||||
|
||||
all_volumes = conn.get_all_volumes()
|
||||
|
|
@ -52,7 +52,7 @@ def test_create_and_delete_volume():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_create_encrypted_volume_dryrun():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
conn.create_volume(80, "us-east-1a", encrypted=True, dry_run=True)
|
||||
ex.exception.error_code.should.equal('DryRunOperation')
|
||||
|
|
@ -63,7 +63,7 @@ def test_create_encrypted_volume_dryrun():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_create_encrypted_volume():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume = conn.create_volume(80, "us-east-1a", encrypted=True)
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
|
|
@ -79,7 +79,7 @@ def test_create_encrypted_volume():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_filter_volume_by_id():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume1 = conn.create_volume(80, "us-east-1a")
|
||||
volume2 = conn.create_volume(36, "us-east-1b")
|
||||
volume3 = conn.create_volume(20, "us-east-1c")
|
||||
|
|
@ -99,7 +99,7 @@ def test_filter_volume_by_id():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_volume_filters():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
|
||||
reservation = conn.run_instances('ami-1234abcd')
|
||||
instance = reservation.instances[0]
|
||||
|
|
@ -196,7 +196,7 @@ def test_volume_filters():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_volume_attach_and_detach():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
reservation = conn.run_instances('ami-1234abcd')
|
||||
instance = reservation.instances[0]
|
||||
volume = conn.create_volume(80, "us-east-1a")
|
||||
|
|
@ -252,7 +252,7 @@ def test_volume_attach_and_detach():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_create_snapshot():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume = conn.create_volume(80, "us-east-1a")
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
|
|
@ -291,7 +291,7 @@ def test_create_snapshot():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_create_encrypted_snapshot():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume = conn.create_volume(80, "us-east-1a", encrypted=True)
|
||||
snapshot = volume.create_snapshot('a test snapshot')
|
||||
snapshot.update()
|
||||
|
|
@ -306,7 +306,7 @@ def test_create_encrypted_snapshot():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_filter_snapshot_by_id():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume1 = conn.create_volume(36, "us-east-1a")
|
||||
snap1 = volume1.create_snapshot('a test snapshot 1')
|
||||
volume2 = conn.create_volume(42, 'us-east-1a')
|
||||
|
|
@ -333,7 +333,7 @@ def test_filter_snapshot_by_id():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_snapshot_filters():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume1 = conn.create_volume(20, "us-east-1a", encrypted=False)
|
||||
volume2 = conn.create_volume(25, "us-east-1a", encrypted=True)
|
||||
|
||||
|
|
@ -404,7 +404,7 @@ def test_snapshot_filters():
|
|||
def test_snapshot_attribute():
|
||||
import copy
|
||||
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume = conn.create_volume(80, "us-east-1a")
|
||||
snapshot = volume.create_snapshot()
|
||||
|
||||
|
|
@ -507,7 +507,7 @@ def test_snapshot_attribute():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_create_volume_from_snapshot():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume = conn.create_volume(80, "us-east-1a")
|
||||
snapshot = volume.create_snapshot('a test snapshot')
|
||||
|
||||
|
|
@ -529,7 +529,7 @@ def test_create_volume_from_snapshot():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_create_volume_from_encrypted_snapshot():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
volume = conn.create_volume(80, "us-east-1a", encrypted=True)
|
||||
|
||||
snapshot = volume.create_snapshot('a test snapshot')
|
||||
|
|
@ -574,7 +574,7 @@ def test_modify_attribute_blockDeviceMapping():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_volume_tag_escaping():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
vol = conn.create_volume(10, 'us-east-1a')
|
||||
snapshot = conn.create_snapshot(vol.id, 'Desc')
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ def test_add_servers():
|
|||
@freeze_time("2014-01-01 05:00:00")
|
||||
@mock_ec2_deprecated
|
||||
def test_instance_launch_and_terminate():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
reservation = conn.run_instances('ami-1234abcd', dry_run=True)
|
||||
|
|
@ -820,7 +820,7 @@ def test_run_instance_with_instance_type():
|
|||
|
||||
@mock_ec2_deprecated
|
||||
def test_run_instance_with_default_placement():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
reservation = conn.run_instances('ami-1234abcd')
|
||||
instance = reservation.instances[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,10 @@ def test_create_autoscaling_group():
|
|||
image_id='ami-abcd1234',
|
||||
instance_type='m1.small',
|
||||
)
|
||||
us_conn.create_launch_configuration(config)
|
||||
x = us_conn.create_launch_configuration(config)
|
||||
|
||||
us_subnet_id = list(ec2_backends['us-east-1'].subnets['us-east-1c'].keys())[0]
|
||||
ap_subnet_id = list(ec2_backends['ap-northeast-1'].subnets['ap-northeast-1a'].keys())[0]
|
||||
group = boto.ec2.autoscale.AutoScalingGroup(
|
||||
name='us_tester_group',
|
||||
availability_zones=['us-east-1c'],
|
||||
|
|
@ -82,7 +84,7 @@ def test_create_autoscaling_group():
|
|||
launch_config=config,
|
||||
load_balancers=["us_test_lb"],
|
||||
placement_group="us_test_placement",
|
||||
vpc_zone_identifier='subnet-1234abcd',
|
||||
vpc_zone_identifier=us_subnet_id,
|
||||
termination_policies=["OldestInstance", "NewestInstance"],
|
||||
)
|
||||
us_conn.create_auto_scaling_group(group)
|
||||
|
|
@ -107,7 +109,7 @@ def test_create_autoscaling_group():
|
|||
launch_config=config,
|
||||
load_balancers=["ap_test_lb"],
|
||||
placement_group="ap_test_placement",
|
||||
vpc_zone_identifier='subnet-5678efgh',
|
||||
vpc_zone_identifier=ap_subnet_id,
|
||||
termination_policies=["OldestInstance", "NewestInstance"],
|
||||
)
|
||||
ap_conn.create_auto_scaling_group(group)
|
||||
|
|
@ -121,7 +123,7 @@ def test_create_autoscaling_group():
|
|||
us_group.desired_capacity.should.equal(2)
|
||||
us_group.max_size.should.equal(2)
|
||||
us_group.min_size.should.equal(2)
|
||||
us_group.vpc_zone_identifier.should.equal('subnet-1234abcd')
|
||||
us_group.vpc_zone_identifier.should.equal(us_subnet_id)
|
||||
us_group.launch_config_name.should.equal('us_tester')
|
||||
us_group.default_cooldown.should.equal(60)
|
||||
us_group.health_check_period.should.equal(100)
|
||||
|
|
@ -137,7 +139,7 @@ def test_create_autoscaling_group():
|
|||
ap_group.desired_capacity.should.equal(2)
|
||||
ap_group.max_size.should.equal(2)
|
||||
ap_group.min_size.should.equal(2)
|
||||
ap_group.vpc_zone_identifier.should.equal('subnet-5678efgh')
|
||||
ap_group.vpc_zone_identifier.should.equal(ap_subnet_id)
|
||||
ap_group.launch_config_name.should.equal('ap_tester')
|
||||
ap_group.default_cooldown.should.equal(60)
|
||||
ap_group.health_check_period.should.equal(100)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue