Skip to content

Commit

Permalink
Fixes for #1597
Browse files Browse the repository at this point in the history
  • Loading branch information
WodansSon committed Jul 18, 2018
1 parent 077c7ce commit 98aaa70
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 14 deletions.
2 changes: 0 additions & 2 deletions azurerm/resource_arm_mysql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func resourceArmMySqlServer() *schema.Resource {
"tier": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(mysql.Basic),
string(mysql.GeneralPurpose),
Expand All @@ -92,7 +91,6 @@ func resourceArmMySqlServer() *schema.Resource {
"family": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"Gen4",
"Gen5",
Expand Down
79 changes: 76 additions & 3 deletions azurerm/resource_arm_mysql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestAccAzureRMMySqlServer_generalPurpose(t *testing.T) {
func TestAccAzureRMMySqlServer_memoryOptimized(t *testing.T) {
resourceName := "azurerm_mysql_server.test"
ri := acctest.RandInt()
config := testAccAzureRMMySQLServer_memoryOptimized(ri, testLocation())
config := testAccAzureRMMySQLServer_memoryOptimizedGeoRedundant(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -126,6 +126,46 @@ func TestAccAzureRMMySQLServer_basicFiveSevenUpdated(t *testing.T) {
})
}

func TestAccAzureRMMySQLServer_updateSKU(t *testing.T) {
resourceName := "azurerm_mysql_server.test"
ri := acctest.RandInt()
location := testLocation()
config := testAccAzureRMMySQLServer_generalPurpose(ri, location)
updatedConfig := testAccAzureRMMySQLServer_memoryOptimized(ri, location)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMMySQLServerDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMMySQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "GP_Gen4_32"),
resource.TestCheckResourceAttr(resourceName, "sku.0.capacity", "32"),
resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "GeneralPurpose"),
resource.TestCheckResourceAttr(resourceName, "sku.0.family", "Gen4"),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "640000"),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
),
},
{
Config: updatedConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMMySQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "MO_Gen5_16"),
resource.TestCheckResourceAttr(resourceName, "sku.0.capacity", "16"),
resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "MemoryOptimized"),
resource.TestCheckResourceAttr(resourceName, "sku.0.family", "Gen5"),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "4194304"),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
),
},
},
})
}

//

func testCheckAzureRMMySQLServerExists(name string) resource.TestCheckFunc {
Expand Down Expand Up @@ -295,10 +335,10 @@ resource "azurerm_mysql_server" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
name = "GP_Gen5_32"
name = "GP_Gen4_32"
capacity = 32
tier = "GeneralPurpose"
family = "Gen5"
family = "Gen4"
}
storage_profile {
Expand All @@ -322,6 +362,39 @@ resource "azurerm_resource_group" "test" {
location = "%s"
}
resource "azurerm_mysql_server" "test" {
name = "acctestmysqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
name = "MO_Gen5_16"
capacity = 16
tier = "MemoryOptimized"
family = "Gen5"
}
storage_profile {
storage_mb = 4194304,
backup_retention_days = 7
geo_redundant_backup = "Disabled"
}
administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
version = "5.7"
ssl_enforcement = "Enabled"
}
`, rInt, location, rInt)
}

func testAccAzureRMMySQLServer_memoryOptimizedGeoRedundant(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_mysql_server" "test" {
name = "acctestmysqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
Expand Down
2 changes: 0 additions & 2 deletions azurerm/resource_arm_postgresql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func resourceArmPostgreSQLServer() *schema.Resource {
"tier": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(postgresql.Basic),
string(postgresql.GeneralPurpose),
Expand All @@ -93,7 +92,6 @@ func resourceArmPostgreSQLServer() *schema.Resource {
"family": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"Gen4",
"Gen5",
Expand Down
81 changes: 78 additions & 3 deletions azurerm/resource_arm_postgresql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestAccAzureRMPostgreSQLServer_generalPurpose(t *testing.T) {
func TestAccAzureRMPostgreSQLServer_memoryOptimized(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"
ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLServer_memoryOptimized(ri, testLocation())
config := testAccAzureRMPostgreSQLServer_memoryOptimizedGeoRedundant(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -205,6 +205,48 @@ func TestAccAzureRMPostgreSQLServer_updated(t *testing.T) {
})
}

func TestAccAzureRMPostgreSQLServer_updateSKU(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"
ri := acctest.RandInt()
location := testLocation()
config := testAccAzureRMPostgreSQLServer_generalPurpose(ri, location)
updatedConfig := testAccAzureRMPostgreSQLServer_memoryOptimized(ri, location)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLServerDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPostgreSQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "GP_Gen4_32"),
resource.TestCheckResourceAttr(resourceName, "sku.0.capacity", "32"),
resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "GeneralPurpose"),
resource.TestCheckResourceAttr(resourceName, "sku.0.family", "Gen4"),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "640000"),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
),
},
{
Config: updatedConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPostgreSQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "sku.0.name", "MO_Gen5_16"),
resource.TestCheckResourceAttr(resourceName, "sku.0.capacity", "16"),
resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "MemoryOptimized"),
resource.TestCheckResourceAttr(resourceName, "sku.0.family", "Gen5"),
resource.TestCheckResourceAttr(resourceName, "storage_profile.0.storage_mb", "4194304"),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
),
},
},
})
}

//

func testCheckAzureRMPostgreSQLServerExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
// Ensure we have enough information in state to look up in API
Expand Down Expand Up @@ -475,10 +517,10 @@ resource "azurerm_postgresql_server" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
name = "GP_Gen5_32"
name = "GP_Gen4_32"
capacity = 32
tier = "GeneralPurpose"
family = "Gen5"
family = "Gen4"
}
storage_profile {
Expand All @@ -502,6 +544,39 @@ resource "azurerm_resource_group" "test" {
location = "%s"
}
resource "azurerm_postgresql_server" "test" {
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
name = "MO_Gen5_16"
capacity = 16
tier = "MemoryOptimized"
family = "Gen5"
}
storage_profile {
storage_mb = 4194304
backup_retention_days = 7
geo_redundant_backup = "Disabled"
}
administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
version = "9.6"
ssl_enforcement = "Enabled"
}
`, rInt, location, rInt)
}

