From c04880978ea12b065853c6d5d1e41e3f094c9a40 Mon Sep 17 00:00:00 2001 From: GCHQ Developer 609 <95346075+GCHQDeveloper609@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:11:03 +0100 Subject: [PATCH] Fix acceptance tests --- ...buted_virtual_switch_pvlan_mapping_test.go | 20 ++++++++++++++++++- ...vsphere_distributed_virtual_switch_test.go | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/vsphere/resource_vsphere_distributed_virtual_switch_pvlan_mapping_test.go b/vsphere/resource_vsphere_distributed_virtual_switch_pvlan_mapping_test.go index 35d500fc0..a4f4eb7ce 100644 --- a/vsphere/resource_vsphere_distributed_virtual_switch_pvlan_mapping_test.go +++ b/vsphere/resource_vsphere_distributed_virtual_switch_pvlan_mapping_test.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/testhelper" + "github.com/hashicorp/terraform-provider-vsphere/vsphere/internal/helper/viapi" "github.com/vmware/govmomi/vim25/types" ) @@ -45,8 +46,20 @@ resource "vsphere_distributed_virtual_switch_pvlan_mapping" "mapping" { secondary_vlan_id = 1005 pvlan_type = "promiscuous" } + +resource "vsphere_distributed_virtual_switch" "dvs" { + name = "testacc-dvs2" + datacenter_id = "${data.vsphere_datacenter.rootdc1.id}" + ignore_other_pvlan_mappings = true + + host { + host_system_id = data.vsphere_host.roothost2.id + devices = ["%s"] + } +} `, - testhelper.CombineConfigs(testAccResourceVSphereDistributedVirtualSwitchConfig()), + testhelper.CombineConfigs(testhelper.ConfigDataRootDC1(), testhelper.ConfigDataRootHost2()), + testhelper.HostNic0, ) } @@ -54,6 +67,11 @@ func testAccResourceVSphereDistributedVirtualSwitchPvlanMappingExists(expected b return func(s *terraform.State) error { props, err := testGetDVSProperties(s, "dvs") if err != nil { + if viapi.IsAnyNotFoundError(err) && expected == false { + // Expected missing + return nil + } + return err } diff --git a/vsphere/resource_vsphere_distributed_virtual_switch_test.go b/vsphere/resource_vsphere_distributed_virtual_switch_test.go index 7d62e8231..c6ae4d289 100644 --- a/vsphere/resource_vsphere_distributed_virtual_switch_test.go +++ b/vsphere/resource_vsphere_distributed_virtual_switch_test.go @@ -44,7 +44,7 @@ func TestAccResourceVSphereDistributedVirtualSwitch_basic(t *testing.T) { ResourceName: "vsphere_distributed_virtual_switch.dvs", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"vlan_range"}, + ImportStateVerifyIgnore: []string{"vlan_range", "ignore_other_pvlan_mappings"}, ImportStateIdFunc: func(s *terraform.State) (string, error) { dvs, err := testGetDVS(s, "dvs") if err != nil {