-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Import support to Redis Cache/Firewall Rule (#1211)
* `azurerm_redis_cache` - support for importing * `azurerm_firewall_rule` - support for import * Setting the redis_configuration using the correct types * maxclients becomes computed * Documenting a known bug in the API * Documenting the behaviour of the storage_connection_string field * Working around broken API's
- Loading branch information
1 parent
150e426
commit 95a820c
Showing
7 changed files
with
370 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
package azurerm | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccAzureRMRedisCache_importBasic(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
|
||
ri := acctest.RandInt() | ||
config := testAccAzureRMRedisCache_basic(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMRedisCache_importStandard(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
|
||
ri := acctest.RandInt() | ||
config := testAccAzureRMRedisCache_standard(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMRedisCache_importPremium(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
|
||
ri := acctest.RandInt() | ||
config := testAccAzureRMRedisCache_premium(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMRedisCache_importPremiumSharded(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
|
||
ri := acctest.RandInt() | ||
config := testAccAzureRMRedisCache_premiumSharded(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMRedisCache_importNonStandardCasing(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
|
||
ri := acctest.RandInt() | ||
config := testAccAzureRMRedisCacheNonStandardCasing(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMRedisCache_importBackupEnabled(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
|
||
ri := acctest.RandInt() | ||
rs := acctest.RandString(4) | ||
config := testAccAzureRMRedisCacheBackupEnabled(ri, rs, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
// `redis_configuration.0.rdb_storage_connection_string` is returned as: | ||
// "...;AccountKey=[key hidden]" rather than "...;AccountKey=fsjfvjnfnf" | ||
// TODO: remove this once the Bug's been fixed: | ||
// https://github.com/Azure/azure-rest-api-specs/issues/3037 | ||
ExpectNonEmptyPlan: true, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"redis_configuration.0.rdb_storage_connection_string"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMRedisCache_importPatchSchedule(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
ri := acctest.RandInt() | ||
location := testLocation() | ||
config := testAccAzureRMRedisCachePatchSchedule(ri, location) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
func TestAccAzureRMRedisCache_importInternalSubnet(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
ri := acctest.RandInt() | ||
config := testAccAzureRMRedisCache_internalSubnet(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMRedisCache_importInternalSubnetStaticIP(t *testing.T) { | ||
resourceName := "azurerm_redis_cache.test" | ||
ri := acctest.RandInt() | ||
config := testAccAzureRMRedisCache_internalSubnetStaticIP(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisCacheDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package azurerm | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccAzureRMRedisFirewallRule_importBasic(t *testing.T) { | ||
resourceName := "azurerm_redis_firewall_rule.test" | ||
|
||
ri := acctest.RandInt() | ||
config := testAccAzureRMRedisFirewallRule_basic(ri, testLocation()) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testCheckAzureRMRedisFirewallRuleDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.