Merge pull request #13508 from hashicorp/p-aws-tes-ecs-service

TestAccAWSEcsServiceWithPlacementConstraints_emptyExpression
This commit is contained in:
Matthew Frahry 2017-04-10 11:18:24 -06:00 committed by GitHub
commit 5be2a50b05
1 changed files with 32 additions and 28 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ecs" "github.com/aws/aws-sdk-go/service/ecs"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -299,13 +300,14 @@ func TestAccAWSEcsServiceWithPlacementConstraints(t *testing.T) {
} }
func TestAccAWSEcsServiceWithPlacementConstraints_emptyExpression(t *testing.T) { func TestAccAWSEcsServiceWithPlacementConstraints_emptyExpression(t *testing.T) {
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders, Providers: testAccProviders,
CheckDestroy: testAccCheckAWSEcsServiceDestroy, CheckDestroy: testAccCheckAWSEcsServiceDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
{ {
Config: testAccAWSEcsServiceWithPlacementConstraintEmptyExpression, Config: testAccAWSEcsServiceWithPlacementConstraintEmptyExpression(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"), testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_constraints.#", "1"), resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_constraints.#", "1"),
@ -482,14 +484,15 @@ resource "aws_ecs_service" "mongo" {
} }
` `
var testAccAWSEcsServiceWithPlacementConstraintEmptyExpression = ` func testAccAWSEcsServiceWithPlacementConstraintEmptyExpression(rInt int) string {
resource "aws_ecs_cluster" "default" { return fmt.Sprintf(`
name = "terraformecstest212" resource "aws_ecs_cluster" "default" {
} name = "terraformecstest%d"
resource "aws_ecs_task_definition" "mongo" { }
resource "aws_ecs_task_definition" "mongo" {
family = "mongodb" family = "mongodb"
container_definitions = <<DEFINITION container_definitions = <<DEFINITION
[ [
{ {
"cpu": 128, "cpu": 128,
"essential": true, "essential": true,
@ -497,19 +500,20 @@ resource "aws_ecs_task_definition" "mongo" {
"memory": 128, "memory": 128,
"name": "mongodb" "name": "mongodb"
} }
] ]
DEFINITION DEFINITION
} }
resource "aws_ecs_service" "mongo" { resource "aws_ecs_service" "mongo" {
name = "mongodb" name = "mongodb-%d"
cluster = "${aws_ecs_cluster.default.id}" cluster = "${aws_ecs_cluster.default.id}"
task_definition = "${aws_ecs_task_definition.mongo.arn}" task_definition = "${aws_ecs_task_definition.mongo.arn}"
desired_count = 1 desired_count = 1
placement_constraints { placement_constraints {
type = "distinctInstance" type = "distinctInstance"
} }
}
`, rInt, rInt)
} }
`
var testAccAWSEcsService_withIamRole = ` var testAccAWSEcsService_withIamRole = `
resource "aws_ecs_cluster" "main" { resource "aws_ecs_cluster" "main" {