Skip to content

Commit 35c773a

Browse files
committed
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 ```
1 parent 597bcab commit 35c773a

2 files changed

Lines changed: 41 additions & 33 deletions

File tree

builtin/providers/aws/import_aws_redshift_parameter_group_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@ package aws
33
import (
44
"testing"
55

6+
"github.com/hashicorp/terraform/helper/acctest"
67
"github.com/hashicorp/terraform/helper/resource"
78
)
89

910
func TestAccAWSRedshiftParameterGroup_importBasic(t *testing.T) {
1011
resourceName := "aws_redshift_parameter_group.bar"
12+
rInt := acctest.RandInt()
1113

1214
resource.Test(t, resource.TestCase{
1315
PreCheck: func() { testAccPreCheck(t) },
1416
Providers: testAccProviders,
1517
CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
1618
Steps: []resource.TestStep{
17-
resource.TestStep{
18-
Config: testAccAWSRedshiftParameterGroupConfig,
19+
{
20+
Config: testAccAWSRedshiftParameterGroupConfig(rInt),
1921
},
2022

21-
resource.TestStep{
23+
{
2224
ResourceName: resourceName,
2325
ImportState: true,
2426
ImportStateVerify: true,

builtin/providers/aws/resource_aws_redshift_parameter_group_test.go

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,26 @@ import (
77
"github.com/aws/aws-sdk-go/aws"
88
"github.com/aws/aws-sdk-go/aws/awserr"
99
"github.com/aws/aws-sdk-go/service/redshift"
10+
"github.com/hashicorp/terraform/helper/acctest"
1011
"github.com/hashicorp/terraform/helper/resource"
1112
"github.com/hashicorp/terraform/terraform"
1213
)
1314

1415
func TestAccAWSRedshiftParameterGroup_withParameters(t *testing.T) {
1516
var v redshift.ClusterParameterGroup
17+
rInt := acctest.RandInt()
1618

1719
resource.Test(t, resource.TestCase{
1820
PreCheck: func() { testAccPreCheck(t) },
1921
Providers: testAccProviders,
2022
CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
2123
Steps: []resource.TestStep{
22-
resource.TestStep{
23-
Config: testAccAWSRedshiftParameterGroupConfig,
24+
{
25+
Config: testAccAWSRedshiftParameterGroupConfig(rInt),
2426
Check: resource.ComposeTestCheckFunc(
2527
testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v),
2628
resource.TestCheckResourceAttr(
27-
"aws_redshift_parameter_group.bar", "name", "parameter-group-test-terraform"),
29+
"aws_redshift_parameter_group.bar", "name", fmt.Sprintf("test-terraform-%d", rInt)),
2830
resource.TestCheckResourceAttr(
2931
"aws_redshift_parameter_group.bar", "family", "redshift-1.0"),
3032
resource.TestCheckResourceAttr(
@@ -49,18 +51,19 @@ func TestAccAWSRedshiftParameterGroup_withParameters(t *testing.T) {
4951

5052
func TestAccAWSRedshiftParameterGroup_withoutParameters(t *testing.T) {
5153
var v redshift.ClusterParameterGroup
54+
rInt := acctest.RandInt()
5255

5356
resource.Test(t, resource.TestCase{
5457
PreCheck: func() { testAccPreCheck(t) },
5558
Providers: testAccProviders,
5659
CheckDestroy: testAccCheckAWSRedshiftParameterGroupDestroy,
5760
Steps: []resource.TestStep{
58-
resource.TestStep{
59-
Config: testAccAWSRedshiftParameterGroupOnlyConfig,
61+
{
62+
Config: testAccAWSRedshiftParameterGroupOnlyConfig(rInt),
6063
Check: resource.ComposeTestCheckFunc(
6164
testAccCheckAWSRedshiftParameterGroupExists("aws_redshift_parameter_group.bar", &v),
6265
resource.TestCheckResourceAttr(
63-
"aws_redshift_parameter_group.bar", "name", "parameter-group-test-terraform"),
66+
"aws_redshift_parameter_group.bar", "name", fmt.Sprintf("test-terraform-%d", rInt)),
6467
resource.TestCheckResourceAttr(
6568
"aws_redshift_parameter_group.bar", "family", "redshift-1.0"),
6669
resource.TestCheckResourceAttr(
@@ -179,28 +182,31 @@ func testAccCheckAWSRedshiftParameterGroupExists(n string, v *redshift.ClusterPa
179182
}
180183
}
181184

182-
const testAccAWSRedshiftParameterGroupOnlyConfig = `
183-
resource "aws_redshift_parameter_group" "bar" {
184-
name = "parameter-group-test-terraform"
185-
family = "redshift-1.0"
186-
description = "Test parameter group for terraform"
187-
}`
188-
189-
const testAccAWSRedshiftParameterGroupConfig = `
190-
resource "aws_redshift_parameter_group" "bar" {
191-
name = "parameter-group-test-terraform"
192-
family = "redshift-1.0"
193-
parameter {
194-
name = "require_ssl"
195-
value = "true"
196-
}
197-
parameter {
198-
name = "query_group"
199-
value = "example"
200-
}
201-
parameter{
202-
name = "enable_user_activity_logging"
203-
value = "true"
204-
}
185+
func testAccAWSRedshiftParameterGroupOnlyConfig(rInt int) string {
186+
return fmt.Sprintf(`
187+
resource "aws_redshift_parameter_group" "bar" {
188+
name = "test-terraform-%d"
189+
family = "redshift-1.0"
190+
description = "Test parameter group for terraform"
191+
}`, rInt)
192+
}
193+
194+
func testAccAWSRedshiftParameterGroupConfig(rInt int) string {
195+
return fmt.Sprintf(`
196+
resource "aws_redshift_parameter_group" "bar" {
197+
name = "test-terraform-%d"
198+
family = "redshift-1.0"
199+
parameter {
200+
name = "require_ssl"
201+
value = "true"
202+
}
203+
parameter {
204+
name = "query_group"
205+
value = "example"
206+
}
207+
parameter{
208+
name = "enable_user_activity_logging"
209+
value = "true"
210+
}
211+
}`, rInt)
205212
}
206-
`

0 commit comments

Comments
 (0)