Skip to content

Commit

Permalink
Compute - Fix failed Acc Test (#27465)
Browse files Browse the repository at this point in the history
* fix acc test

* remove unnecessary testcases
  • Loading branch information
ms-zhenhua authored Oct 17, 2024
1 parent 9d5e798 commit bbd9285
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 642 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,27 +449,6 @@ func TestAccVirtualMachine_ultraSSD(t *testing.T) {
})
}

func TestAccVirtualMachine_ChangeAvailabilitySet(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_virtual_machine", "test")
r := VirtualMachineResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.withAvailabilitySet(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},

{
Config: r.updateAvailabilitySet(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
})
}

func (VirtualMachineResource) basicLinuxMachine_managedDisk_withOsWriteAcceleratorEnabled(data acceptance.TestData, enabled string) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down Expand Up @@ -2735,163 +2714,3 @@ resource "azurerm_virtual_machine" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func (VirtualMachineResource) withAvailabilitySet(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_subnet" "test" {
name = "acctsub-%d"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
ip_configuration {
name = "testconfiguration1"
subnet_id = azurerm_subnet.test.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_availability_set" "test" {
name = "availabilityset%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
network_interface_ids = [azurerm_network_interface.test.id]
vm_size = "Standard_D1_v2"
availability_set_id = azurerm_availability_set.test.id
delete_os_disk_on_termination = true
storage_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts"
version = "latest"
}
storage_os_disk {
name = "osd-%d"
caching = "ReadWrite"
create_option = "FromImage"
disk_size_gb = "50"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func (VirtualMachineResource) updateAvailabilitySet(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_virtual_network" "test" {
name = "acctvn-%d"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_subnet" "test" {
name = "acctsub-%d"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azurerm_network_interface" "test" {
name = "acctni-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
ip_configuration {
name = "testconfiguration1"
subnet_id = azurerm_subnet.test.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_availability_set" "test" {
name = "updatedAvailabilitySet%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_virtual_machine" "test" {
name = "acctvm-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
network_interface_ids = [azurerm_network_interface.test.id]
vm_size = "Standard_D1_v2"
availability_set_id = azurerm_availability_set.test.id
delete_os_disk_on_termination = true
storage_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts"
version = "latest"
}
storage_os_disk {
name = "osd-%d"
caching = "ReadWrite"
create_option = "FromImage"
disk_size_gb = "50"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "hn%d"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}
144 changes: 3 additions & 141 deletions internal/services/legacy/virtual_machine_scale_set_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,6 @@ func TestAccVirtualMachineScaleSet_updateNetworkProfile_ipconfiguration_dns_name
})
}

func TestAccVirtualMachineScaleSet_verify_key_data_changed(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_virtual_machine_scale_set", "test")
r := VirtualMachineScaleSetResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.linux(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("os_profile.0.admin_password", "os_profile.0.custom_data"),
{
Config: r.linuxKeyDataUpdated(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("os_profile.0.admin_password", "os_profile.0.custom_data"),
})
}

func TestAccVirtualMachineScaleSet_basicApplicationSecurity(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_virtual_machine_scale_set", "test")
r := VirtualMachineScaleSetResource{}
Expand Down Expand Up @@ -2942,125 +2920,6 @@ resource "azurerm_virtual_machine_scale_set" "test" {
`, data.RandomInteger, data.Locations.Primary)
}

func (VirtualMachineScaleSetResource) linuxKeyDataUpdated(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%[1]d"
location = "%[2]s"
}
resource "azurerm_virtual_network" "test" {
name = "acctestvn-%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
address_space = ["10.0.0.0/8"]
}
resource "azurerm_subnet" "test" {
name = "acctestsn-%[1]d"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.1.0/24"]
}
resource "azurerm_storage_account" "test" {
name = "accsa%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_storage_container" "test" {
name = "acctestsc-%[1]d"
storage_account_name = azurerm_storage_account.test.name
container_access_type = "private"
}
resource "azurerm_public_ip" "test" {
name = "acctestpip-%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
allocation_method = "Static"
}
resource "azurerm_lb" "test" {
name = "acctestlb-%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
frontend_ip_configuration {
name = "ip-address"
public_ip_address_id = azurerm_public_ip.test.id
}
}
resource "azurerm_lb_backend_address_pool" "test" {
name = "acctestbap-%[1]d"
loadbalancer_id = azurerm_lb.test.id
}
resource "azurerm_virtual_machine_scale_set" "test" {
name = "acctestvmss-%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
upgrade_policy_mode = "Automatic"
sku {
name = "Standard_F2"
tier = "Standard"
capacity = "1"
}
os_profile {
computer_name_prefix = "prefix"
admin_username = "ubuntu"
custom_data = "updated custom data!"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
path = "/home/ubuntu/.ssh/authorized_keys"
key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDvXYZAjVUt2aojUV3XIA+PY6gXrgbvktXwf2NoIHGlQFhogpMEyOfqgogCtTBM7MNCS3ELul6SV+mlpH08Ki45ADIQuDXdommCvsMFW096JrsHOJpGfjCsJ1gbbv7brB3Ag+BSGb4qO3pRsEVTtZCeJDwfH5D7vmqP5xXcELKR4UAtKQKUhLvt6mhW90sFLTJeOTiYGbavIKqfCUFSeSMQkUPr8o3uzOfeWyCw7tc7szLuvfwJ5poGHuve73KKAlUnDTPUrhyj7iITZSDl+/i+bpDzPyCyJWDMsC0ON7q2fDr2mEz0L9ACrsI5Nx3lt5fe+IaHSrjivqnL8SqUWSN45o9Qp99sGWFiuTfos8f1jp+AXzC4ArVtKyRg/CnzKRiK0CGSxBJ5s9zAoa7yBBmjCszq89vFa0eMgpEIZFwa6kKJKt9AfRBXgO9YGPV4uaN7topy92/p2pE+vF8IafarbvnTDOQt62mS07tXYqYg1DhecrmBVWKlq9oafBweoeTjoq52SoGsuDc/YAOzIgWVIuvV8yKoh9KbXPWowjLtxDhRIS/d1nMMNdNI8X0TQivgi5+umMgAXhsVAKSNDUauLt4jimYkWAuE+R6KoCqVFdaB9bQDySBjAziruDSe3reToydjzzluvHMjWK8QiDynxs41pi4zZz6gAlca3QPkEQ== [email protected]"
}
}
network_profile {
name = "TestNetworkProfile"
primary = true
ip_configuration {
name = "TestIPConfiguration"
primary = true
subnet_id = azurerm_subnet.test.id
load_balancer_backend_address_pool_ids = [azurerm_lb_backend_address_pool.test.id]
}
}
storage_profile_os_disk {
name = "osDiskProfile"
caching = "ReadWrite"
create_option = "FromImage"
os_type = "linux"
vhd_containers = ["${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}"]
}
storage_profile_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts"
version = "latest"
}
}
`, data.RandomInteger, data.Locations.Primary)
}

func (VirtualMachineScaleSetResource) basicLinux_managedDisk(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down Expand Up @@ -3530,6 +3389,9 @@ resource "azurerm_application_gateway" "test" {
timeout = 120
interval = 300
unhealthy_threshold = 8
match {
status_code = ["200-399"]
}
}
request_routing_rule {
Expand Down
Loading

0 comments on commit bbd9285

Please sign in to comment.