provider/azurerm: Fixing broken tests / Making Container Registry `sku` optional (#14983)
* Updating the Sku field to be optional * Making the Sku optional * Ensuring we check for a 404 to mark a successful deletion * Upping the size of the internal data disk * Randomizing the Local Network Gateway tests * Fixing a bug in Local Network Gateway's where the deletion wouldn't be detected
This commit is contained in:
parent
76297fc43d
commit
68fe08045b
|
@ -3,22 +3,24 @@ package azurerm
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAzureRMLocalNetworkGateway_importBasic(t *testing.T) {
|
func TestAccAzureRMLocalNetworkGateway_importBasic(t *testing.T) {
|
||||||
resourceName := "azurerm_local_network_gateway.test"
|
resourceName := "azurerm_local_network_gateway.test"
|
||||||
|
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: testCheckAzureRMLocalNetworkGatewayDestroy,
|
CheckDestroy: testCheckAzureRMLocalNetworkGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAzureRMLocalNetworkGatewayConfig_basic,
|
Config: testAccAzureRMLocalNetworkGatewayConfig_basic(rInt),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
{
|
||||||
ResourceName: resourceName,
|
ResourceName: resourceName,
|
||||||
ImportState: true,
|
ImportState: true,
|
||||||
ImportStateVerify: true,
|
ImportStateVerify: true,
|
||||||
|
|
|
@ -45,8 +45,9 @@ func resourceArmContainerRegistry() *schema.Resource {
|
||||||
|
|
||||||
"sku": {
|
"sku": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
Default: string(containerregistry.Basic),
|
||||||
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
|
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
|
||||||
ValidateFunc: validation.StringInSlice([]string{
|
ValidateFunc: validation.StringInSlice([]string{
|
||||||
string(containerregistry.Basic),
|
string(containerregistry.Basic),
|
||||||
|
|
|
@ -171,9 +171,14 @@ func resourceArmEventHubNamespaceDelete(d *schema.ResourceData, meta interface{}
|
||||||
resGroup := id.ResourceGroup
|
resGroup := id.ResourceGroup
|
||||||
name := id.Path["namespaces"]
|
name := id.Path["namespaces"]
|
||||||
|
|
||||||
_, error := namespaceClient.Delete(resGroup, name, make(chan struct{}))
|
deleteResp, error := namespaceClient.Delete(resGroup, name, make(chan struct{}))
|
||||||
|
resp := <-deleteResp
|
||||||
err = <-error
|
err = <-error
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error issuing Azure ARM delete request of EventHub Namespace '%s': %+v", name, err)
|
return fmt.Errorf("Error issuing Azure ARM delete request of EventHub Namespace '%s': %+v", name, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,8 +141,14 @@ func resourceArmLocalNetworkGatewayDelete(d *schema.ResourceData, meta interface
|
||||||
name := id.Path["localNetworkGateways"]
|
name := id.Path["localNetworkGateways"]
|
||||||
resGroup := id.ResourceGroup
|
resGroup := id.ResourceGroup
|
||||||
|
|
||||||
_, error := lnetClient.Delete(resGroup, name, make(chan struct{}))
|
deleteResp, error := lnetClient.Delete(resGroup, name, make(chan struct{}))
|
||||||
|
resp := <-deleteResp
|
||||||
err = <-error
|
err = <-error
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error issuing Azure ARM delete request of local network gateway '%s': %s", name, err)
|
return fmt.Errorf("Error issuing Azure ARM delete request of local network gateway '%s': %s", name, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"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"
|
||||||
)
|
)
|
||||||
|
@ -12,13 +13,14 @@ import (
|
||||||
func TestAccAzureRMLocalNetworkGateway_basic(t *testing.T) {
|
func TestAccAzureRMLocalNetworkGateway_basic(t *testing.T) {
|
||||||
name := "azurerm_local_network_gateway.test"
|
name := "azurerm_local_network_gateway.test"
|
||||||
|
|
||||||
|
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: testCheckAzureRMLocalNetworkGatewayDestroy,
|
CheckDestroy: testCheckAzureRMLocalNetworkGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccAzureRMLocalNetworkGatewayConfig_basic,
|
Config: testAccAzureRMLocalNetworkGatewayConfig_basic(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testCheckAzureRMLocalNetworkGatewayExists(name),
|
testCheckAzureRMLocalNetworkGatewayExists(name),
|
||||||
resource.TestCheckResourceAttr(name, "gateway_address", "127.0.0.1"),
|
resource.TestCheckResourceAttr(name, "gateway_address", "127.0.0.1"),
|
||||||
|
@ -31,6 +33,7 @@ func TestAccAzureRMLocalNetworkGateway_basic(t *testing.T) {
|
||||||
|
|
||||||
func TestAccAzureRMLocalNetworkGateway_disappears(t *testing.T) {
|
func TestAccAzureRMLocalNetworkGateway_disappears(t *testing.T) {
|
||||||
name := "azurerm_local_network_gateway.test"
|
name := "azurerm_local_network_gateway.test"
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -38,7 +41,7 @@ func TestAccAzureRMLocalNetworkGateway_disappears(t *testing.T) {
|
||||||
CheckDestroy: testCheckAzureRMLocalNetworkGatewayDestroy,
|
CheckDestroy: testCheckAzureRMLocalNetworkGatewayDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccAzureRMLocalNetworkGatewayConfig_basic,
|
Config: testAccAzureRMLocalNetworkGatewayConfig_basic(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testCheckAzureRMLocalNetworkGatewayExists(name),
|
testCheckAzureRMLocalNetworkGatewayExists(name),
|
||||||
resource.TestCheckResourceAttr(name, "gateway_address", "127.0.0.1"),
|
resource.TestCheckResourceAttr(name, "gateway_address", "127.0.0.1"),
|
||||||
|
@ -146,17 +149,19 @@ func testCheckAzureRMLocalNetworkGatewayDestroy(s *terraform.State) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccAzureRMLocalNetworkGatewayConfig_basic = `
|
func testAccAzureRMLocalNetworkGatewayConfig_basic(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "azurerm_resource_group" "test" {
|
resource "azurerm_resource_group" "test" {
|
||||||
name = "tftestingResourceGroup"
|
name = "acctest-%d"
|
||||||
location = "West US"
|
location = "West US"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "azurerm_local_network_gateway" "test" {
|
resource "azurerm_local_network_gateway" "test" {
|
||||||
name = "tftestingLocalNetworkGateway"
|
name = "acctestlng-%d"
|
||||||
location = "${azurerm_resource_group.test.location}"
|
location = "${azurerm_resource_group.test.location}"
|
||||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||||
gateway_address = "127.0.0.1"
|
gateway_address = "127.0.0.1"
|
||||||
address_space = ["127.0.0.0/8"]
|
address_space = ["127.0.0.0/8"]
|
||||||
}
|
}
|
||||||
`
|
`, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
|
@ -1018,7 +1018,7 @@ resource "azurerm_virtual_machine" "test" {
|
||||||
name = "osd-%d"
|
name = "osd-%d"
|
||||||
caching = "ReadWrite"
|
caching = "ReadWrite"
|
||||||
create_option = "FromImage"
|
create_option = "FromImage"
|
||||||
disk_size_gb = "10"
|
disk_size_gb = "50"
|
||||||
managed_disk_type = "Standard_LRS"
|
managed_disk_type = "Standard_LRS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,7 +1089,7 @@ resource "azurerm_virtual_machine" "test" {
|
||||||
name = "osd-%d"
|
name = "osd-%d"
|
||||||
caching = "ReadWrite"
|
caching = "ReadWrite"
|
||||||
create_option = "FromImage"
|
create_option = "FromImage"
|
||||||
disk_size_gb = "10"
|
disk_size_gb = "50"
|
||||||
}
|
}
|
||||||
|
|
||||||
os_profile {
|
os_profile {
|
||||||
|
@ -1168,7 +1168,7 @@ resource "azurerm_virtual_machine" "test" {
|
||||||
name = "osd-%d"
|
name = "osd-%d"
|
||||||
caching = "ReadWrite"
|
caching = "ReadWrite"
|
||||||
create_option = "FromImage"
|
create_option = "FromImage"
|
||||||
disk_size_gb = "10"
|
disk_size_gb = "50"
|
||||||
managed_disk_type = "Standard_LRS"
|
managed_disk_type = "Standard_LRS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ The following arguments are supported:
|
||||||
|
|
||||||
* `storage_account` - (Required) A Storage Account block as documented below - which must be located in the same data center as the Container Registry.
|
* `storage_account` - (Required) A Storage Account block as documented below - which must be located in the same data center as the Container Registry.
|
||||||
|
|
||||||
* `sku` - (Required) The SKU name of the the container registry. `Basic` is the only acceptable value at this time.
|
* `sku` - (Optional) The SKU name of the the container registry. `Basic` is the only acceptable value at this time.
|
||||||
|
|
||||||
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue