Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_postgresql_server - support for version 11.0 #3970

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions azurerm/resource_arm_postgresql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func resourceArmPostgreSQLServer() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
string(postgresql.NineFullStopFive),
string(postgresql.NineFullStopSix),
string(postgresql.OneOne),
string(postgresql.OneZero),
string(postgresql.OneZeroFullStopZero),
string(postgresql.OneZeroFullStopTwo),
Expand Down
132 changes: 73 additions & 59 deletions azurerm/resource_arm_postgresql_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,66 @@ func TestAccAzureRMPostgreSQLServer_basicTenPointZero(t *testing.T) {
})
}

func TestAccAzureRMPostgreSQLServer_basicTenPointTwo(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"
ri := tf.AccRandTimeInt()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLServerDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMPostgreSQLServer_basicTenPointTwo(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPostgreSQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
resource.TestCheckResourceAttr(resourceName, "version", "10.2"),
resource.TestCheckResourceAttr(resourceName, "ssl_enforcement", "Enabled"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"administrator_login_password", // not returned as sensitive
},
},
},
})
}

func TestAccAzureRMPostgreSQLServer_basicEleven(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"
ri := tf.AccRandTimeInt()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLServerDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMPostgreSQLServer_basicEleven(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPostgreSQLServerExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "administrator_login", "acctestun"),
resource.TestCheckResourceAttr(resourceName, "version", "11"),
resource.TestCheckResourceAttr(resourceName, "ssl_enforcement", "Enabled"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"administrator_login_password", // not returned as sensitive
},
},
},
})
}

func TestAccAzureRMPostgreSQLServer_requiresImport(t *testing.T) {
if !requireResourcesToBeImported {
t.Skip("Skipping since resources aren't required to be imported")
Expand Down Expand Up @@ -384,7 +444,7 @@ func testCheckAzureRMPostgreSQLServerDestroy(s *terraform.State) error {
return nil
}

func testAccAzureRMPostgreSQLServer_basicNinePointFive(rInt int, location string) string {
func testAccAzureRMPostgreSQLServer_basic(rInt int, location string, version string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
Expand All @@ -411,76 +471,30 @@ resource "azurerm_postgresql_server" "test" {

administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
version = "9.5"
version = "%s"
ssl_enforcement = "Enabled"
}
`, rInt, location, rInt)
`, rInt, location, rInt, version)
}

func testAccAzureRMPostgreSQLServer_basicNinePointSix(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
func testAccAzureRMPostgreSQLServer_basicNinePointFive(rInt int, location string) string {
return testAccAzureRMPostgreSQLServer_basic(rInt, location, "9.5")
}

resource "azurerm_postgresql_server" "test" {
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"

sku {
name = "GP_Gen5_2"
capacity = 2
tier = "GeneralPurpose"
family = "Gen5"
}

storage_profile {
storage_mb = 51200
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_basicNinePointSix(rInt int, location string) string {
return testAccAzureRMPostgreSQLServer_basic(rInt, location, "9.6")
}

func testAccAzureRMPostgreSQLServer_basicTenPointZero(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
return testAccAzureRMPostgreSQLServer_basic(rInt, location, "10.0")
}

resource "azurerm_postgresql_server" "test" {
name = "acctestpsqlsvr-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"

sku {
name = "GP_Gen5_2"
capacity = 2
tier = "GeneralPurpose"
family = "Gen5"
}

storage_profile {
storage_mb = 51200
backup_retention_days = 7
geo_redundant_backup = "Disabled"
}

administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
version = "10.0"
ssl_enforcement = "Enabled"
func testAccAzureRMPostgreSQLServer_basicTenPointTwo(rInt int, location string) string {
return testAccAzureRMPostgreSQLServer_basic(rInt, location, "10.2")
}
`, rInt, location, rInt)

func testAccAzureRMPostgreSQLServer_basicEleven(rInt int, location string) string {
return testAccAzureRMPostgreSQLServer_basic(rInt, location, "11")
}

func testAccAzureRMPostgreSQLServer_requiresImport(rInt int, location string) string {
Expand Down