Skip to content

Commit

Permalink
tests/service/rds: Remove hardcoded instance classes from EC2-Classic…
Browse files Browse the repository at this point in the history
… tests and basic data source test (#15184)

Reference: #15182

Previously:

```
=== CONT  TestAccAWSDBInstance_ec2Classic
TestAccAWSDBInstance_ec2Classic: resource_aws_db_instance_test.go:2248: Step 1/1 error: terraform failed: exit status 1
stderr:
Error: Error creating DB Instance: InsufficientDBInstanceCapacity: Cannot create a db.m5.large database instance because there are no availability zones with sufficient capacity for non-VPC and storage type : gp2 for db.m5.large. Please try the request again at a later time.
  status code: 400, request id: 5bc39058-0571-4f63-bb80-c25533285646
--- FAIL: TestAccAWSDBInstance_ec2Classic (5.31s)

=== CONT  TestAccAWSDbInstanceDataSource_ec2Classic
TestAccAWSDbInstanceDataSource_ec2Classic: data_source_aws_db_instance_test.go:51: Step 1/1 error: terraform failed: exit status 1
stderr:
Error: Error creating DB Instance: InsufficientDBInstanceCapacity: Cannot create a db.m5.large database instance because there are no availability zones with sufficient capacity for non-VPC and storage type : gp2 for db.m5.large. Please try the request again at a later time.
  status code: 400, request id: 38414095-00df-4a5d-ba25-241b5c400ef6
--- FAIL: TestAccAWSDbInstanceDataSource_ec2Classic (15.24s)
```

Output from acceptance testing:

```
--- PASS: TestAccAWSDbInstanceDataSource_basic (617.92s)
--- PASS: TestAccAWSDbInstanceDataSource_ec2Classic (456.35s)

--- PASS: TestAccAWSDBInstance_ec2Classic (406.18s)
```
  • Loading branch information
bflad authored Sep 17, 2020
1 parent 226b15b commit f9747e1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
32 changes: 28 additions & 4 deletions aws/data_source_aws_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ func TestAccAWSDbInstanceDataSource_ec2Classic(t *testing.T) {

func testAccAWSDBInstanceDataSourceConfig(rInt int) string {
return fmt.Sprintf(`
data "aws_rds_orderable_db_instance" "test" {
engine = "mariadb"
preferred_instance_classes = ["db.t3.micro", "db.t2.micro", "db.t3.small"]
}
resource "aws_db_instance" "bar" {
identifier = "datasource-test-terraform-%d"
allocated_storage = 10
engine = "mariadb"
instance_class = "db.t2.micro"
engine = data.aws_rds_orderable_db_instance.test.engine
instance_class = data.aws_rds_orderable_db_instance.test.instance_class
name = "baz"
password = "barbarbarbar"
username = "foo"
Expand All @@ -95,10 +100,29 @@ data "aws_db_instance" "bar" {

func testAccAWSDBInstanceDataSourceConfig_ec2Classic(rInt int) string {
return fmt.Sprintf(`
%s
data "aws_rds_orderable_db_instance" "test" {
engine = "mysql"
engine_version = "5.6.41"
preferred_instance_classes = ["db.m3.medium", "db.m3.large", "db.r3.large"]
}
resource "aws_db_instance" "bar" {
identifier = "foobarbaz-test-terraform-%[1]d"
allocated_storage = 10
engine = data.aws_rds_orderable_db_instance.test.engine
engine_version = data.aws_rds_orderable_db_instance.test.engine_version
instance_class = data.aws_rds_orderable_db_instance.test.instance_class
name = "baz"
password = "barbarbarbar"
username = "foo"
publicly_accessible = true
security_group_names = ["default"]
parameter_group_name = "default.mysql5.6"
skip_final_snapshot = true
}
data "aws_db_instance" "bar" {
db_instance_identifier = aws_db_instance.bar.identifier
}
`, testAccAWSDBInstanceConfigEc2Classic(rInt))
`, rInt)
}
14 changes: 10 additions & 4 deletions aws/resource_aws_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4559,12 +4559,18 @@ resource "aws_db_instance" "bar" {

func testAccAWSDBInstanceConfigEc2Classic(rInt int) string {
return fmt.Sprintf(`
data "aws_rds_orderable_db_instance" "test" {
engine = "mysql"
engine_version = "5.6.41"
preferred_instance_classes = ["db.m3.medium", "db.m3.large", "db.r3.large"]
}
resource "aws_db_instance" "bar" {
identifier = "foobarbaz-test-terraform-%d"
identifier = "foobarbaz-test-terraform-%[1]d"
allocated_storage = 10
engine = "mysql"
engine_version = "5.6"
instance_class = "db.m5.large"
engine = data.aws_rds_orderable_db_instance.test.engine
engine_version = data.aws_rds_orderable_db_instance.test.engine_version
instance_class = data.aws_rds_orderable_db_instance.test.instance_class
name = "baz"
password = "barbarbarbar"
username = "foo"
Expand Down

0 comments on commit f9747e1

Please sign in to comment.