Skip to content

Commit

Permalink
provider/aws: Randomize an ASG/LC test
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed May 23, 2016
1 parent b46dcd9 commit 5fcc089
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions builtin/providers/aws/resource_aws_autoscaling_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,30 @@ import (
func TestAccAWSAutoscalingPolicy_basic(t *testing.T) {
var policy autoscaling.ScalingPolicy

name := fmt.Sprintf("terraform-test-foobar-%s", acctest.RandString(5))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoscalingPolicyDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSAutoscalingPolicyConfig,
Config: testAccAWSAutoscalingPolicyConfig(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckScalingPolicyExists("aws_autoscaling_policy.foobar_simple", &policy),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "adjustment_type", "ChangeInCapacity"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "policy_type", "SimpleScaling"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "cooldown", "300"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "name", "foobar_simple"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "scaling_adjustment", "2"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "autoscaling_group_name", "terraform-test-foobar5"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_simple", "autoscaling_group_name", name),
testAccCheckScalingPolicyExists("aws_autoscaling_policy.foobar_step", &policy),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "adjustment_type", "ChangeInCapacity"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "policy_type", "StepScaling"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "name", "foobar_step"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "metric_aggregation_type", "Minimum"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "estimated_instance_warmup", "200"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "autoscaling_group_name", "terraform-test-foobar5"),
resource.TestCheckResourceAttr("aws_autoscaling_policy.foobar_step", "autoscaling_group_name", name),
),
},
},
Expand Down Expand Up @@ -124,16 +126,17 @@ func testAccCheckAWSAutoscalingPolicyDestroy(s *terraform.State) error {
return nil
}

var testAccAWSAutoscalingPolicyConfig = fmt.Sprintf(`
func testAccAWSAutoscalingPolicyConfig(name string) string {
return fmt.Sprintf(`
resource "aws_launch_configuration" "foobar" {
name = "terraform-test-foobar5"
name = "%s"
image_id = "ami-21f78e11"
instance_type = "t1.micro"
}
resource "aws_autoscaling_group" "foobar" {
availability_zones = ["us-west-2a"]
name = "terraform-test-foobar5"
name = "%s"
max_size = 5
min_size = 2
health_check_grace_period = 300
Expand Down Expand Up @@ -169,7 +172,8 @@ resource "aws_autoscaling_policy" "foobar_step" {
}
autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
}
`)
`, name, name)
}

func testAccAWSAutoscalingPolicyConfig_upgrade_614(name string) string {
return fmt.Sprintf(`
Expand Down

0 comments on commit 5fcc089

Please sign in to comment.