Skip to content

Commit

Permalink
r\linux_virtual_machine_scale_set `r\windows_virtual_machine_scale_…
Browse files Browse the repository at this point in the history
…set`: Rename `terminate_notification` to `termination_notification` (#15570)
  • Loading branch information
myc2h6o authored Apr 29, 2022
1 parent 35ee710 commit 1952a4e
Show file tree
Hide file tree
Showing 9 changed files with 833 additions and 565 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,32 +414,51 @@ func TestAccLinuxVirtualMachineScaleSet_otherScaleInPolicy(t *testing.T) {
})
}

func TestAccLinuxVirtualMachineScaleSet_otherTerminateNotification(t *testing.T) {
func TestAccLinuxVirtualMachineScaleSet_otherTerminationNotification(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test")
r := LinuxVirtualMachineScaleSetResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
// turn terminate notification on
// turn termination notification on
{
Config: r.otherTerminateNotification(data, true),
Config: r.otherTerminationNotification(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("terminate_notification.#").HasValue("1"),
check.That(data.ResourceName).Key("terminate_notification.0.enabled").HasValue("true"),
check.That(data.ResourceName).Key("termination_notification.#").HasValue("1"),
check.That(data.ResourceName).Key("termination_notification.0.enabled").HasValue("true"),
),
},
data.ImportStep("admin_password"),
// turn terminate notification off
// turn termination notification off
{
Config: r.otherTerminateNotification(data, false),
Config: r.otherTerminationNotification(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("terminate_notification.#").HasValue("1"),
check.That(data.ResourceName).Key("terminate_notification.0.enabled").HasValue("false"),
check.That(data.ResourceName).Key("termination_notification.#").HasValue("1"),
check.That(data.ResourceName).Key("termination_notification.0.enabled").HasValue("false"),
),
},
data.ImportStep("admin_password"),
// turn terminate notification on again
// turn termination notification on again
{
Config: r.otherTerminationNotification(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("termination_notification.#").HasValue("1"),
check.That(data.ResourceName).Key("termination_notification.0.enabled").HasValue("true"),
),
},
data.ImportStep("admin_password"),
})
}

// TODO remove TestAccLinuxVirtualMachineScaleSet_otherTerminationNotificationMigration in 4.0
func TestAccLinuxVirtualMachineScaleSet_otherTerminationNotificationMigration(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test")
r := LinuxVirtualMachineScaleSetResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
// old: terminate_notification
{
Config: r.otherTerminateNotification(data, true),
Check: acceptance.ComposeTestCheckFunc(
Expand All @@ -449,6 +468,16 @@ func TestAccLinuxVirtualMachineScaleSet_otherTerminateNotification(t *testing.T)
),
},
data.ImportStep("admin_password"),
// new: termination_notification
{
Config: r.otherTerminationNotification(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("termination_notification.#").HasValue("1"),
check.That(data.ResourceName).Key("termination_notification.0.enabled").HasValue("true"),
),
},
data.ImportStep("admin_password"),
})
}

Expand Down Expand Up @@ -1907,6 +1936,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" {
`, r.template(data), data.RandomInteger)
}

// TODO remove otherTerminateNotification in 4.0
func (r LinuxVirtualMachineScaleSetResource) otherTerminateNotification(data acceptance.TestData, enabled bool) string {
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -1953,6 +1983,52 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" {
`, r.template(data), data.RandomInteger, enabled)
}

func (r LinuxVirtualMachineScaleSetResource) otherTerminationNotification(data acceptance.TestData, enabled bool) string {
return fmt.Sprintf(`
%s
resource "azurerm_linux_virtual_machine_scale_set" "test" {
name = "acctestvmss-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "Standard_F2"
instances = 1
admin_username = "adminuser"
admin_password = "P@ssword1234!"
disable_password_authentication = false
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
os_disk {
disk_size_gb = 30
storage_account_type = "Standard_LRS"
caching = "ReadWrite"
}
network_interface {
name = "example"
primary = true
ip_configuration {
name = "internal"
primary = true
subnet_id = azurerm_subnet.test.id
}
}
termination_notification {
enabled = %t
}
}
`, r.template(data), data.RandomInteger, enabled)
}

func (r LinuxVirtualMachineScaleSetResource) otherAutomaticRepairsPolicy(data acceptance.TestData, enabled bool) string {
return fmt.Sprintf(`
%[1]s
Expand Down Expand Up @@ -2103,7 +2179,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" {
}
}
terminate_notification {
termination_notification {
enabled = %t
}
}
Expand Down
Loading

0 comments on commit 1952a4e

Please sign in to comment.