Address pytest warnings (#3629)
* Address `boto` deprecation warnings This commit eliminates the following warning: ../boto/ec2/connection.py:582: PendingDeprecationWarning: The current get_all_instances implementation will be replaced with get_all_reservations. `boto` isn't likely to ever make good on this warning, but doing the replacement will declutter the `moto` test output. * Remove `invoke_lambda` tracebacks from unit test logging If an exception is encountered, the details are returned in the response payload. Printing the traceback was just adding noise to the pytest output. * Use known AMIs in unit tests This commit eliminates the following warning in the pytest output: `PendingDeprecationWarning: Could not find AMI with image-id:ami-123456, in the near future this will cause an error.` Known, pre-loaded AMI image ids are used instead of random ids that don't actually exist in the moto backend. The integrity of the tests is unaffected by this change. A test has been added to provide explicit coverage of the PendingDeprecationWarning raised when an invalid AMI image id is passed to moto.
This commit is contained in:
parent
cd25ab7a16
commit
f4b81e69b8
17 changed files with 98 additions and 72 deletions
|
|
@ -1,11 +1,13 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from tests import EXAMPLE_AMI_ID
|
||||
|
||||
template = {
|
||||
"Parameters": {"R53ZoneName": {"Type": "String", "Default": "my_zone"}},
|
||||
"Resources": {
|
||||
"Ec2Instance": {
|
||||
"Type": "AWS::EC2::Instance",
|
||||
"Properties": {"ImageId": "ami-1234abcd", "PrivateIpAddress": "10.0.0.25"},
|
||||
"Properties": {"ImageId": EXAMPLE_AMI_ID, "PrivateIpAddress": "10.0.0.25"},
|
||||
},
|
||||
"HostedZone": {
|
||||
"Type": "AWS::Route53::HostedZone",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from tests import EXAMPLE_AMI_ID, EXAMPLE_AMI_ID2
|
||||
|
||||
template = {
|
||||
"Description": "AWS CloudFormation Sample Template Gollum_Single_Instance_With_EBS_Volume: Gollum is a simple wiki system built on top of Git that powers GitHub Wikis. This template installs a Gollum Wiki stack on a single EC2 instance with an EBS volume for storage and demonstrates using the AWS CloudFormation bootstrap scripts to install the packages and files necessary at instance launch time. **WARNING** This template creates an Amazon EC2 instance and an EBS volume. You will be billed for the AWS resources used if you create a stack from this template.",
|
||||
"Parameters": {
|
||||
|
|
@ -217,43 +219,43 @@ template = {
|
|||
"AWSRegionArch2AMI": {
|
||||
"ap-southeast-1": {
|
||||
"64HVM": "NOT_YET_SUPPORTED",
|
||||
"32": "ami-b4b0cae6",
|
||||
"64": "ami-beb0caec",
|
||||
"32": EXAMPLE_AMI_ID,
|
||||
"64": EXAMPLE_AMI_ID2,
|
||||
},
|
||||
"ap-southeast-2": {
|
||||
"64HVM": "NOT_YET_SUPPORTED",
|
||||
"32": "ami-b3990e89",
|
||||
"64": "ami-bd990e87",
|
||||
"32": EXAMPLE_AMI_ID,
|
||||
"64": EXAMPLE_AMI_ID2,
|
||||
},
|
||||
"us-west-2": {
|
||||
"64HVM": "NOT_YET_SUPPORTED",
|
||||
"32": "ami-38fe7308",
|
||||
"64": "ami-30fe7300",
|
||||
"32": EXAMPLE_AMI_ID,
|
||||
"64": EXAMPLE_AMI_ID2,
|
||||
},
|
||||
"us-east-1": {
|
||||
"64HVM": "ami-0da96764",
|
||||
"32": "ami-31814f58",
|
||||
"64": "ami-1b814f72",
|
||||
"32": EXAMPLE_AMI_ID,
|
||||
"64": EXAMPLE_AMI_ID2,
|
||||
},
|
||||
"ap-northeast-1": {
|
||||
"64HVM": "NOT_YET_SUPPORTED",
|
||||
"32": "ami-0644f007",
|
||||
"64": "ami-0a44f00b",
|
||||
"32": EXAMPLE_AMI_ID,
|
||||
"64": EXAMPLE_AMI_ID2,
|
||||
},
|
||||
"us-west-1": {
|
||||
"64HVM": "NOT_YET_SUPPORTED",
|
||||
"32": "ami-11d68a54",
|
||||
"64": "ami-1bd68a5e",
|
||||
"32": EXAMPLE_AMI_ID,
|
||||
"64": EXAMPLE_AMI_ID2,
|
||||
},
|
||||
"eu-west-1": {
|
||||
"64HVM": "NOT_YET_SUPPORTED",
|
||||
"32": "ami-973b06e3",
|
||||
"64": "ami-953b06e1",
|
||||
"32": EXAMPLE_AMI_ID,
|
||||
"64": EXAMPLE_AMI_ID2,
|
||||
},
|
||||
"sa-east-1": {
|
||||
"64HVM": "NOT_YET_SUPPORTED",
|
||||
"32": "ami-3e3be423",
|
||||
"64": "ami-3c3be421",
|
||||
"32": EXAMPLE_AMI_ID,
|
||||
"64": EXAMPLE_AMI_ID2,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from tests import EXAMPLE_AMI_ID
|
||||
|
||||
template = {
|
||||
"Description": "AWS CloudFormation Sample Template vpc_single_instance_in_subnet.template: Sample template showing how to create a VPC and add an EC2 instance with an Elastic IP address and a security group. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
|
||||
"Parameters": {
|
||||
|
|
@ -263,14 +265,14 @@ template = {
|
|||
},
|
||||
"Mappings": {
|
||||
"RegionMap": {
|
||||
"ap-southeast-1": {"AMI": "ami-74dda626"},
|
||||
"ap-southeast-2": {"AMI": "ami-b3990e89"},
|
||||
"us-west-2": {"AMI": "ami-16fd7026"},
|
||||
"us-east-1": {"AMI": "ami-7f418316"},
|
||||
"ap-northeast-1": {"AMI": "ami-dcfa4edd"},
|
||||
"us-west-1": {"AMI": "ami-951945d0"},
|
||||
"eu-west-1": {"AMI": "ami-24506250"},
|
||||
"sa-east-1": {"AMI": "ami-3e3be423"},
|
||||
"ap-southeast-1": {"AMI": EXAMPLE_AMI_ID},
|
||||
"ap-southeast-2": {"AMI": EXAMPLE_AMI_ID},
|
||||
"us-west-2": {"AMI": EXAMPLE_AMI_ID},
|
||||
"us-east-1": {"AMI": EXAMPLE_AMI_ID},
|
||||
"ap-northeast-1": {"AMI": EXAMPLE_AMI_ID},
|
||||
"us-west-1": {"AMI": EXAMPLE_AMI_ID},
|
||||
"eu-west-1": {"AMI": EXAMPLE_AMI_ID},
|
||||
"sa-east-1": {"AMI": EXAMPLE_AMI_ID},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ Resources:
|
|||
EC2Instance1:
|
||||
Type: AWS::EC2::Instance
|
||||
Properties:
|
||||
ImageId: ami-d3adb33f
|
||||
ImageId: ami-03cf127a
|
||||
KeyName: dummy
|
||||
InstanceType: t2.micro
|
||||
Tags:
|
||||
|
|
@ -67,7 +67,7 @@ Resources:
|
|||
EC2Instance1:
|
||||
Type: AWS::EC2::Instance
|
||||
Properties:
|
||||
ImageId: ami-d3adb33f
|
||||
ImageId: ami-03cf127a
|
||||
KeyName: !Join [ ":", [ du, m, my ] ]
|
||||
InstanceType: t2.micro
|
||||
Tags:
|
||||
|
|
@ -90,7 +90,7 @@ Resources:
|
|||
EC2Instance1:
|
||||
Type: AWS::EC2::Instance
|
||||
Properties:
|
||||
ImageId: ami-d3adb33f
|
||||
ImageId: ami-03cf127a
|
||||
KeyName: dummy
|
||||
InstanceType: t2.micro
|
||||
Tags:
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ def test_stack_ec2_integration():
|
|||
conn.create_stack("ec2_stack", template_body=ec2_template_json)
|
||||
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
|
||||
stack = conn.describe_stacks()[0]
|
||||
|
|
@ -269,7 +269,7 @@ def test_stack_elb_integration_with_attached_ec2_instances():
|
|||
load_balancer = elb_conn.get_all_load_balancers()[0]
|
||||
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
|
||||
load_balancer.instances[0].id.should.equal(ec2_instance.id)
|
||||
|
|
@ -465,7 +465,7 @@ def test_stack_security_groups():
|
|||
filters={"description": ["My other group"]}
|
||||
)[0]
|
||||
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
|
||||
ec2_instance.groups[0].id.should.equal(instance_group.id)
|
||||
|
|
@ -692,7 +692,7 @@ def test_vpc_single_instance_in_subnet():
|
|||
subnet.vpc_id.should.equal(vpc.id)
|
||||
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
instance = reservation.instances[0]
|
||||
instance.tags["Foo"].should.equal("Bar")
|
||||
# Check that the EIP is attached the the EC2 instance
|
||||
|
|
@ -1011,7 +1011,7 @@ def test_single_instance_with_ebs_volume():
|
|||
)
|
||||
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
|
||||
volumes = ec2_conn.get_all_volumes()
|
||||
|
|
@ -1157,7 +1157,7 @@ def test_conditional_if_handling():
|
|||
conn = boto.cloudformation.connect_to_region("us-west-1")
|
||||
conn.create_stack("test_stack1", template_body=dummy_template_json)
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
ec2_instance.image_id.should.equal(EXAMPLE_AMI_ID2)
|
||||
ec2_instance.terminate()
|
||||
|
|
@ -1167,7 +1167,7 @@ def test_conditional_if_handling():
|
|||
"test_stack1", template_body=dummy_template_json, parameters=[("ENV", "prd")]
|
||||
)
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-2")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
ec2_instance.image_id.should.equal(EXAMPLE_AMI_ID)
|
||||
|
||||
|
|
@ -1179,11 +1179,11 @@ def test_cloudformation_mapping():
|
|||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Mappings": {
|
||||
"RegionMap": {
|
||||
"us-east-1": {"32": "ami-6411e20d", "64": "ami-7a11e213"},
|
||||
"us-west-1": {"32": "ami-c9c7978c", "64": "ami-cfc7978a"},
|
||||
"eu-west-1": {"32": "ami-37c2f643", "64": "ami-31c2f645"},
|
||||
"ap-southeast-1": {"32": "ami-66f28c34", "64": "ami-60f28c32"},
|
||||
"ap-northeast-1": {"32": "ami-9c03a89d", "64": "ami-a003a8a1"},
|
||||
"us-east-1": {"32": EXAMPLE_AMI_ID, "64": EXAMPLE_AMI_ID2},
|
||||
"us-west-1": {"32": EXAMPLE_AMI_ID, "64": EXAMPLE_AMI_ID2},
|
||||
"eu-west-1": {"32": EXAMPLE_AMI_ID, "64": EXAMPLE_AMI_ID2},
|
||||
"ap-southeast-1": {"32": EXAMPLE_AMI_ID, "64": EXAMPLE_AMI_ID2},
|
||||
"ap-northeast-1": {"32": EXAMPLE_AMI_ID, "64": EXAMPLE_AMI_ID2},
|
||||
}
|
||||
},
|
||||
"Resources": {
|
||||
|
|
@ -1195,7 +1195,6 @@ def test_cloudformation_mapping():
|
|||
},
|
||||
"InstanceType": "m1.small",
|
||||
},
|
||||
"Type": "AWS::EC2::Instance",
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -1205,16 +1204,16 @@ def test_cloudformation_mapping():
|
|||
conn = boto.cloudformation.connect_to_region("us-east-1")
|
||||
conn.create_stack("test_stack1", template_body=dummy_template_json)
|
||||
ec2_conn = boto.ec2.connect_to_region("us-east-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
ec2_instance.image_id.should.equal("ami-6411e20d")
|
||||
ec2_instance.image_id.should.equal(EXAMPLE_AMI_ID)
|
||||
|
||||
conn = boto.cloudformation.connect_to_region("us-west-1")
|
||||
conn.create_stack("test_stack1", template_body=dummy_template_json)
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
reservation = ec2_conn.get_all_reservations()[0]
|
||||
ec2_instance = reservation.instances[0]
|
||||
ec2_instance.image_id.should.equal("ami-c9c7978c")
|
||||
ec2_instance.image_id.should.equal(EXAMPLE_AMI_ID)
|
||||
|
||||
|
||||
@mock_cloudformation_deprecated()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue