Skip to content

Commit

Permalink
chore: fix vm test
Browse files Browse the repository at this point in the history
  • Loading branch information
marinsalinas committed Jan 27, 2021
1 parent 79b8b5b commit 601de16
Showing 1 changed file with 57 additions and 2 deletions.
59 changes: 57 additions & 2 deletions nutanix/resource_nutanix_virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
},
})
Expand Down Expand Up @@ -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"},
},
},
})
Expand Down Expand Up @@ -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" {}
Expand Down

0 comments on commit 601de16

Please sign in to comment.