From 5321755a03fc5dc173948a083728681ad88f2b43 Mon Sep 17 00:00:00 2001 From: Marin Salinas Date: Wed, 20 Jan 2021 23:19:05 -0600 Subject: [PATCH] chore: fix vm test --- .../resource_nutanix_virtual_machine_test.go | 59 ++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/nutanix/resource_nutanix_virtual_machine_test.go b/nutanix/resource_nutanix_virtual_machine_test.go index 79f35c165..31079a65a 100644 --- a/nutanix/resource_nutanix_virtual_machine_test.go +++ b/nutanix/resource_nutanix_virtual_machine_test.go @@ -282,7 +282,31 @@ func TestAccNutanixVirtualMachine_CdromGuestCustomisationReboot(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"disk_list"}, + ImportStateVerifyIgnore: []string{"disk_list", "cloud_init_cdrom_uuid"}, + }, + }, + }) +} + +func TestAccNutanixVirtualMachine_CdromGuestCustomisationRebootWithManualCDROM(t *testing.T) { + r := acctest.RandInt() + resourceName := "nutanix_virtual_machine.vm7" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNutanixVirtualMachineDestroy, + Steps: []resource.TestStep{ + { + Config: testAccNutanixVMConfigCdromGuestCustomisationRebootWithManualCDROM(r), + Check: resource.ComposeTestCheckFunc( + testAccCheckNutanixVirtualMachineExists(resourceName), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"disk_list", "cloud_init_cdrom_uuid"}, }, }, }) @@ -311,7 +335,7 @@ func TestAccNutanixVirtualMachine_CloudInitCustomKeyValues(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"disk_list"}, + ImportStateVerifyIgnore: []string{"disk_list", "cloud_init_cdrom_uuid"}, }, }, }) @@ -824,6 +848,37 @@ func testAccNutanixVMConfigCdromGuestCustomisationReboot(r int) string { `, r) } +func testAccNutanixVMConfigCdromGuestCustomisationRebootWithManualCDROM(r int) string { + return fmt.Sprintf(` + data "nutanix_clusters" "clusters" {} + + locals { + cluster1 = "${data.nutanix_clusters.clusters.entities.0.service_list.0 == "PRISM_CENTRAL" + ? data.nutanix_clusters.clusters.entities.1.metadata.uuid : data.nutanix_clusters.clusters.entities.0.metadata.uuid}" + } + + resource "nutanix_virtual_machine" "vm7" { + name = "test-dou-%d" + cluster_uuid = "${local.cluster1}" + + num_vcpus_per_socket = 1 + num_sockets = 1 + memory_size_mib = 186 + guest_customization_cloud_init_user_data = base64encode("#cloud-config\nfqdn: test.domain.local") + + disk_list { + device_properties { + device_type = "CDROM" + disk_address = { + device_index = 0 + adapter_type = "IDE" + } + } + } + } + `, r) +} + func testAccNutanixVMConfigCloudInitCustomKeyValues(r int) string { return fmt.Sprintf(` data "nutanix_clusters" "clusters" {}