add randomness to gateway and efs file system tests
This commit is contained in:
parent
da7ef1bb76
commit
5662b7e60f
|
@ -3,19 +3,20 @@ 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 TestAccAWSCustomerGateway_importBasic(t *testing.T) {
|
func TestAccAWSCustomerGateway_importBasic(t *testing.T) {
|
||||||
resourceName := "aws_customer_gateway.foo"
|
resourceName := "aws_customer_gateway.foo"
|
||||||
|
randInt := 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: testAccCheckCustomerGatewayDestroy,
|
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccCustomerGatewayConfig,
|
Config: testAccCustomerGatewayConfig(randInt),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
|
|
|
@ -3,11 +3,13 @@ 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 TestAccAWSEFSFileSystem_importBasic(t *testing.T) {
|
func TestAccAWSEFSFileSystem_importBasic(t *testing.T) {
|
||||||
resourceName := "aws_efs_file_system.foo-with-tags"
|
resourceName := "aws_efs_file_system.foo-with-tags"
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -15,7 +17,7 @@ func TestAccAWSEFSFileSystem_importBasic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAWSEFSFileSystemConfigWithTags,
|
Config: testAccAWSEFSFileSystemConfigWithTags(rInt),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
|
|
|
@ -10,12 +10,14 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/ec2"
|
"github.com/aws/aws-sdk-go/service/ec2"
|
||||||
|
|
||||||
|
"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 TestAccAWSCustomerGateway_basic(t *testing.T) {
|
func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
||||||
var gateway ec2.CustomerGateway
|
var gateway ec2.CustomerGateway
|
||||||
|
randInt := acctest.RandInt()
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
IDRefreshName: "aws_customer_gateway.foo",
|
IDRefreshName: "aws_customer_gateway.foo",
|
||||||
|
@ -23,19 +25,19 @@ func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfig,
|
Config: testAccCustomerGatewayConfig(randInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfigUpdateTags,
|
Config: testAccCustomerGatewayConfigUpdateTags(randInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfigForceReplace,
|
Config: testAccCustomerGatewayConfigForceReplace(randInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
),
|
),
|
||||||
|
@ -46,6 +48,7 @@ func TestAccAWSCustomerGateway_basic(t *testing.T) {
|
||||||
|
|
||||||
func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
||||||
var gateway ec2.CustomerGateway
|
var gateway ec2.CustomerGateway
|
||||||
|
randInt := acctest.RandInt()
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
IDRefreshName: "aws_customer_gateway.foo",
|
IDRefreshName: "aws_customer_gateway.foo",
|
||||||
|
@ -53,13 +56,13 @@ func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfig,
|
Config: testAccCustomerGatewayConfig(randInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfigIdentical,
|
Config: testAccCustomerGatewayConfigIdentical(randInt),
|
||||||
ExpectError: regexp.MustCompile("An existing customer gateway"),
|
ExpectError: regexp.MustCompile("An existing customer gateway"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -68,13 +71,14 @@ func TestAccAWSCustomerGateway_similarAlreadyExists(t *testing.T) {
|
||||||
|
|
||||||
func TestAccAWSCustomerGateway_disappears(t *testing.T) {
|
func TestAccAWSCustomerGateway_disappears(t *testing.T) {
|
||||||
var gateway ec2.CustomerGateway
|
var gateway ec2.CustomerGateway
|
||||||
|
randInt := 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: testAccCheckCustomerGatewayDestroy,
|
CheckDestroy: testAccCheckCustomerGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccCustomerGatewayConfig,
|
Config: testAccCustomerGatewayConfig(randInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
testAccCheckCustomerGateway("aws_customer_gateway.foo", &gateway),
|
||||||
testAccAWSCustomerGatewayDisappears(&gateway),
|
testAccAWSCustomerGatewayDisappears(&gateway),
|
||||||
|
@ -190,59 +194,67 @@ func testAccCheckCustomerGateway(gatewayResource string, cgw *ec2.CustomerGatewa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccCustomerGatewayConfig = `
|
func testAccCustomerGatewayConfig(randInt int) string {
|
||||||
resource "aws_customer_gateway" "foo" {
|
return fmt.Sprintf(`
|
||||||
bgp_asn = 65000
|
resource "aws_customer_gateway" "foo" {
|
||||||
ip_address = "172.0.0.1"
|
bgp_asn = 65000
|
||||||
type = "ipsec.1"
|
ip_address = "172.0.0.1"
|
||||||
tags {
|
type = "ipsec.1"
|
||||||
Name = "foo-gateway"
|
tags {
|
||||||
}
|
Name = "foo-gateway-%d"
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const testAccCustomerGatewayConfigIdentical = `
|
|
||||||
resource "aws_customer_gateway" "foo" {
|
|
||||||
bgp_asn = 65000
|
|
||||||
ip_address = "172.0.0.1"
|
|
||||||
type = "ipsec.1"
|
|
||||||
tags {
|
|
||||||
Name = "foo-gateway"
|
|
||||||
}
|
}
|
||||||
|
`, randInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_customer_gateway" "identical" {
|
func testAccCustomerGatewayConfigIdentical(randInt int) string {
|
||||||
bgp_asn = 65000
|
return fmt.Sprintf(`
|
||||||
ip_address = "172.0.0.1"
|
resource "aws_customer_gateway" "foo" {
|
||||||
type = "ipsec.1"
|
bgp_asn = 65000
|
||||||
tags {
|
ip_address = "172.0.0.1"
|
||||||
Name = "foo-gateway-identical"
|
type = "ipsec.1"
|
||||||
}
|
tags {
|
||||||
|
Name = "foo-gateway-%d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_customer_gateway" "identical" {
|
||||||
|
bgp_asn = 65000
|
||||||
|
ip_address = "172.0.0.1"
|
||||||
|
type = "ipsec.1"
|
||||||
|
tags {
|
||||||
|
Name = "foo-gateway-identical-%d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, randInt, randInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
// Add the Another: "tag" tag.
|
// Add the Another: "tag" tag.
|
||||||
const testAccCustomerGatewayConfigUpdateTags = `
|
func testAccCustomerGatewayConfigUpdateTags(randInt int) string {
|
||||||
resource "aws_customer_gateway" "foo" {
|
return fmt.Sprintf(`
|
||||||
bgp_asn = 65000
|
resource "aws_customer_gateway" "foo" {
|
||||||
ip_address = "172.0.0.1"
|
bgp_asn = 65000
|
||||||
type = "ipsec.1"
|
ip_address = "172.0.0.1"
|
||||||
tags {
|
type = "ipsec.1"
|
||||||
Name = "foo-gateway"
|
tags {
|
||||||
Another = "tag"
|
Name = "foo-gateway-%d"
|
||||||
}
|
Another = "tag-%d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, randInt, randInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
// Change the ip_address.
|
// Change the ip_address.
|
||||||
const testAccCustomerGatewayConfigForceReplace = `
|
func testAccCustomerGatewayConfigForceReplace(randInt int) string {
|
||||||
resource "aws_customer_gateway" "foo" {
|
return fmt.Sprintf(`
|
||||||
bgp_asn = 65000
|
resource "aws_customer_gateway" "foo" {
|
||||||
ip_address = "172.10.10.1"
|
bgp_asn = 65000
|
||||||
type = "ipsec.1"
|
ip_address = "172.10.10.1"
|
||||||
tags {
|
type = "ipsec.1"
|
||||||
Name = "foo-gateway"
|
tags {
|
||||||
Another = "tag"
|
Name = "foo-gateway-%d"
|
||||||
|
Another = "tag-%d"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
`, randInt, randInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ func TestResourceAWSEFSFileSystem_hasEmptyFileSystems(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
func TestAccAWSEFSFileSystem_basic(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,
|
||||||
|
@ -104,7 +105,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccAWSEFSFileSystemConfigWithTags,
|
Config: testAccAWSEFSFileSystemConfigWithTags(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckEfsFileSystem(
|
testAccCheckEfsFileSystem(
|
||||||
"aws_efs_file_system.foo-with-tags",
|
"aws_efs_file_system.foo-with-tags",
|
||||||
|
@ -116,7 +117,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||||
testAccCheckEfsFileSystemTags(
|
testAccCheckEfsFileSystemTags(
|
||||||
"aws_efs_file_system.foo-with-tags",
|
"aws_efs_file_system.foo-with-tags",
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"Name": "foo-efs",
|
"Name": fmt.Sprintf("foo-efs-%d", rInt),
|
||||||
"Another": "tag",
|
"Another": "tag",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -143,13 +144,14 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSEFSFileSystem_pagedTags(t *testing.T) {
|
func TestAccAWSEFSFileSystem_pagedTags(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: testAccCheckEfsFileSystemDestroy,
|
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccAWSEFSFileSystemConfigPagedTags,
|
Config: testAccAWSEFSFileSystemConfigPagedTags(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_efs_file_system.foo",
|
"aws_efs_file_system.foo",
|
||||||
|
@ -312,34 +314,38 @@ resource "aws_efs_file_system" "foo" {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccAWSEFSFileSystemConfigPagedTags = `
|
func testAccAWSEFSFileSystemConfigPagedTags(rInt int) string {
|
||||||
resource "aws_efs_file_system" "foo" {
|
return fmt.Sprintf(`
|
||||||
creation_token = "radeksimko"
|
resource "aws_efs_file_system" "foo" {
|
||||||
tags {
|
creation_token = "radeksimko"
|
||||||
Name = "foo-efs"
|
tags {
|
||||||
Another = "tag"
|
Name = "foo-efs-%d"
|
||||||
Test = "yes"
|
Another = "tag"
|
||||||
User = "root"
|
Test = "yes"
|
||||||
Page = "1"
|
User = "root"
|
||||||
Environment = "prod"
|
Page = "1"
|
||||||
CostCenter = "terraform"
|
Environment = "prod"
|
||||||
AcceptanceTest = "PagedTags"
|
CostCenter = "terraform"
|
||||||
CreationToken = "radek"
|
AcceptanceTest = "PagedTags"
|
||||||
PerfMode = "max"
|
CreationToken = "radek"
|
||||||
Region = "us-west-2"
|
PerfMode = "max"
|
||||||
|
Region = "us-west-2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
`, rInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const testAccAWSEFSFileSystemConfigWithTags = `
|
func testAccAWSEFSFileSystemConfigWithTags(rInt int) string {
|
||||||
resource "aws_efs_file_system" "foo-with-tags" {
|
return fmt.Sprintf(`
|
||||||
creation_token = "yada_yada"
|
resource "aws_efs_file_system" "foo-with-tags" {
|
||||||
tags {
|
creation_token = "yada_yada"
|
||||||
Name = "foo-efs"
|
tags {
|
||||||
Another = "tag"
|
Name = "foo-efs-%d"
|
||||||
|
Another = "tag"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
`, rInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const testAccAWSEFSFileSystemConfigWithPerformanceMode = `
|
const testAccAWSEFSFileSystemConfigWithPerformanceMode = `
|
||||||
resource "aws_efs_file_system" "foo-with-performance-mode" {
|
resource "aws_efs_file_system" "foo-with-performance-mode" {
|
||||||
|
|
Loading…
Reference in New Issue