diff --git a/acctests/README.md b/acctests/README.md index 9d9d0638e..1508d8e78 100644 --- a/acctests/README.md +++ b/acctests/README.md @@ -63,9 +63,9 @@ $ source devrc This set of environment variables and setup should allow you to run most of the acceptance tests, current failing ones or ones skipped due to missing or misconfigured environment variables will be addressed ASAP (unfortunately there had been a large amount of technical debt built up around testing). ### Please Note -As for writing a few manual steps had to be taken to privately network the nested ESXis and add them to vSphere. +As for writing a few manual steps had to be taken to privately network the nested ESXis and add them to vSphere. You will need to let the first apply fail, then perform the steps and re-apply. -1. Delete vmk1 and manually recreate it attached to the new vSwitch (which runs on vmnic1) +1. Delete vmk1 and manually recreate it attached to the new vSwitch (which runs on vmnic1), give it an IP on the private subnet 2. Visit the physical ESXi web UI (likely the vCenter IP - 1) and power off the vcsa VM 3. Attach vmnet to the vcsa VM 4. Power on the vcsa VM diff --git a/acctests/vsphere/for-acceptance-tests.tf b/acctests/vsphere/for-acceptance-tests.tf index f7c51b5da..cbe01547c 100644 --- a/acctests/vsphere/for-acceptance-tests.tf +++ b/acctests/vsphere/for-acceptance-tests.tf @@ -29,11 +29,11 @@ resource "vsphere_resource_pool" "pool" { } resource "vsphere_nas_datastore" "ds" { - name = var.VSPHERE_NFS_DS_NAME + name = var.VSPHERE_NFS_DS_NAME host_system_ids = [vsphere_host.host1.id] // TODO: needs to be networked privately for nested ESXIs to connect to it - type = "NFS" - remote_hosts = [var.VSPHERE_NAS_HOST] - remote_path = "/nfs" + type = "NFS" + remote_hosts = [var.VSPHERE_NAS_HOST] + remote_path = "/nfs" } resource "vsphere_virtual_machine" "template" { diff --git a/acctests/vsphere/nested-esxi-template.tf b/acctests/vsphere/nested-esxi-template.tf index f62937665..360e918a7 100644 --- a/acctests/vsphere/nested-esxi-template.tf +++ b/acctests/vsphere/nested-esxi-template.tf @@ -27,7 +27,7 @@ resource "vsphere_vmfs_datastore" "nested-esxi" { } resource "vsphere_host_virtual_switch" "switch" { - name = "terraform-test" # + name = "terraform-test" host_system_id = vsphere_host.host1.id network_adapters = [var.VSPHERE_ESXI_TRUNK_NIC] @@ -62,5 +62,6 @@ data "vsphere_ovf_vm_template" "nested-esxi" { remote_ovf_url = "https://download3.vmware.com/software/vmw-tools/nested-esxi/Nested_ESXi7.0u3_Appliance_Template_v1.ova" ovf_network_map = { "${vsphere_host_port_group.pg.name}" = data.vsphere_network.pg.id + "VM Network" = data.vsphere_network.pg.id # second NIC for testing } } diff --git a/vsphere/resource_vsphere_vnic_test.go b/vsphere/resource_vsphere_vnic_test.go index 159bc9a71..c392dd39c 100644 --- a/vsphere/resource_vsphere_vnic_test.go +++ b/vsphere/resource_vsphere_vnic_test.go @@ -43,7 +43,7 @@ func generateSteps(cfgFunc genTfConfig, netstack string) []resource.TestStep { return out } -func TestAccResourceVSphereVNic_dvs(t *testing.T) { +func TestAccResourceVSphereVNic_dvs_default(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { RunSweepers() @@ -67,7 +67,7 @@ func TestAccResourceVSphereVNic_dvs_vmotion(t *testing.T) { }) } -func TestAccResourceVSphereVNic_hvs(t *testing.T) { +func TestAccResourceVSphereVNic_hvs_default(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { RunSweepers() @@ -201,7 +201,7 @@ func testAccVsphereVNicNetworkSettings(name, ipv4State, ipv6State, netstack stri for _, ipv6addr := range vnic.Spec.Ip.IpV6Config.IpV6Address { if strings.EqualFold(ipv6addr.IpAddress, ip) { if ipv6addr.PrefixLength != int32(prefix) || - strings.EqualFold(routeConfig.IpV6DefaultGateway, gw) { + !strings.EqualFold(routeConfig.IpV6DefaultGateway, gw) { return fmt.Errorf( "ipv6 network error, static config mismatch. prefix length %d vs %d, gw %s vs %s", prefix, ipv6addr.PrefixLength, @@ -272,18 +272,9 @@ func testaccvspherevnicconfigHvs(netConfig string) string { datacenter_id = data.vsphere_datacenter.rootdc1.id } - - resource "vsphere_host_virtual_switch" "hvs1" { - name = "hashi-dc_HPG0" - host_system_id = data.vsphere_host.h1.id - network_adapters = ["%s", "%s"] - active_nics = ["%s"] - standby_nics = ["%s"] - } - resource "vsphere_host_port_group" "p1" { name = "ko-pg" - virtual_switch_name = vsphere_host_virtual_switch.hvs1.name + virtual_switch_name = "vSwitch0" host_system_id = data.vsphere_host.h1.id } @@ -294,10 +285,6 @@ func testaccvspherevnicconfigHvs(netConfig string) string { } `, testhelper.CombineConfigs(testhelper.ConfigDataRootDC1(), testhelper.ConfigDataRootPortGroup1()), os.Getenv("TF_VAR_VSPHERE_ESXI3"), - os.Getenv("TF_VAR_VSPHERE_HOST_NIC0"), - os.Getenv("TF_VAR_VSPHERE_HOST_NIC1"), - os.Getenv("TF_VAR_VSPHERE_HOST_NIC0"), - os.Getenv("TF_VAR_VSPHERE_HOST_NIC1"), netConfig) } @@ -309,7 +296,7 @@ func testaccvspherevnicconfigDvs(netConfig string) string { name = "hashi-dc_DVPG0" datacenter_id = data.vsphere_datacenter.rootdc1.id host { - host_system_id = data.vsphere_host.roothost1.id + host_system_id = data.vsphere_host.roothost2.id devices = ["%s"] } } @@ -321,14 +308,14 @@ func testaccvspherevnicconfigDvs(netConfig string) string { } resource "vsphere_vnic" "v1" { - host = data.vsphere_host.roothost1.id + host = data.vsphere_host.roothost2.id distributed_switch_port = vsphere_distributed_virtual_switch.d1.id distributed_port_group = vsphere_distributed_port_group.p1.id %s } `, testhelper.CombineConfigs( testhelper.ConfigDataRootDC1(), - testhelper.ConfigDataRootHost1(), + testhelper.ConfigDataRootHost2(), ), os.Getenv("TF_VAR_VSPHERE_HOST_NIC1"), netConfig)