provider/aws: Fix redshift parameter group acctests

Allows the redshift parameter group acceptance tests handle being ran in parallel better

```
$ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSRedshiftParameterGroup_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/02/09 10:16:19 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSRedshiftParameterGroup_ -timeout 120m
=== RUN   TestAccAWSRedshiftParameterGroup_importBasic
--- PASS: TestAccAWSRedshiftParameterGroup_importBasic (15.17s)
=== RUN   TestAccAWSRedshiftParameterGroup_withParameters
--- PASS: TestAccAWSRedshiftParameterGroup_withParameters (13.16s)
=== RUN   TestAccAWSRedshiftParameterGroup_withoutParameters
--- PASS: TestAccAWSRedshiftParameterGroup_withoutParameters (12.58s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    40.940s
```
This commit is contained in:
Jake Champlin 2017-02-09 10:18:31 -05:00
parent 597bcabd49
commit 35c773a616
No known key found for this signature in database
GPG Key ID: DC31F41958EF4AC2
2 changed files with 41 additions and 33 deletions

View File

@ -3,22 +3,24 @@ package aws
import ( import (
"testing" "testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
) )
func TestAccAWSRedshiftParameterGroup_importBasic(t *testing.T) { func TestAccAWSRedshiftParameterGroup_importBasic(t *testing.T) {
resourceName := "aws_redshift_parameter_group.bar" resourceName := "aws_redshift_parameter_group.bar"
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: testAccCheckAWSRedshiftParameterGroupDestroy, CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccAWSRedshiftParameterGroupConfig, Config: testAccAWSRedshiftParameterGroupConfig(rInt),
}, },
resource.TestStep{ {
ResourceName: resourceName, ResourceName: resourceName,
ImportState: true, ImportState: true,
ImportStateVerify: true, ImportStateVerify: true,

View File

@ -7,24 +7,26 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/redshift" "github.com/aws/aws-sdk-go/service/redshift"
"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"
) )
func TestAccAWSRedshiftParameterGroup_withParameters(t *testing.T) { func TestAccAWSRedshiftParameterGroup_withParameters(t *testing.T) {
var v redshift.ClusterParameterGroup var v redshift.ClusterParameterGroup
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: testAccCheckAWSRedshiftParameterGroupDestroy, CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccAWSRedshiftParameterGroupConfig, Config: testAccAWSRedshiftParameterGroupConfig(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v), testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_parameter_group.bar", "name", "parameter-group-test-terraform"), "aws_redshift_parameter_group.bar", "name", fmt.Sprintf("test-terraform-%d", rInt)),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_parameter_group.bar", "family", "redshift-1.0"), "aws_redshift_parameter_group.bar", "family", "redshift-1.0"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
@ -49,18 +51,19 @@ func TestAccAWSRedshiftParameterGroup_withParameters(t *testing.T) {
func TestAccAWSRedshiftParameterGroup_withoutParameters(t *testing.T) { func TestAccAWSRedshiftParameterGroup_withoutParameters(t *testing.T) {
var v redshift.ClusterParameterGroup var v redshift.ClusterParameterGroup
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: testAccCheckAWSRedshiftParameterGroupDestroy, CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
Steps: []resource.TestStep{ Steps: []resource.TestStep{
resource.TestStep{ {
Config: testAccAWSRedshiftParameterGroupOnlyConfig, Config: testAccAWSRedshiftParameterGroupOnlyConfig(rInt),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v), testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_parameter_group.bar", "name", "parameter-group-test-terraform"), "aws_redshift_parameter_group.bar", "name", fmt.Sprintf("test-terraform-%d", rInt)),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
"aws_redshift_parameter_group.bar", "family", "redshift-1.0"), "aws_redshift_parameter_group.bar", "family", "redshift-1.0"),
resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
@ -179,28 +182,31 @@ func testAccCheckAWSRedshiftParameterGroupExists(n string, v *redshift.ClusterPa
} }
} }
const testAccAWSRedshiftParameterGroupOnlyConfig = ` func testAccAWSRedshiftParameterGroupOnlyConfig(rInt int) string {
resource "aws_redshift_parameter_group" "bar" { return fmt.Sprintf(`
name = "parameter-group-test-terraform" resource "aws_redshift_parameter_group" "bar" {
family = "redshift-1.0" name = "test-terraform-%d"
description = "Test parameter group for terraform" family = "redshift-1.0"
}` description = "Test parameter group for terraform"
}`, rInt)
const testAccAWSRedshiftParameterGroupConfig = ` }
resource "aws_redshift_parameter_group" "bar" {
name = "parameter-group-test-terraform" func testAccAWSRedshiftParameterGroupConfig(rInt int) string {
family = "redshift-1.0" return fmt.Sprintf(`
parameter { resource "aws_redshift_parameter_group" "bar" {
name = "require_ssl" name = "test-terraform-%d"
value = "true" family = "redshift-1.0"
} parameter {
parameter { name = "require_ssl"
name = "query_group" value = "true"
value = "example" }
} parameter {
parameter{ name = "query_group"
name = "enable_user_activity_logging" value = "example"
value = "true" }
} parameter{
name = "enable_user_activity_logging"
value = "true"
}
}`, rInt)
} }
`