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

Resolves issue 10346 - acctests failing on Recoveryservices #10347

Merged
merged 1 commit into from
Jan 28, 2021
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 @@ -347,7 +347,7 @@ resource "azurerm_backup_policy_vm" "import" {
count = 10
}
}
`, r.template(data))
`, r.basicDaily(data))
}

func (r BackupProtectionPolicyVMResource) basicWeekly(data acceptance.TestData) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ func TestAccBackupProtectedVm_updateBackupPolicyId(t *testing.T) {
// Backup policy link will need to be removed first so the VM's backup policy subsequently reverts to Default
// Azure API is quite sensitive, adding the step to control resource cleanup order
ResourceName: fBackupPolicyResourceName,
Config: r.withVM(data),
Config: r.withBasePolicy(data),
},
{
// Then VM can be removed
ResourceName: virtualMachine,
Config: r.withSecondPolicy(data),
Config: r.withBasePolicy(data),
},
{
// Remove backup policies and vault
Expand Down Expand Up @@ -161,7 +161,7 @@ resource "azurerm_subnet" "test" {
name = "acctest_subnet"
virtual_network_name = azurerm_virtual_network.test.name
resource_group_name = azurerm_resource_group.test.name
address_prefix = "10.0.10.0/24"
address_prefixes = ["10.0.10.0/24"]
}

resource "azurerm_network_interface" "test" {
Expand Down Expand Up @@ -310,7 +310,7 @@ resource "azurerm_subnet" "test" {
name = "acctest_subnet"
virtual_network_name = azurerm_virtual_network.test.name
resource_group_name = azurerm_resource_group.test.name
address_prefix = "10.0.10.0/24"
address_prefixes = ["10.0.10.0/24"]
}

resource "azurerm_network_interface" "test" {
Expand Down Expand Up @@ -354,45 +354,7 @@ resource "azurerm_managed_disk" "test" {
}

// For update backup policy id test
func (r BackupProtectedVmResource) withVault(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

resource "azurerm_recovery_services_vault" "test" {
name = "acctest-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku = "Standard"

soft_delete_enabled = false
}
`, r.base(data), data.RandomInteger)
}

// For update backup policy id test
func (r BackupProtectedVmResource) withFirstPolicy(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

resource "azurerm_backup_policy_vm" "test" {
name = "acctest-%d"
resource_group_name = azurerm_resource_group.test.name
recovery_vault_name = azurerm_recovery_services_vault.test.name

backup {
frequency = "Daily"
time = "23:00"
}

retention_daily {
count = 10
}
}
`, r.withVault(data), data.RandomInteger)
}

// For update backup policy id test
func (r BackupProtectedVmResource) withSecondPolicy(data acceptance.TestData) string {
func (r BackupProtectedVmResource) withBasePolicy(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

Expand All @@ -410,61 +372,7 @@ resource "azurerm_backup_policy_vm" "test_change_backup" {
count = 15
}
}
`, r.withFirstPolicy(data), data.RandomInteger)
}

// For update backup policy id test
func (r BackupProtectedVmResource) withVM(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

resource "azurerm_virtual_machine" "test" {
name = "acctestvm-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
vm_size = "Standard_A0"
network_interface_ids = [azurerm_network_interface.test.id]
delete_os_disk_on_termination = true

storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}

storage_os_disk {
name = "acctest-osdisk"
managed_disk_type = "Standard_LRS"
caching = "ReadWrite"
create_option = "FromImage"
}

storage_data_disk {
name = "acctest-datadisk"
managed_disk_id = azurerm_managed_disk.test.id
managed_disk_type = "Standard_LRS"
disk_size_gb = azurerm_managed_disk.test.disk_size_gb
create_option = "Attach"
lun = 0
}

os_profile {
computer_name = "acctest"
admin_username = "vmadmin"
admin_password = "Password123!@#"
}

os_profile_linux_config {
disable_password_authentication = false
}

boot_diagnostics {
enabled = true
storage_uri = azurerm_storage_account.test.primary_blob_endpoint
}
}
`, r.withSecondPolicy(data), data.RandomInteger)
`, r.base(data), data.RandomInteger)
}

// For update backup policy id test
Expand All @@ -478,7 +386,7 @@ resource "azurerm_backup_protected_vm" "test" {
source_vm_id = azurerm_virtual_machine.test.id
backup_policy_id = azurerm_backup_policy_vm.test.id
}
`, r.withVM(data))
`, r.withBasePolicy(data))
}

// For update backup policy id test
Expand All @@ -492,7 +400,7 @@ resource "azurerm_backup_protected_vm" "test" {
source_vm_id = azurerm_virtual_machine.test.id
backup_policy_id = azurerm_backup_policy_vm.test_change_backup.id
}
`, r.withVM(data))
`, r.withBasePolicy(data))
}

func (r BackupProtectedVmResource) requiresImport(data acceptance.TestData) string {
Expand Down