From 15aabe93c3a31ab75a33930985c249492c8e0a96 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 24 Apr 2017 15:23:52 -0600 Subject: [PATCH] Randomize mongodb names --- .../aws/resource_aws_ecs_service_test.go | 135 ++++++++++-------- 1 file changed, 76 insertions(+), 59 deletions(-) diff --git a/builtin/providers/aws/resource_aws_ecs_service_test.go b/builtin/providers/aws/resource_aws_ecs_service_test.go index f622d64b7..c3a603547 100644 --- a/builtin/providers/aws/resource_aws_ecs_service_test.go +++ b/builtin/providers/aws/resource_aws_ecs_service_test.go @@ -85,20 +85,21 @@ func TestParseTaskDefinition(t *testing.T) { } func TestAccAWSEcsServiceWithARN(t *testing.T) { + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsService, + Config: testAccAWSEcsService(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"), ), }, { - Config: testAccAWSEcsServiceModified, + Config: testAccAWSEcsServiceModified(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"), ), @@ -181,13 +182,14 @@ func TestAccAWSEcsService_withIamRole(t *testing.T) { } func TestAccAWSEcsService_withDeploymentValues(t *testing.T) { + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsServiceWithDeploymentValues, + Config: testAccAWSEcsServiceWithDeploymentValues(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"), resource.TestCheckResourceAttr( @@ -262,20 +264,21 @@ func TestAccAWSEcsService_withAlb(t *testing.T) { } func TestAccAWSEcsServiceWithPlacementStrategy(t *testing.T) { + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsService, + Config: testAccAWSEcsService(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"), resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_strategy.#", "0"), ), }, { - Config: testAccAWSEcsServiceWithPlacementStrategy, + Config: testAccAWSEcsServiceWithPlacementStrategy(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"), resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_strategy.#", "1"), @@ -286,13 +289,14 @@ func TestAccAWSEcsServiceWithPlacementStrategy(t *testing.T) { } func TestAccAWSEcsServiceWithPlacementConstraints(t *testing.T) { + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsServiceWithPlacementConstraint, + Config: testAccAWSEcsServiceWithPlacementConstraint(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"), resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_constraints.#", "1"), @@ -303,13 +307,14 @@ func TestAccAWSEcsServiceWithPlacementConstraints(t *testing.T) { } func TestAccAWSEcsServiceWithPlacementConstraints_emptyExpression(t *testing.T) { + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSEcsServiceDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsServiceWithPlacementConstraintEmptyExpression, + Config: testAccAWSEcsServiceWithPlacementConstraintEmptyExpression(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"), resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_constraints.#", "1"), @@ -366,9 +371,10 @@ func testAccCheckAWSEcsServiceExists(name string) resource.TestCheckFunc { } } -var testAccAWSEcsService = ` +func testAccAWSEcsService(rInt int) string { + return fmt.Sprintf(` resource "aws_ecs_cluster" "default" { - name = "terraformecstest1" + name = "terraformecstest%d" } resource "aws_ecs_task_definition" "mongo" { @@ -387,16 +393,18 @@ DEFINITION } resource "aws_ecs_service" "mongo" { - name = "mongodb" + name = "mongodb-%d" cluster = "${aws_ecs_cluster.default.id}" task_definition = "${aws_ecs_task_definition.mongo.arn}" desired_count = 1 } -` +`, rInt, rInt) +} -var testAccAWSEcsServiceModified = ` +func testAccAWSEcsServiceModified(rInt int) string { + return fmt.Sprintf(` resource "aws_ecs_cluster" "default" { - name = "terraformecstest1" + name = "terraformecstest%d" } resource "aws_ecs_task_definition" "mongo" { @@ -415,16 +423,18 @@ DEFINITION } resource "aws_ecs_service" "mongo" { - name = "mongodb" + name = "mongodb-%d" cluster = "${aws_ecs_cluster.default.id}" task_definition = "${aws_ecs_task_definition.mongo.arn}" desired_count = 2 } -` +`, rInt, rInt) +} -var testAccAWSEcsServiceWithPlacementStrategy = ` +func testAccAWSEcsServiceWithPlacementStrategy(rInt int) string { + return fmt.Sprintf(` resource "aws_ecs_cluster" "default" { - name = "terraformecstest1" + name = "terraformecstest%d" } resource "aws_ecs_task_definition" "mongo" { @@ -443,7 +453,7 @@ DEFINITION } resource "aws_ecs_service" "mongo" { - name = "mongodb" + name = "mongodb-%d" cluster = "${aws_ecs_cluster.default.id}" task_definition = "${aws_ecs_task_definition.mongo.arn}" desired_count = 1 @@ -452,43 +462,47 @@ resource "aws_ecs_service" "mongo" { field = "memory" } } -` +`, rInt, rInt) +} -var testAccAWSEcsServiceWithPlacementConstraint = ` +func testAccAWSEcsServiceWithPlacementConstraint(rInt int) string { + return fmt.Sprintf(` + resource "aws_ecs_cluster" "default" { + name = "terraformecstest%d" + } + + resource "aws_ecs_task_definition" "mongo" { + family = "mongodb" + container_definitions = <