Skip to content

Commit

Permalink
tests/resource/aws_ecs_service: Reinstate nonexistent import test and…
Browse files Browse the repository at this point in the history
… ensure testAccCheckAWSEcsServiceDisappears waits for INACTIVE
  • Loading branch information
bflad committed Oct 5, 2018
1 parent 5b77b23 commit 44074aa
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions aws/resource_aws_ecs_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ func TestAccAWSEcsService_basicImport(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
// Test non-existent resource import
{
ResourceName: resourceName,
ImportStateId: fmt.Sprintf("%s/nonexistent", clusterName),
ImportState: true,
ImportStateVerify: false,
ExpectError: regexp.MustCompile(`Please verify the ID is correct`),
},
},
})
}
Expand Down Expand Up @@ -825,13 +833,38 @@ func testAccCheckAWSEcsServiceDisappears(service *ecs.Service) resource.TestChec
conn := testAccProvider.Meta().(*AWSClient).ecsconn

input := &ecs.DeleteServiceInput{
Cluster: aws.String(*service.ClusterArn),
Service: aws.String(*service.ServiceName),
Cluster: service.ClusterArn,
Service: service.ServiceName,
Force: aws.Bool(true),
}

_, err := conn.DeleteService(input)

if err != nil {
return err
}

// Wait until it's deleted
wait := resource.StateChangeConf{
Pending: []string{"ACTIVE", "DRAINING"},
Target: []string{"INACTIVE"},
Timeout: 10 * time.Minute,
MinTimeout: 1 * time.Second,
Refresh: func() (interface{}, string, error) {
resp, err := conn.DescribeServices(&ecs.DescribeServicesInput{
Cluster: service.ClusterArn,
Services: []*string{service.ServiceName},
})
if err != nil {
return resp, "FAILED", err
}

return resp, aws.StringValue(resp.Services[0].Status), nil
},
}

_, err = wait.WaitForState()

return err
}
}
Expand Down

0 comments on commit 44074aa

Please sign in to comment.