terraform/builtin/providers/azurerm/resource_arm_loadbalancer_r...

527 lines
16 KiB
Go
Raw Normal View History

provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
package azurerm
import (
"fmt"
2016-10-17 16:10:17 +02:00
"os"
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
"testing"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
func TestResourceAzureRMLoadBalancerRuleNameLabel_validation(t *testing.T) {
cases := []struct {
Value string
ErrCount int
}{
{
Value: "-word",
ErrCount: 1,
},
{
Value: "testing-",
ErrCount: 1,
},
{
Value: "test#test",
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
ErrCount: 1,
},
{
Value: acctest.RandStringFromCharSet(81, "abcdedfed"),
ErrCount: 1,
},
{
Value: "test.rule",
ErrCount: 0,
},
{
Value: "test_rule",
ErrCount: 0,
},
{
Value: "test-rule",
ErrCount: 0,
},
{
Value: "TestRule",
ErrCount: 0,
},
{
Value: "Test123Rule",
ErrCount: 0,
},
{
Value: "TestRule",
ErrCount: 0,
},
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
}
for _, tc := range cases {
_, errors := validateArmLoadBalancerRuleName(tc.Value, "azurerm_lb_rule")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected the Azure RM LoadBalancer Rule Name Label to trigger a validation error")
}
}
}
func TestAccAzureRMLoadBalancerRule_basic(t *testing.T) {
var lb network.LoadBalancer
ri := acctest.RandInt()
lbRuleName := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
2016-10-17 16:10:17 +02:00
subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID")
lbRule_id := fmt.Sprintf(
"/subscriptions/%s/resourceGroups/acctestrg-%d/providers/Microsoft.Network/loadBalancers/arm-test-loadbalancer-%d/loadBalancingRules/%s",
subscriptionID, ri, ri, lbRuleName)
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLoadBalancerRule_basic(ri, lbRuleName),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
2016-10-17 16:10:17 +02:00
resource.TestCheckResourceAttr(
"azurerm_lb_rule.test", "id", lbRule_id),
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
),
},
},
})
}
func TestAccAzureRMLoadBalancerRule_removal(t *testing.T) {
var lb network.LoadBalancer
ri := acctest.RandInt()
lbRuleName := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLoadBalancerRule_basic(ri, lbRuleName),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
),
},
{
Config: testAccAzureRMLoadBalancerRule_removal(ri),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerRuleNotExists(lbRuleName, &lb),
),
},
},
})
}
provider/azurerm: lock mutex in load_balancer resources This fixes races between sub resources causing inconsistent writes of the load balancer resource Fixes #9424 ``` TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMLoadBalancer -timeout 120m === RUN TestAccAzureRMLoadBalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadBalancerBackEndAddressPool_basic (150.95s) === RUN TestAccAzureRMLoadBalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadBalancerBackEndAddressPool_removal (146.25s) === RUN TestAccAzureRMLoadBalancerNatPool_basic --- PASS: TestAccAzureRMLoadBalancerNatPool_basic (157.43s) === RUN TestAccAzureRMLoadBalancerNatPool_removal --- PASS: TestAccAzureRMLoadBalancerNatPool_removal (169.46s) === RUN TestAccAzureRMLoadBalancerNatRule_basic --- PASS: TestAccAzureRMLoadBalancerNatRule_basic (149.04s) === RUN TestAccAzureRMLoadBalancerNatRule_removal --- PASS: TestAccAzureRMLoadBalancerNatRule_removal (170.35s) === RUN TestAccAzureRMLoadBalancerProbe_basic --- PASS: TestAccAzureRMLoadBalancerProbe_basic (146.88s) === RUN TestAccAzureRMLoadBalancerProbe_removal --- PASS: TestAccAzureRMLoadBalancerProbe_removal (166.25s) === RUN TestAccAzureRMLoadBalancerRule_basic --- PASS: TestAccAzureRMLoadBalancerRule_basic (146.36s) === RUN TestAccAzureRMLoadBalancerRule_removal --- PASS: TestAccAzureRMLoadBalancerRule_removal (164.24s) === RUN TestAccAzureRMLoadBalancerRule_inconsistentReads --- PASS: TestAccAzureRMLoadBalancerRule_inconsistentReads (153.19s) === RUN TestAccAzureRMLoadBalancer_basic --- PASS: TestAccAzureRMLoadBalancer_basic (102.59s) === RUN TestAccAzureRMLoadBalancer_frontEndConfig --- PASS: TestAccAzureRMLoadBalancer_frontEndConfig (187.92s) === RUN TestAccAzureRMLoadBalancer_tags --- PASS: TestAccAzureRMLoadBalancer_tags (119.93s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 2130.930s ```
2016-10-19 14:51:47 +02:00
// https://github.com/hashicorp/terraform/issues/9424
func TestAccAzureRMLoadBalancerRule_inconsistentReads(t *testing.T) {
var lb network.LoadBalancer
ri := acctest.RandInt()
backendPoolName := fmt.Sprintf("LbPool-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
lbRuleName := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
probeName := fmt.Sprintf("LbProbe-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLoadBalancerRule_inconsistentRead(ri, backendPoolName, probeName, lbRuleName),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerBackEndAddressPoolExists(backendPoolName, &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
testCheckAzureRMLoadBalancerProbeExists(probeName, &lb),
),
},
},
})
}
provider/azurerm: allow updating load balancer sub-resources (#10016) * provider/azurerm: allow updating of lb_rule resource * check if rule is being updated rather than assuming created * added test to cover guard against multiple rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerRule_" -timeout 120m === RUN TestAccAzureRMLoadBalancerRule_basic --- PASS: TestAccAzureRMLoadBalancerRule_basic (157.45s) === RUN TestAccAzureRMLoadBalancerRule_removal --- PASS: TestAccAzureRMLoadBalancerRule_removal (163.67s) === RUN TestAccAzureRMLoadBalancerRule_inconsistentReads --- PASS: TestAccAzureRMLoadBalancerRule_inconsistentReads (150.00s) === RUN TestAccAzureRMLoadBalancerRule_update --- PASS: TestAccAzureRMLoadBalancerRule_update (164.20s) === RUN TestAccAzureRMLoadBalancerRule_duplicateRules --- PASS: TestAccAzureRMLoadBalancerRule_duplicateRules (137.51s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 772.846s * provider/azurerm: allow updating of lb_nat_rule resource * check if NAT rule is being updated rather than assuming created * added test to cover guard against multiple NAT rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatRule" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatRule_basic --- PASS: TestAccAzureRMLoadBalancerNatRule_basic (148.48s) === RUN TestAccAzureRMLoadBalancerNatRule_removal --- PASS: TestAccAzureRMLoadBalancerNatRule_removal (163.48s) === RUN TestAccAzureRMLoadBalancerNatRule_update --- PASS: TestAccAzureRMLoadBalancerNatRule_update (176.97s) === RUN TestAccAzureRMLoadBalancerNatRule_duplicate --- PASS: TestAccAzureRMLoadBalancerNatRule_duplicate (136.36s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 625.301s * provider/azurerm: allow updating of lb_probe resource * check if probe is being updated rather than assuming created * added test to cover guard against multiple probes with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerProbe" -timeout 120m === RUN TestAccAzureRMLoadBalancerProbe_basic --- PASS: TestAccAzureRMLoadBalancerProbe_basic (134.53s) === RUN TestAccAzureRMLoadBalancerProbe_removal --- PASS: TestAccAzureRMLoadBalancerProbe_removal (168.06s) === RUN TestAccAzureRMLoadBalancerProbe_update --- PASS: TestAccAzureRMLoadBalancerProbe_update (175.99s) === RUN TestAccAzureRMLoadBalancerProbe_duplicate --- PASS: TestAccAzureRMLoadBalancerProbe_duplicate (139.01s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 617.598s * provider/azurerm: allow updating of lb_nat_pool resource * check if NAT pool is being updated rather than assuming created * added test to cover guard against multiple NAT pools with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatPool" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatPool_basic --- PASS: TestAccAzureRMLoadBalancerNatPool_basic (146.52s) === RUN TestAccAzureRMLoadBalancerNatPool_removal --- PASS: TestAccAzureRMLoadBalancerNatPool_removal (158.34s) === RUN TestAccAzureRMLoadBalancerNatPool_update --- PASS: TestAccAzureRMLoadBalancerNatPool_update (174.05s) === RUN TestAccAzureRMLoadBalancerNatPool_duplicate --- PASS: TestAccAzureRMLoadBalancerNatPool_duplicate (136.94s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 615.866s
2016-11-11 12:09:00 +01:00
func TestAccAzureRMLoadBalancerRule_update(t *testing.T) {
var lb network.LoadBalancer
ri := acctest.RandInt()
lbRuleName := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
lbRule2Name := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID")
lbRuleID := fmt.Sprintf(
"/subscriptions/%s/resourceGroups/acctestrg-%d/providers/Microsoft.Network/loadBalancers/arm-test-loadbalancer-%d/loadBalancingRules/%s",
subscriptionID, ri, ri, lbRuleName)
lbRule2ID := fmt.Sprintf(
"/subscriptions/%s/resourceGroups/acctestrg-%d/providers/Microsoft.Network/loadBalancers/arm-test-loadbalancer-%d/loadBalancingRules/%s",
subscriptionID, ri, ri, lbRule2Name)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLoadBalancerRule_multipleRules(ri, lbRuleName, lbRule2Name),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRule2Name, &lb),
resource.TestCheckResourceAttr("azurerm_lb_rule.test", "id", lbRuleID),
resource.TestCheckResourceAttr("azurerm_lb_rule.test2", "id", lbRule2ID),
resource.TestCheckResourceAttr("azurerm_lb_rule.test2", "frontend_port", "3390"),
resource.TestCheckResourceAttr("azurerm_lb_rule.test2", "backend_port", "3390"),
),
},
{
Config: testAccAzureRMLoadBalancerRule_multipleRulesUpdate(ri, lbRuleName, lbRule2Name),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRule2Name, &lb),
resource.TestCheckResourceAttr("azurerm_lb_rule.test", "id", lbRuleID),
resource.TestCheckResourceAttr("azurerm_lb_rule.test2", "id", lbRule2ID),
resource.TestCheckResourceAttr("azurerm_lb_rule.test2", "frontend_port", "3391"),
resource.TestCheckResourceAttr("azurerm_lb_rule.test2", "backend_port", "3391"),
),
},
},
})
}
func TestAccAzureRMLoadBalancerRule_reapply(t *testing.T) {
provider/azurerm: allow updating load balancer sub-resources (#10016) * provider/azurerm: allow updating of lb_rule resource * check if rule is being updated rather than assuming created * added test to cover guard against multiple rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerRule_" -timeout 120m === RUN TestAccAzureRMLoadBalancerRule_basic --- PASS: TestAccAzureRMLoadBalancerRule_basic (157.45s) === RUN TestAccAzureRMLoadBalancerRule_removal --- PASS: TestAccAzureRMLoadBalancerRule_removal (163.67s) === RUN TestAccAzureRMLoadBalancerRule_inconsistentReads --- PASS: TestAccAzureRMLoadBalancerRule_inconsistentReads (150.00s) === RUN TestAccAzureRMLoadBalancerRule_update --- PASS: TestAccAzureRMLoadBalancerRule_update (164.20s) === RUN TestAccAzureRMLoadBalancerRule_duplicateRules --- PASS: TestAccAzureRMLoadBalancerRule_duplicateRules (137.51s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 772.846s * provider/azurerm: allow updating of lb_nat_rule resource * check if NAT rule is being updated rather than assuming created * added test to cover guard against multiple NAT rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatRule" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatRule_basic --- PASS: TestAccAzureRMLoadBalancerNatRule_basic (148.48s) === RUN TestAccAzureRMLoadBalancerNatRule_removal --- PASS: TestAccAzureRMLoadBalancerNatRule_removal (163.48s) === RUN TestAccAzureRMLoadBalancerNatRule_update --- PASS: TestAccAzureRMLoadBalancerNatRule_update (176.97s) === RUN TestAccAzureRMLoadBalancerNatRule_duplicate --- PASS: TestAccAzureRMLoadBalancerNatRule_duplicate (136.36s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 625.301s * provider/azurerm: allow updating of lb_probe resource * check if probe is being updated rather than assuming created * added test to cover guard against multiple probes with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerProbe" -timeout 120m === RUN TestAccAzureRMLoadBalancerProbe_basic --- PASS: TestAccAzureRMLoadBalancerProbe_basic (134.53s) === RUN TestAccAzureRMLoadBalancerProbe_removal --- PASS: TestAccAzureRMLoadBalancerProbe_removal (168.06s) === RUN TestAccAzureRMLoadBalancerProbe_update --- PASS: TestAccAzureRMLoadBalancerProbe_update (175.99s) === RUN TestAccAzureRMLoadBalancerProbe_duplicate --- PASS: TestAccAzureRMLoadBalancerProbe_duplicate (139.01s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 617.598s * provider/azurerm: allow updating of lb_nat_pool resource * check if NAT pool is being updated rather than assuming created * added test to cover guard against multiple NAT pools with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatPool" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatPool_basic --- PASS: TestAccAzureRMLoadBalancerNatPool_basic (146.52s) === RUN TestAccAzureRMLoadBalancerNatPool_removal --- PASS: TestAccAzureRMLoadBalancerNatPool_removal (158.34s) === RUN TestAccAzureRMLoadBalancerNatPool_update --- PASS: TestAccAzureRMLoadBalancerNatPool_update (174.05s) === RUN TestAccAzureRMLoadBalancerNatPool_duplicate --- PASS: TestAccAzureRMLoadBalancerNatPool_duplicate (136.94s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 615.866s
2016-11-11 12:09:00 +01:00
var lb network.LoadBalancer
ri := acctest.RandInt()
lbRuleName := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
deleteRuleState := func(s *terraform.State) error {
return s.Remove("azurerm_lb_rule.test")
}
provider/azurerm: allow updating load balancer sub-resources (#10016) * provider/azurerm: allow updating of lb_rule resource * check if rule is being updated rather than assuming created * added test to cover guard against multiple rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerRule_" -timeout 120m === RUN TestAccAzureRMLoadBalancerRule_basic --- PASS: TestAccAzureRMLoadBalancerRule_basic (157.45s) === RUN TestAccAzureRMLoadBalancerRule_removal --- PASS: TestAccAzureRMLoadBalancerRule_removal (163.67s) === RUN TestAccAzureRMLoadBalancerRule_inconsistentReads --- PASS: TestAccAzureRMLoadBalancerRule_inconsistentReads (150.00s) === RUN TestAccAzureRMLoadBalancerRule_update --- PASS: TestAccAzureRMLoadBalancerRule_update (164.20s) === RUN TestAccAzureRMLoadBalancerRule_duplicateRules --- PASS: TestAccAzureRMLoadBalancerRule_duplicateRules (137.51s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 772.846s * provider/azurerm: allow updating of lb_nat_rule resource * check if NAT rule is being updated rather than assuming created * added test to cover guard against multiple NAT rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatRule" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatRule_basic --- PASS: TestAccAzureRMLoadBalancerNatRule_basic (148.48s) === RUN TestAccAzureRMLoadBalancerNatRule_removal --- PASS: TestAccAzureRMLoadBalancerNatRule_removal (163.48s) === RUN TestAccAzureRMLoadBalancerNatRule_update --- PASS: TestAccAzureRMLoadBalancerNatRule_update (176.97s) === RUN TestAccAzureRMLoadBalancerNatRule_duplicate --- PASS: TestAccAzureRMLoadBalancerNatRule_duplicate (136.36s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 625.301s * provider/azurerm: allow updating of lb_probe resource * check if probe is being updated rather than assuming created * added test to cover guard against multiple probes with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerProbe" -timeout 120m === RUN TestAccAzureRMLoadBalancerProbe_basic --- PASS: TestAccAzureRMLoadBalancerProbe_basic (134.53s) === RUN TestAccAzureRMLoadBalancerProbe_removal --- PASS: TestAccAzureRMLoadBalancerProbe_removal (168.06s) === RUN TestAccAzureRMLoadBalancerProbe_update --- PASS: TestAccAzureRMLoadBalancerProbe_update (175.99s) === RUN TestAccAzureRMLoadBalancerProbe_duplicate --- PASS: TestAccAzureRMLoadBalancerProbe_duplicate (139.01s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 617.598s * provider/azurerm: allow updating of lb_nat_pool resource * check if NAT pool is being updated rather than assuming created * added test to cover guard against multiple NAT pools with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatPool" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatPool_basic --- PASS: TestAccAzureRMLoadBalancerNatPool_basic (146.52s) === RUN TestAccAzureRMLoadBalancerNatPool_removal --- PASS: TestAccAzureRMLoadBalancerNatPool_removal (158.34s) === RUN TestAccAzureRMLoadBalancerNatPool_update --- PASS: TestAccAzureRMLoadBalancerNatPool_update (174.05s) === RUN TestAccAzureRMLoadBalancerNatPool_duplicate --- PASS: TestAccAzureRMLoadBalancerNatPool_duplicate (136.94s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 615.866s
2016-11-11 12:09:00 +01:00
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLoadBalancerRule_basic(ri, lbRuleName),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
deleteRuleState,
),
ExpectNonEmptyPlan: true,
},
{
Config: testAccAzureRMLoadBalancerRule_basic(ri, lbRuleName),
provider/azurerm: allow updating load balancer sub-resources (#10016) * provider/azurerm: allow updating of lb_rule resource * check if rule is being updated rather than assuming created * added test to cover guard against multiple rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerRule_" -timeout 120m === RUN TestAccAzureRMLoadBalancerRule_basic --- PASS: TestAccAzureRMLoadBalancerRule_basic (157.45s) === RUN TestAccAzureRMLoadBalancerRule_removal --- PASS: TestAccAzureRMLoadBalancerRule_removal (163.67s) === RUN TestAccAzureRMLoadBalancerRule_inconsistentReads --- PASS: TestAccAzureRMLoadBalancerRule_inconsistentReads (150.00s) === RUN TestAccAzureRMLoadBalancerRule_update --- PASS: TestAccAzureRMLoadBalancerRule_update (164.20s) === RUN TestAccAzureRMLoadBalancerRule_duplicateRules --- PASS: TestAccAzureRMLoadBalancerRule_duplicateRules (137.51s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 772.846s * provider/azurerm: allow updating of lb_nat_rule resource * check if NAT rule is being updated rather than assuming created * added test to cover guard against multiple NAT rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatRule" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatRule_basic --- PASS: TestAccAzureRMLoadBalancerNatRule_basic (148.48s) === RUN TestAccAzureRMLoadBalancerNatRule_removal --- PASS: TestAccAzureRMLoadBalancerNatRule_removal (163.48s) === RUN TestAccAzureRMLoadBalancerNatRule_update --- PASS: TestAccAzureRMLoadBalancerNatRule_update (176.97s) === RUN TestAccAzureRMLoadBalancerNatRule_duplicate --- PASS: TestAccAzureRMLoadBalancerNatRule_duplicate (136.36s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 625.301s * provider/azurerm: allow updating of lb_probe resource * check if probe is being updated rather than assuming created * added test to cover guard against multiple probes with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerProbe" -timeout 120m === RUN TestAccAzureRMLoadBalancerProbe_basic --- PASS: TestAccAzureRMLoadBalancerProbe_basic (134.53s) === RUN TestAccAzureRMLoadBalancerProbe_removal --- PASS: TestAccAzureRMLoadBalancerProbe_removal (168.06s) === RUN TestAccAzureRMLoadBalancerProbe_update --- PASS: TestAccAzureRMLoadBalancerProbe_update (175.99s) === RUN TestAccAzureRMLoadBalancerProbe_duplicate --- PASS: TestAccAzureRMLoadBalancerProbe_duplicate (139.01s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 617.598s * provider/azurerm: allow updating of lb_nat_pool resource * check if NAT pool is being updated rather than assuming created * added test to cover guard against multiple NAT pools with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatPool" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatPool_basic --- PASS: TestAccAzureRMLoadBalancerNatPool_basic (146.52s) === RUN TestAccAzureRMLoadBalancerNatPool_removal --- PASS: TestAccAzureRMLoadBalancerNatPool_removal (158.34s) === RUN TestAccAzureRMLoadBalancerNatPool_update --- PASS: TestAccAzureRMLoadBalancerNatPool_update (174.05s) === RUN TestAccAzureRMLoadBalancerNatPool_duplicate --- PASS: TestAccAzureRMLoadBalancerNatPool_duplicate (136.94s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 615.866s
2016-11-11 12:09:00 +01:00
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
),
},
},
})
}
func TestAccAzureRMLoadBalancerRule_disappears(t *testing.T) {
var lb network.LoadBalancer
ri := acctest.RandInt()
lbRuleName := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLoadBalancerRule_basic(ri, lbRuleName),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
testCheckAzureRMLoadBalancerRuleDisappears(lbRuleName, &lb),
),
ExpectNonEmptyPlan: true,
},
},
})
}
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
func testCheckAzureRMLoadBalancerRuleExists(lbRuleName string, lb *network.LoadBalancer) resource.TestCheckFunc {
return func(s *terraform.State) error {
_, _, exists := findLoadBalancerRuleByName(lb, lbRuleName)
if !exists {
return fmt.Errorf("A LoadBalancer Rule with name %q cannot be found.", lbRuleName)
}
return nil
}
}
func testCheckAzureRMLoadBalancerRuleNotExists(lbRuleName string, lb *network.LoadBalancer) resource.TestCheckFunc {
return func(s *terraform.State) error {
_, _, exists := findLoadBalancerRuleByName(lb, lbRuleName)
if exists {
return fmt.Errorf("A LoadBalancer Rule with name %q has been found.", lbRuleName)
}
return nil
}
}
func testCheckAzureRMLoadBalancerRuleDisappears(ruleName string, lb *network.LoadBalancer) resource.TestCheckFunc {
return func(s *terraform.State) error {
conn := testAccProvider.Meta().(*ArmClient).loadBalancerClient
_, i, exists := findLoadBalancerRuleByName(lb, ruleName)
if !exists {
return fmt.Errorf("A Rule with name %q cannot be found.", ruleName)
}
currentRules := *lb.LoadBalancerPropertiesFormat.LoadBalancingRules
rules := append(currentRules[:i], currentRules[i+1:]...)
lb.LoadBalancerPropertiesFormat.LoadBalancingRules = &rules
id, err := parseAzureResourceID(*lb.ID)
if err != nil {
return err
}
_, err = conn.CreateOrUpdate(id.ResourceGroup, *lb.Name, *lb, make(chan struct{}))
if err != nil {
return fmt.Errorf("Error Creating/Updating LoadBalancer %s", err)
}
_, err = conn.Get(id.ResourceGroup, *lb.Name, "")
return err
}
}
provider/azurerm: Add Load Balancer resources (#9199) * provider/azurerm: Add AzureRM Loadbalancer resource Adds support for the elusive Azure LoadBalancer * [x] `azurerm_lb` * [x] `azurerm_lb_backend_address_pool` * [x] `azurerm_lb_rule` * [x] `azurerm_lb_nat_rule` * [x] `azurerm_lb_probe` * [x] `azurerm_lb_nat_pool` Test Results: ``` make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLoadbalancer' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMLoadbalancer -timeout 120m === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_basic (207.26s) === RUN TestAccAzureRMLoadbalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadbalancerBackEndAddressPool_removal (165.89s) === RUN TestAccAzureRMLoadbalancerNatRule_basic --- PASS: TestAccAzureRMLoadbalancerNatRule_basic (179.30s) === RUN TestAccAzureRMLoadbalancerNatRule_removal --- PASS: TestAccAzureRMLoadbalancerNatRule_removal (180.73s) === RUN TestAccAzureRMLoadbalancerRule_basic --- PASS: TestAccAzureRMLoadbalancerRule_basic (170.40s) === RUN TestAccAzureRMLoadbalancerRule_removal --- PASS: TestAccAzureRMLoadbalancerRule_removal (204.23s) === RUN TestAccAzureRMLoadbalancer_basic --- PASS: TestAccAzureRMLoadbalancer_basic (136.03s) === RUN TestAccAzureRMLoadbalancer_frontEndConfig --- PASS: TestAccAzureRMLoadbalancer_frontEndConfig (214.47s) === RUN TestAccAzureRMLoadbalancer_tags --- PASS: TestAccAzureRMLoadbalancer_tags (215.52s) === RUN TestAccAzureRMLoadbalancerProbe_basic --- PASS: TestAccAzureRMLoadbalancerProbe_basic (183.36s) === RUN TestAccAzureRMLoadbalancerProbe_removal --- PASS: TestAccAzureRMLoadbalancerProbe_removal (185.86s) === RUN TestAccAzureRMLoadbalancerNatPool_basic --- PASS: TestAccAzureRMLoadbalancerNatPool_basic (161.47s) === RUN TestAccAzureRMLoadbalancerNatPool_removal --- PASS: TestAccAzureRMLoadbalancerNatPool_removal (167.38s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1673.852s ``` * provider/azurerm: Documentation for the ARM LB resources
2016-10-07 20:14:26 +02:00
func testAccAzureRMLoadBalancerRule_basic(rInt int, lbRuleName string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestrg-%d"
location = "West US"
}
resource "azurerm_public_ip" "test" {
name = "test-ip-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
}
resource "azurerm_lb" "test" {
name = "arm-test-loadbalancer-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
frontend_ip_configuration {
name = "one-%d"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
}
resource "azurerm_lb_rule" "test" {
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
name = "%s"
protocol = "Tcp"
frontend_port = 3389
backend_port = 3389
frontend_ip_configuration_name = "one-%d"
}
`, rInt, rInt, rInt, rInt, lbRuleName, rInt)
}
func testAccAzureRMLoadBalancerRule_removal(rInt int) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestrg-%d"
location = "West US"
}
resource "azurerm_public_ip" "test" {
name = "test-ip-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
}
resource "azurerm_lb" "test" {
name = "arm-test-loadbalancer-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
frontend_ip_configuration {
name = "one-%d"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
}
`, rInt, rInt, rInt, rInt)
}
provider/azurerm: lock mutex in load_balancer resources This fixes races between sub resources causing inconsistent writes of the load balancer resource Fixes #9424 ``` TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMLoadBalancer -timeout 120m === RUN TestAccAzureRMLoadBalancerBackEndAddressPool_basic --- PASS: TestAccAzureRMLoadBalancerBackEndAddressPool_basic (150.95s) === RUN TestAccAzureRMLoadBalancerBackEndAddressPool_removal --- PASS: TestAccAzureRMLoadBalancerBackEndAddressPool_removal (146.25s) === RUN TestAccAzureRMLoadBalancerNatPool_basic --- PASS: TestAccAzureRMLoadBalancerNatPool_basic (157.43s) === RUN TestAccAzureRMLoadBalancerNatPool_removal --- PASS: TestAccAzureRMLoadBalancerNatPool_removal (169.46s) === RUN TestAccAzureRMLoadBalancerNatRule_basic --- PASS: TestAccAzureRMLoadBalancerNatRule_basic (149.04s) === RUN TestAccAzureRMLoadBalancerNatRule_removal --- PASS: TestAccAzureRMLoadBalancerNatRule_removal (170.35s) === RUN TestAccAzureRMLoadBalancerProbe_basic --- PASS: TestAccAzureRMLoadBalancerProbe_basic (146.88s) === RUN TestAccAzureRMLoadBalancerProbe_removal --- PASS: TestAccAzureRMLoadBalancerProbe_removal (166.25s) === RUN TestAccAzureRMLoadBalancerRule_basic --- PASS: TestAccAzureRMLoadBalancerRule_basic (146.36s) === RUN TestAccAzureRMLoadBalancerRule_removal --- PASS: TestAccAzureRMLoadBalancerRule_removal (164.24s) === RUN TestAccAzureRMLoadBalancerRule_inconsistentReads --- PASS: TestAccAzureRMLoadBalancerRule_inconsistentReads (153.19s) === RUN TestAccAzureRMLoadBalancer_basic --- PASS: TestAccAzureRMLoadBalancer_basic (102.59s) === RUN TestAccAzureRMLoadBalancer_frontEndConfig --- PASS: TestAccAzureRMLoadBalancer_frontEndConfig (187.92s) === RUN TestAccAzureRMLoadBalancer_tags --- PASS: TestAccAzureRMLoadBalancer_tags (119.93s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 2130.930s ```
2016-10-19 14:51:47 +02:00
// https://github.com/hashicorp/terraform/issues/9424
func testAccAzureRMLoadBalancerRule_inconsistentRead(rInt int, backendPoolName, probeName, lbRuleName string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestrg-%d"
location = "West US"
}
resource "azurerm_public_ip" "test" {
name = "test-ip-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
}
resource "azurerm_lb" "test" {
name = "arm-test-loadbalancer-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
frontend_ip_configuration {
name = "one-%d"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
}
resource "azurerm_lb_backend_address_pool" "teset" {
name = "%s"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
}
resource "azurerm_lb_probe" "test" {
name = "%s"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
protocol = "Tcp"
port = 443
}
resource "azurerm_lb_rule" "test" {
name = "%s"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
protocol = "Tcp"
frontend_port = 3389
backend_port = 3389
frontend_ip_configuration_name = "one-%d"
}
`, rInt, rInt, rInt, rInt, backendPoolName, probeName, lbRuleName, rInt)
}
provider/azurerm: allow updating load balancer sub-resources (#10016) * provider/azurerm: allow updating of lb_rule resource * check if rule is being updated rather than assuming created * added test to cover guard against multiple rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerRule_" -timeout 120m === RUN TestAccAzureRMLoadBalancerRule_basic --- PASS: TestAccAzureRMLoadBalancerRule_basic (157.45s) === RUN TestAccAzureRMLoadBalancerRule_removal --- PASS: TestAccAzureRMLoadBalancerRule_removal (163.67s) === RUN TestAccAzureRMLoadBalancerRule_inconsistentReads --- PASS: TestAccAzureRMLoadBalancerRule_inconsistentReads (150.00s) === RUN TestAccAzureRMLoadBalancerRule_update --- PASS: TestAccAzureRMLoadBalancerRule_update (164.20s) === RUN TestAccAzureRMLoadBalancerRule_duplicateRules --- PASS: TestAccAzureRMLoadBalancerRule_duplicateRules (137.51s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 772.846s * provider/azurerm: allow updating of lb_nat_rule resource * check if NAT rule is being updated rather than assuming created * added test to cover guard against multiple NAT rules with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatRule" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatRule_basic --- PASS: TestAccAzureRMLoadBalancerNatRule_basic (148.48s) === RUN TestAccAzureRMLoadBalancerNatRule_removal --- PASS: TestAccAzureRMLoadBalancerNatRule_removal (163.48s) === RUN TestAccAzureRMLoadBalancerNatRule_update --- PASS: TestAccAzureRMLoadBalancerNatRule_update (176.97s) === RUN TestAccAzureRMLoadBalancerNatRule_duplicate --- PASS: TestAccAzureRMLoadBalancerNatRule_duplicate (136.36s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 625.301s * provider/azurerm: allow updating of lb_probe resource * check if probe is being updated rather than assuming created * added test to cover guard against multiple probes with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerProbe" -timeout 120m === RUN TestAccAzureRMLoadBalancerProbe_basic --- PASS: TestAccAzureRMLoadBalancerProbe_basic (134.53s) === RUN TestAccAzureRMLoadBalancerProbe_removal --- PASS: TestAccAzureRMLoadBalancerProbe_removal (168.06s) === RUN TestAccAzureRMLoadBalancerProbe_update --- PASS: TestAccAzureRMLoadBalancerProbe_update (175.99s) === RUN TestAccAzureRMLoadBalancerProbe_duplicate --- PASS: TestAccAzureRMLoadBalancerProbe_duplicate (139.01s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 617.598s * provider/azurerm: allow updating of lb_nat_pool resource * check if NAT pool is being updated rather than assuming created * added test to cover guard against multiple NAT pools with the same name TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMLoadBalancerNatPool" -timeout 120m === RUN TestAccAzureRMLoadBalancerNatPool_basic --- PASS: TestAccAzureRMLoadBalancerNatPool_basic (146.52s) === RUN TestAccAzureRMLoadBalancerNatPool_removal --- PASS: TestAccAzureRMLoadBalancerNatPool_removal (158.34s) === RUN TestAccAzureRMLoadBalancerNatPool_update --- PASS: TestAccAzureRMLoadBalancerNatPool_update (174.05s) === RUN TestAccAzureRMLoadBalancerNatPool_duplicate --- PASS: TestAccAzureRMLoadBalancerNatPool_duplicate (136.94s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 615.866s
2016-11-11 12:09:00 +01:00
func testAccAzureRMLoadBalancerRule_multipleRules(rInt int, lbRuleName, lbRule2Name string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestrg-%d"
location = "West US"
}
resource "azurerm_public_ip" "test" {
name = "test-ip-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
}
resource "azurerm_lb" "test" {
name = "arm-test-loadbalancer-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
frontend_ip_configuration {
name = "one-%d"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
}
resource "azurerm_lb_rule" "test" {
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
name = "%s"
protocol = "Udp"
frontend_port = 3389
backend_port = 3389
frontend_ip_configuration_name = "one-%d"
}
resource "azurerm_lb_rule" "test2" {
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
name = "%s"
protocol = "Udp"
frontend_port = 3390
backend_port = 3390
frontend_ip_configuration_name = "one-%d"
}
`, rInt, rInt, rInt, rInt, lbRuleName, rInt, lbRule2Name, rInt)
}
func testAccAzureRMLoadBalancerRule_multipleRulesUpdate(rInt int, lbRuleName, lbRule2Name string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestrg-%d"
location = "West US"
}
resource "azurerm_public_ip" "test" {
name = "test-ip-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
}
resource "azurerm_lb" "test" {
name = "arm-test-loadbalancer-%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
frontend_ip_configuration {
name = "one-%d"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
}
resource "azurerm_lb_rule" "test" {
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
name = "%s"
protocol = "Udp"
frontend_port = 3389
backend_port = 3389
frontend_ip_configuration_name = "one-%d"
}
resource "azurerm_lb_rule" "test2" {
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
name = "%s"
protocol = "Udp"
frontend_port = 3391
backend_port = 3391
frontend_ip_configuration_name = "one-%d"
}
`, rInt, rInt, rInt, rInt, lbRuleName, rInt, lbRule2Name, rInt)
}