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

r\linux_virtual_machine_scale_set r\windows_virtual_machine_scale_set: Rename terminate_notification to termination_notification #15570

Merged
merged 6 commits into from
Apr 29, 2022
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
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