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:
Tom Harvey 2017-06-01 14:00:04 +01:00 committed by GitHub
parent 76297fc43d
commit 68fe08045b
7 changed files with 35 additions and 16 deletions

View File

@ -3,22 +3,24 @@ package azurerm
import (
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMLocalNetworkGateway_importBasic(t *testing.T) {
resourceName := "azurerm_local_network_gateway.test"
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLocalNetworkGatewayDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAzureRMLocalNetworkGatewayConfig_basic,
{
Config: testAccAzureRMLocalNetworkGatewayConfig_basic(rInt),
},
resource.TestStep{
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,

View File

@ -45,8 +45,9 @@ func resourceArmContainerRegistry() *schema.Resource {
"sku": {
Type: schema.TypeString,
Required: true,
Optional: true,
ForceNew: true,
Default: string(containerregistry.Basic),
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
ValidateFunc: validation.StringInSlice([]string{
string(containerregistry.Basic),

View File

@ -171,9 +171,14 @@ func resourceArmEventHubNamespaceDelete(d *schema.ResourceData, meta interface{}
resGroup := id.ResourceGroup
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
if resp.StatusCode == http.StatusNotFound {
return nil
}
if err != nil {
return fmt.Errorf("Error issuing Azure ARM delete request of EventHub Namespace '%s': %+v", name, err)
}

View File

@ -141,8 +141,14 @@ func resourceArmLocalNetworkGatewayDelete(d *schema.ResourceData, meta interface
name := id.Path["localNetworkGateways"]
resGroup := id.ResourceGroup
_, error := lnetClient.Delete(resGroup, name, make(chan struct{}))
deleteResp, error := lnetClient.Delete(resGroup, name, make(chan struct{}))
resp := <-deleteResp
err = <-error
if resp.StatusCode == http.StatusNotFound {
return nil
}
if err != nil {
return fmt.Errorf("Error issuing Azure ARM delete request of local network gateway '%s': %s", name, err)
}

View File

@ -5,6 +5,7 @@ import (
"net/http"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -12,13 +13,14 @@ import (
func TestAccAzureRMLocalNetworkGateway_basic(t *testing.T) {
name := "azurerm_local_network_gateway.test"
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLocalNetworkGatewayDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLocalNetworkGatewayConfig_basic,
Config: testAccAzureRMLocalNetworkGatewayConfig_basic(rInt),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLocalNetworkGatewayExists(name),
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) {
name := "azurerm_local_network_gateway.test"
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
@ -38,7 +41,7 @@ func TestAccAzureRMLocalNetworkGateway_disappears(t *testing.T) {
CheckDestroy: testCheckAzureRMLocalNetworkGatewayDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLocalNetworkGatewayConfig_basic,
Config: testAccAzureRMLocalNetworkGatewayConfig_basic(rInt),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLocalNetworkGatewayExists(name),
resource.TestCheckResourceAttr(name, "gateway_address", "127.0.0.1"),
@ -146,17 +149,19 @@ func testCheckAzureRMLocalNetworkGatewayDestroy(s *terraform.State) error {
return nil
}
var testAccAzureRMLocalNetworkGatewayConfig_basic = `
func testAccAzureRMLocalNetworkGatewayConfig_basic(rInt int) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "tftestingResourceGroup"
name = "acctest-%d"
location = "West US"
}
resource "azurerm_local_network_gateway" "test" {
name = "tftestingLocalNetworkGateway"
name = "acctestlng-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
gateway_address = "127.0.0.1"
address_space = ["127.0.0.0/8"]
}
`
`, rInt, rInt)
}

View File

@ -1018,7 +1018,7 @@ resource "azurerm_virtual_machine" "test" {
name = "osd-%d"
caching = "ReadWrite"
create_option = "FromImage"
disk_size_gb = "10"
disk_size_gb = "50"
managed_disk_type = "Standard_LRS"
}
@ -1089,7 +1089,7 @@ resource "azurerm_virtual_machine" "test" {
name = "osd-%d"
caching = "ReadWrite"
create_option = "FromImage"
disk_size_gb = "10"
disk_size_gb = "50"
}
os_profile {
@ -1168,7 +1168,7 @@ resource "azurerm_virtual_machine" "test" {
name = "osd-%d"
caching = "ReadWrite"
create_option = "FromImage"
disk_size_gb = "10"
disk_size_gb = "50"
managed_disk_type = "Standard_LRS"
}

View File

@ -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.
* `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.