From 9f0c5103d4e4f17b37d69a392c59932e252f9f93 Mon Sep 17 00:00:00 2001 From: Jake Champlin Date: Thu, 9 Feb 2017 09:23:32 -0500 Subject: [PATCH] provider/aws: Fix ECS Task Definition tests When ran in parallel the tests `TestAccAwsEcsTaskDefinition_withNetwork` and `TestAccAwsEcsTaskDefinition_withTask` will overlap with each other due to the shared naming of the `iam_role` resource. This fixes these tests to allow running in parallel on TeamCity. ``` $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAwsEcsTaskDefinition_withTask' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/02/09 09:20:03 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAwsEcsTaskDefinition_withTask -timeout 120m PASS ok github.com/hashicorp/terraform/builtin/providers/aws 0.022s ``` ``` $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAwsEcsTaskDefinition_withNetwork' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/02/09 09:21:10 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAwsEcsTaskDefinition_withNetwork -timeout 120m PASS ok github.com/hashicorp/terraform/builtin/providers/aws 0.026s ``` --- .../resource_aws_ecs_task_definition_test.go | 249 +++++++++--------- 1 file changed, 127 insertions(+), 122 deletions(-) diff --git a/builtin/providers/aws/resource_aws_ecs_task_definition_test.go b/builtin/providers/aws/resource_aws_ecs_task_definition_test.go index ef4602b92..d73296811 100644 --- a/builtin/providers/aws/resource_aws_ecs_task_definition_test.go +++ b/builtin/providers/aws/resource_aws_ecs_task_definition_test.go @@ -6,6 +6,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ecs" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -79,13 +80,14 @@ func TestAccAWSEcsTaskDefinition_withEcsService(t *testing.T) { func TestAccAWSEcsTaskDefinition_withTaskRoleArn(t *testing.T) { var def ecs.TaskDefinition + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSEcsTaskDefinitionDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsTaskDefinitionWithTaskRoleArn, + Config: testAccAWSEcsTaskDefinitionWithTaskRoleArn(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsTaskDefinitionExists("aws_ecs_task_definition.sleep", &def), ), @@ -96,13 +98,14 @@ func TestAccAWSEcsTaskDefinition_withTaskRoleArn(t *testing.T) { func TestAccAWSEcsTaskDefinition_withNetworkMode(t *testing.T) { var def ecs.TaskDefinition + rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAWSEcsTaskDefinitionDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSEcsTaskDefinitionWithNetworkMode, + Config: testAccAWSEcsTaskDefinitionWithNetworkMode(rInt), Check: resource.ComposeTestCheckFunc( testAccCheckAWSEcsTaskDefinitionExists("aws_ecs_task_definition.sleep", &def), resource.TestCheckResourceAttr( @@ -338,132 +341,134 @@ TASK_DEFINITION } ` -var testAccAWSEcsTaskDefinitionWithTaskRoleArn = ` -resource "aws_iam_role" "role_test" { - name = "tf_old_name" - path = "/test/" - assume_role_policy = <