provider/aws: Ranomize LB names so tests can run at the same time
This commit is contained in:
parent
a8de40090a
commit
6f04c36a1a
|
@ -8,18 +8,20 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/elb"
|
"github.com/aws/aws-sdk-go/service/elb"
|
||||||
|
|
||||||
|
"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 TestAccAWSAppCookieStickinessPolicy_basic(t *testing.T) {
|
func TestAccAWSAppCookieStickinessPolicy_basic(t *testing.T) {
|
||||||
|
lbName := fmt.Sprintf("tf-test-lb-%s", acctest.RandString(5))
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAppCookieStickinessPolicyDestroy,
|
CheckDestroy: testAccCheckAppCookieStickinessPolicyDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAppCookieStickinessPolicyConfig,
|
Config: testAccAppCookieStickinessPolicyConfig(lbName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAppCookieStickinessPolicy(
|
testAccCheckAppCookieStickinessPolicy(
|
||||||
"aws_elb.lb",
|
"aws_elb.lb",
|
||||||
|
@ -28,7 +30,7 @@ func TestAccAWSAppCookieStickinessPolicy_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccAppCookieStickinessPolicyConfigUpdate,
|
Config: testAccAppCookieStickinessPolicyConfigUpdate(lbName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAppCookieStickinessPolicy(
|
testAccCheckAppCookieStickinessPolicy(
|
||||||
"aws_elb.lb",
|
"aws_elb.lb",
|
||||||
|
@ -100,9 +102,10 @@ func testAccCheckAppCookieStickinessPolicy(elbResource string, policyResource st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccAppCookieStickinessPolicyConfig = `
|
func testAccAppCookieStickinessPolicyConfig(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elb" "lb" {
|
resource "aws_elb" "lb" {
|
||||||
name = "test-lb"
|
name = "%s"
|
||||||
availability_zones = ["us-west-2a"]
|
availability_zones = ["us-west-2a"]
|
||||||
listener {
|
listener {
|
||||||
instance_port = 8000
|
instance_port = 8000
|
||||||
|
@ -117,13 +120,14 @@ resource "aws_app_cookie_stickiness_policy" "foo" {
|
||||||
load_balancer = "${aws_elb.lb.id}"
|
load_balancer = "${aws_elb.lb.id}"
|
||||||
lb_port = 80
|
lb_port = 80
|
||||||
cookie_name = "MyAppCookie"
|
cookie_name = "MyAppCookie"
|
||||||
|
}`, rName)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
// Change the cookie_name to "MyOtherAppCookie".
|
// Change the cookie_name to "MyOtherAppCookie".
|
||||||
const testAccAppCookieStickinessPolicyConfigUpdate = `
|
func testAccAppCookieStickinessPolicyConfigUpdate(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elb" "lb" {
|
resource "aws_elb" "lb" {
|
||||||
name = "test-lb"
|
name = "%s"
|
||||||
availability_zones = ["us-west-2a"]
|
availability_zones = ["us-west-2a"]
|
||||||
listener {
|
listener {
|
||||||
instance_port = 8000
|
instance_port = 8000
|
||||||
|
@ -138,5 +142,5 @@ resource "aws_app_cookie_stickiness_policy" "foo" {
|
||||||
load_balancer = "${aws_elb.lb.id}"
|
load_balancer = "${aws_elb.lb.id}"
|
||||||
lb_port = 80
|
lb_port = 80
|
||||||
cookie_name = "MyOtherAppCookie"
|
cookie_name = "MyOtherAppCookie"
|
||||||
|
}`, rName)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
|
@ -8,18 +8,20 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/elb"
|
"github.com/aws/aws-sdk-go/service/elb"
|
||||||
|
|
||||||
|
"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 TestAccAWSLBCookieStickinessPolicy_basic(t *testing.T) {
|
func TestAccAWSLBCookieStickinessPolicy_basic(t *testing.T) {
|
||||||
|
lbName := fmt.Sprintf("tf-test-lb-%s", acctest.RandString(5))
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckLBCookieStickinessPolicyDestroy,
|
CheckDestroy: testAccCheckLBCookieStickinessPolicyDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccLBCookieStickinessPolicyConfig,
|
Config: testAccLBCookieStickinessPolicyConfig(lbName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckLBCookieStickinessPolicy(
|
testAccCheckLBCookieStickinessPolicy(
|
||||||
"aws_elb.lb",
|
"aws_elb.lb",
|
||||||
|
@ -28,7 +30,7 @@ func TestAccAWSLBCookieStickinessPolicy_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccLBCookieStickinessPolicyConfigUpdate,
|
Config: testAccLBCookieStickinessPolicyConfigUpdate(lbName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckLBCookieStickinessPolicy(
|
testAccCheckLBCookieStickinessPolicy(
|
||||||
"aws_elb.lb",
|
"aws_elb.lb",
|
||||||
|
@ -100,9 +102,10 @@ func testAccCheckLBCookieStickinessPolicy(elbResource string, policyResource str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccLBCookieStickinessPolicyConfig = `
|
func testAccLBCookieStickinessPolicyConfig(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elb" "lb" {
|
resource "aws_elb" "lb" {
|
||||||
name = "test-lb"
|
name = "%s"
|
||||||
availability_zones = ["us-west-2a"]
|
availability_zones = ["us-west-2a"]
|
||||||
listener {
|
listener {
|
||||||
instance_port = 8000
|
instance_port = 8000
|
||||||
|
@ -116,13 +119,14 @@ resource "aws_lb_cookie_stickiness_policy" "foo" {
|
||||||
name = "foo-policy"
|
name = "foo-policy"
|
||||||
load_balancer = "${aws_elb.lb.id}"
|
load_balancer = "${aws_elb.lb.id}"
|
||||||
lb_port = 80
|
lb_port = 80
|
||||||
|
}`, rName)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
// Sets the cookie_expiration_period to 300s.
|
// Sets the cookie_expiration_period to 300s.
|
||||||
const testAccLBCookieStickinessPolicyConfigUpdate = `
|
func testAccLBCookieStickinessPolicyConfigUpdate(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elb" "lb" {
|
resource "aws_elb" "lb" {
|
||||||
name = "test-lb"
|
name = "%s"
|
||||||
availability_zones = ["us-west-2a"]
|
availability_zones = ["us-west-2a"]
|
||||||
listener {
|
listener {
|
||||||
instance_port = 8000
|
instance_port = 8000
|
||||||
|
@ -137,5 +141,5 @@ resource "aws_lb_cookie_stickiness_policy" "foo" {
|
||||||
load_balancer = "${aws_elb.lb.id}"
|
load_balancer = "${aws_elb.lb.id}"
|
||||||
lb_port = 80
|
lb_port = 80
|
||||||
cookie_expiration_period = 300
|
cookie_expiration_period = 300
|
||||||
|
}`, rName)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
|
@ -6,21 +6,23 @@ import (
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/service/elb"
|
"github.com/aws/aws-sdk-go/service/elb"
|
||||||
|
"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 TestAccAWSProxyProtocolPolicy_basic(t *testing.T) {
|
func TestAccAWSProxyProtocolPolicy_basic(t *testing.T) {
|
||||||
|
lbName := fmt.Sprintf("tf-test-lb-%s", acctest.RandString(5))
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckProxyProtocolPolicyDestroy,
|
CheckDestroy: testAccCheckProxyProtocolPolicyDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccProxyProtocolPolicyConfig,
|
Config: testAccProxyProtocolPolicyConfig(lbName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_proxy_protocol_policy.smtp", "load_balancer", "test-lb"),
|
"aws_proxy_protocol_policy.smtp", "load_balancer", lbName),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_proxy_protocol_policy.smtp", "instance_ports.#", "1"),
|
"aws_proxy_protocol_policy.smtp", "instance_ports.#", "1"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -28,10 +30,10 @@ func TestAccAWSProxyProtocolPolicy_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccProxyProtocolPolicyConfigUpdate,
|
Config: testAccProxyProtocolPolicyConfigUpdate(lbName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_proxy_protocol_policy.smtp", "load_balancer", "test-lb"),
|
"aws_proxy_protocol_policy.smtp", "load_balancer", lbName),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_proxy_protocol_policy.smtp", "instance_ports.#", "2"),
|
"aws_proxy_protocol_policy.smtp", "instance_ports.#", "2"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -70,9 +72,10 @@ func testAccCheckProxyProtocolPolicyDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccProxyProtocolPolicyConfig = `
|
func testAccProxyProtocolPolicyConfig(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elb" "lb" {
|
resource "aws_elb" "lb" {
|
||||||
name = "test-lb"
|
name = "%s"
|
||||||
availability_zones = ["us-west-2a"]
|
availability_zones = ["us-west-2a"]
|
||||||
|
|
||||||
listener {
|
listener {
|
||||||
|
@ -93,12 +96,13 @@ resource "aws_elb" "lb" {
|
||||||
resource "aws_proxy_protocol_policy" "smtp" {
|
resource "aws_proxy_protocol_policy" "smtp" {
|
||||||
load_balancer = "${aws_elb.lb.name}"
|
load_balancer = "${aws_elb.lb.name}"
|
||||||
instance_ports = ["25"]
|
instance_ports = ["25"]
|
||||||
|
}`, rName)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const testAccProxyProtocolPolicyConfigUpdate = `
|
func testAccProxyProtocolPolicyConfigUpdate(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elb" "lb" {
|
resource "aws_elb" "lb" {
|
||||||
name = "test-lb"
|
name = "%s"
|
||||||
availability_zones = ["us-west-2a"]
|
availability_zones = ["us-west-2a"]
|
||||||
|
|
||||||
listener {
|
listener {
|
||||||
|
@ -119,5 +123,5 @@ resource "aws_elb" "lb" {
|
||||||
resource "aws_proxy_protocol_policy" "smtp" {
|
resource "aws_proxy_protocol_policy" "smtp" {
|
||||||
load_balancer = "${aws_elb.lb.name}"
|
load_balancer = "${aws_elb.lb.name}"
|
||||||
instance_ports = ["25", "587"]
|
instance_ports = ["25", "587"]
|
||||||
|
}`, rName)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
Loading…
Reference in New Issue