func testAccAzureRMPostgreSQLServer_memoryOptimizedGeoRedundant(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_postgresql_server" "test" {
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/mysql_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ The following arguments are supported:

* `capacity` - (Required) The scale up/out capacity, representing server's compute units.

* `tier` - (Required) The tier of the particular SKU. Possible values are `Basic`, `GeneralPurpose`, and `MemoryOptimized`. For more information see the [product documentation](https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers). Changing this forces a new resource to be created.
* `tier` - (Required) The tier of the particular SKU. Possible values are `Basic`, `GeneralPurpose`, and `MemoryOptimized`. For more information see the [product documentation](https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers).

* `family` - (Required) The `family` of hardware `Gen4` or `Gen5`, before selecting your `family` check the [product documentation](https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers#compute-generations-vcores-and-memory) for availability in your region. Changing this forces a new resource to be created.
* `family` - (Required) The `family` of hardware `Gen4` or `Gen5`, before selecting your `family` check the [product documentation](https://docs.microsoft.com/en-us/azure/mysql/concepts-pricing-tiers#compute-generations-vcores-and-memory) for availability in your region.

---

Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/postgresql_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ The following arguments are supported:

* `capacity` - (Required) The scale up/out capacity, representing server's compute units.

* `tier` - (Required) The tier of the particular SKU. Possible values are `Basic`, `GeneralPurpose`, and `MemoryOptimized`. For more information see the [product documentation](https://docs.microsoft.com/en-us/azure/postgresql/concepts-pricing-tiers). Changing this forces a new resource to be created.
* `tier` - (Required) The tier of the particular SKU. Possible values are `Basic`, `GeneralPurpose`, and `MemoryOptimized`. For more information see the [product documentation](https://docs.microsoft.com/en-us/azure/postgresql/concepts-pricing-tiers).

* `family` - (Required) The `family` of hardware `Gen4` or `Gen5`, before selecting your `family` check the [product documentation](https://docs.microsoft.com/en-us/azure/postgresql/concepts-pricing-tiers#compute-generations-vcores-and-memory) for availability in your region. Changing this forces a new resource to be created.
* `family` - (Required) The `family` of hardware `Gen4` or `Gen5`, before selecting your `family` check the [product documentation](https://docs.microsoft.com/en-us/azure/postgresql/concepts-pricing-tiers#compute-generations-vcores-and-memory) for availability in your region.

---

Expand Down

0 comments on commit 98aaa70

Please sign in to comment.