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

Acctest - fix mysql RP test case failures #28882

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ resource "azurerm_mysql_flexible_server" "test" {
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
version = "8.0.21"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "1"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "1"
}

Expand Down Expand Up @@ -157,7 +157,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "1"
}

Expand Down Expand Up @@ -187,7 +187,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "1"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "2"

identity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "1"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestAccDataSourceMySqlFlexibleServer_basic(t *testing.T) {
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("sku_name").HasValue("B_Standard_B1s"),
check.That(data.ResourceName).Key("sku_name").HasValue("B_Standard_B1ms"),
check.That(data.ResourceName).Key("administrator_login").HasValue("_admin_Terraform_892123456789312"),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "1"
}

Expand Down
94 changes: 61 additions & 33 deletions internal/services/mysql/mysql_flexible_server_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ func TestAccMySqlFlexibleServer_failover(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.failover(data, "1", "2"),
Config: r.failover(data, "2", "3"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("administrator_password"),
{
Config: r.failover(data, "2", "1"),
Config: r.failover(data, "3", "2"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -605,7 +605,12 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"

# ignore_changes zone because API returns a value for it when it is not specified
lifecycle {
ignore_changes = [zone]
}
}
`, r.template(data), data.RandomInteger)
}
Expand Down Expand Up @@ -677,7 +682,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
zone = "1"
zone = "3"
version = "8.0.21"
backup_retention_days = 7
geo_redundant_backup_enabled = false
Expand Down Expand Up @@ -762,7 +767,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "123wsxQAZ"
zone = "1"
zone = "3"
version = "8.0.21"
backup_retention_days = 10
geo_redundant_backup_enabled = false
Expand Down Expand Up @@ -801,16 +806,20 @@ resource "azurerm_mysql_flexible_server" "test" {
name = "acctest-fs-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
zone = "1"
sku_name = "GP_Standard_D2ds_v4"

maintenance_window {
day_of_week = 0
start_hour = 8
start_minute = 0
}

# ignore_changes zone because API returns a value for it when it is not specified
lifecycle {
ignore_changes = [zone]
}
}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -823,16 +832,20 @@ resource "azurerm_mysql_flexible_server" "test" {
name = "acctest-fs-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
zone = "1"
sku_name = "GP_Standard_D2ds_v4"

maintenance_window {
day_of_week = 3
start_hour = 7
start_minute = 15
}

# ignore_changes zone because API returns a value for it when it is not specified
lifecycle {
ignore_changes = [zone]
}
}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -848,7 +861,7 @@ resource "azurerm_mysql_flexible_server" "test" {
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "MO_Standard_E2ds_v4"
zone = "1"
zone = "2"
}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -864,7 +877,7 @@ resource "azurerm_mysql_flexible_server" "test" {
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "GP_Standard_D2ds_v4"
zone = "1"
zone = "2"
}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -885,7 +898,7 @@ resource "azurerm_mysql_flexible_server" "test" {
}

sku_name = "GP_Standard_D2ds_v4"
zone = "1"
zone = "2"

lifecycle {
ignore_changes = [
Expand Down Expand Up @@ -914,7 +927,7 @@ resource "azurerm_mysql_flexible_server" "test" {
}

sku_name = "GP_Standard_D2ds_v4"
zone = "1"
zone = "3"
}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -937,7 +950,7 @@ resource "azurerm_mysql_flexible_server" "test" {
}

sku_name = "GP_Standard_D2ds_v4"
zone = "1"
zone = "2"
}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -953,7 +966,12 @@ resource "azurerm_mysql_flexible_server" "pitr" {
create_mode = "PointInTimeRestore"
source_server_id = azurerm_mysql_flexible_server.test.id
point_in_time_restore_time_in_utc = "%s"
zone = "1"
zone = "2"

# ignore_changes source_server_id because API does not return its value when create_mode is PointInTimeRestore
lifecycle {
ignore_changes = [source_server_id]
}
}
`, r.basic(data), data.RandomInteger, time.Now().Add(time.Duration(15)*time.Minute).UTC().Format(time.RFC3339))
}
Expand All @@ -970,7 +988,7 @@ resource "azurerm_mysql_flexible_server" "test" {
administrator_password = "QAZwsx123"
sku_name = "GP_Standard_D4ds_v4"
version = "8.0.21"
zone = "1"
zone = "2"
}
`, r.template(data), data.RandomInteger)
}
Expand All @@ -986,7 +1004,12 @@ resource "azurerm_mysql_flexible_server" "replica" {
create_mode = "Replica"
source_server_id = azurerm_mysql_flexible_server.test.id
version = "8.0.21"
zone = "1"
zone = "2"

# ignore_changes source_server_id because API does not return its value when create_mode is Replica
lifecycle {
ignore_changes = [source_server_id]
}
}
`, r.source(data), data.RandomInteger)
}
Expand All @@ -1003,7 +1026,12 @@ resource "azurerm_mysql_flexible_server" "replica" {
source_server_id = azurerm_mysql_flexible_server.test.id
replication_role = "None"
version = "8.0.21"
zone = "1"
zone = "2"

# ignore_changes source_server_id because API does not return its value when create_mode is Replica
lifecycle {
ignore_changes = [source_server_id]
}
}
`, r.source(data), data.RandomInteger)
}
Expand All @@ -1019,7 +1047,7 @@ resource "azurerm_mysql_flexible_server" "test" {
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
geo_redundant_backup_enabled = true
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
}
`, r.template(data), data.RandomInteger)
}
Expand Down Expand Up @@ -1051,7 +1079,7 @@ resource "azurerm_mysql_flexible_server" "test" {
sku_name = "GP_Standard_D4ds_v4"
geo_redundant_backup_enabled = true
version = "8.0.21"
zone = "1"
zone = "2"

storage {
size_gb = %d
Expand All @@ -1076,7 +1104,7 @@ resource "azurerm_mysql_flexible_server" "test" {
sku_name = "GP_Standard_D4ds_v4"
geo_redundant_backup_enabled = true
version = "8.0.21"
zone = "1"
zone = "2"

storage {
size_gb = %d
Expand Down Expand Up @@ -1183,8 +1211,8 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
zone = "1"
sku_name = "B_Standard_B1ms"
zone = "2"
}
`, r.cmkTemplate(data), data.RandomInteger)
}
Expand All @@ -1199,8 +1227,8 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
zone = "1"
sku_name = "B_Standard_B1ms"
zone = "2"

identity {
type = "UserAssigned"
Expand Down Expand Up @@ -1274,7 +1302,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "2"
geo_redundant_backup_enabled = true

Expand Down Expand Up @@ -1309,8 +1337,8 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
zone = "1"
sku_name = "B_Standard_B1ms"
zone = "2"

identity {
type = "UserAssigned"
Expand All @@ -1336,8 +1364,8 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "_admin_Terraform_892123456789312"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
zone = "1"
sku_name = "B_Standard_B1ms"
zone = "2"
}
`, r.template(data), data.RandomString, data.RandomInteger)
}
Expand All @@ -1355,7 +1383,7 @@ resource "azurerm_mysql_flexible_server" "test" {
administrator_login = "_admin_Terraform_892123456789312"
administrator_password_wo = ephemeral.azurerm_key_vault_secret.test.value
administrator_password_wo_version = %[4]d
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
}
`, r.template(data), acceptance.WriteOnlyKeyVaultSecretTemplate(data, secret), data.RandomInteger, version)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func FlexibleServerSkuName(i interface{}, k string) (warnings []string, errors [
}

// See all available sku names from https://docs.microsoft.com/en-us/azure/mysql/flexible-server/concepts-compute-storage#compute-tiers-size-and-server-types
if !regexp.MustCompile(`^(B_(Standard_B(1|1m|2|2m|4m|8m|12m|16m|20m)s))|(GP_(Standard_D(2|4|8|16|32|48|64)ds_v4)|(Standard_D(2|4|8|16|32|48|64)ads_v5))|(MO_((Standard_E(2|4|8|16|20|32|48|64|80i)ds_v4)|(Standard_E(2|2a|4|4a|8|8a|16|16a|20|20a|32|32a|48|48a|64|64a|96)ds_v5)))$`).MatchString(v) {
if !regexp.MustCompile(`^(B_(Standard_B(1m|2|2m|4m|8m|12m|16m|20m)s))|(GP_(Standard_D(2|4|8|16|32|48|64)ds_v4)|(Standard_D(2|4|8|16|32|48|64)ads_v5))|(MO_((Standard_E(2|4|8|16|20|32|48|64|80i)ds_v4)|(Standard_E(2|2a|4|4a|8|8a|16|16a|20|20a|32|32a|48|48a|64|64a|96)ds_v5)))$`).MatchString(v) {
errors = append(errors, fmt.Errorf("%q is not a valid sku name, got %v", k, v))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func TestFlexibleServerSkuName(t *testing.T) {
valid: true,
},
{
name: "B_Standard_B1s",
input: "B_Standard_B1s",
name: "B_Standard_B1ms",
input: "B_Standard_B1ms",
valid: true,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ resource "azurerm_mysql_flexible_server" "test" {
location = azurerm_resource_group.test.location
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "2"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource "azurerm_mysql_flexible_server" "example" {
administrator_login = "adminTerraform"
administrator_password = "QAZwsx123"
version = "8.0.21"
sku_name = "B_Standard_B1s"
sku_name = "B_Standard_B1ms"
zone = "1"
}

Expand Down
Loading
Loading