From 7efe8623b846b37f4fcaa36b01c56479f1533035 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Wed, 6 Dec 2023 19:41:43 +0200 Subject: [PATCH] Add missing context in T1 GW interface tests And update affected tests. Signed-off-by: Kobi Samoray --- ...sxt_policy_tier0_gateway_interface_test.go | 19 ++++++++++++------- ...resource_nsxt_policy_tier0_gateway_test.go | 4 ++-- ...sxt_policy_tier1_gateway_interface_test.go | 8 ++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/nsxt/resource_nsxt_policy_tier0_gateway_interface_test.go b/nsxt/resource_nsxt_policy_tier0_gateway_interface_test.go index 1eb050c2d..ec2b7ec1d 100644 --- a/nsxt/resource_nsxt_policy_tier0_gateway_interface_test.go +++ b/nsxt/resource_nsxt_policy_tier0_gateway_interface_test.go @@ -611,16 +611,21 @@ data "nsxt_policy_transport_zone" "test" { }`, getEdgeClusterName(), tzName) } -func testAccNsxtPolicyGatewayInterfaceDeps(vlans string) string { +func testAccNsxtPolicyGatewayInterfaceDeps(vlans string, withContext bool) string { + context := "" + if withContext { + context = testAccNsxtPolicyMultitenancyContext() + } return testAccNsxtPolicyGatewayFabricDeps(true) + fmt.Sprintf(` resource "nsxt_policy_vlan_segment" "test" { +%s transport_zone_path = data.nsxt_policy_transport_zone.test.path display_name = "interface_test" vlan_ids = [%s] subnet { cidr = "10.2.2.2/24" } -}`, vlans) +}`, context, vlans) } func testAccNsxtPolicyTier0EdgeClusterTemplate() string { @@ -662,7 +667,7 @@ data "nsxt_policy_realization_info" "realization_info" { } func testAccNsxtPolicyTier0InterfaceServiceTemplate(name string, subnet string, mtu string) string { - return testAccNsxtPolicyGatewayInterfaceDeps("11") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", false) + fmt.Sprintf(` resource "nsxt_policy_tier0_gateway" "test" { display_name = "%s" @@ -689,7 +694,7 @@ resource "nsxt_policy_tier0_gateway_interface" "test" { } func testAccNsxtPolicyTier0InterfaceThinTemplate(name string, subnet string) string { - return testAccNsxtPolicyGatewayInterfaceDeps("11") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", false) + fmt.Sprintf(` resource "nsxt_policy_tier0_gateway" "test" { display_name = "%s" ha_mode = "ACTIVE_STANDBY" @@ -708,7 +713,7 @@ resource "nsxt_policy_tier0_gateway_interface" "test" { } func testAccNsxtPolicyTier0InterfaceTemplateWithID(name string, subnet string) string { - return testAccNsxtPolicyGatewayInterfaceDeps("11") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", false) + fmt.Sprintf(` resource "nsxt_policy_tier0_gateway" "test" { display_name = "%s" ha_mode = "ACTIVE_STANDBY" @@ -729,7 +734,7 @@ resource "nsxt_policy_tier0_gateway_interface" "test" { } func testAccNsxtPolicyTier0InterfaceTemplateWithV6(name string, subnet string) string { - return testAccNsxtPolicyGatewayInterfaceDeps("11") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", false) + fmt.Sprintf(` data "nsxt_policy_ipv6_ndra_profile" "default" { display_name = "default" } @@ -780,7 +785,7 @@ func testAccNsxtPolicyTier0InterfaceExternalTemplate(name string, subnet string, }` ospfDeps = testAccNsxtPolicyTier0InterfaceOspfDeps() } - return testAccNsxtPolicyGatewayInterfaceDeps("11") + ospfDeps + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", false) + ospfDeps + fmt.Sprintf(` data "nsxt_policy_edge_node" "EN" { edge_cluster_path = data.nsxt_policy_edge_cluster.EC.path member_index = 0 diff --git a/nsxt/resource_nsxt_policy_tier0_gateway_test.go b/nsxt/resource_nsxt_policy_tier0_gateway_test.go index 7951263e8..1d6a295b6 100644 --- a/nsxt/resource_nsxt_policy_tier0_gateway_test.go +++ b/nsxt/resource_nsxt_policy_tier0_gateway_test.go @@ -770,7 +770,7 @@ resource "nsxt_policy_bgp_config" "test" { ecmp = true }` } - return testAccNsxtPolicyGatewayInterfaceDeps("11, 12") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11, 12", false) + fmt.Sprintf(` resource "nsxt_policy_tier0_gateway" "parent" { nsx_id = "vrf-parent" display_name = "parent" @@ -818,7 +818,7 @@ data "nsxt_policy_realization_info" "realization_info" { } func testAccNsxtPolicyTier0WithVRFTearDown() string { - return testAccNsxtPolicyGatewayInterfaceDeps("11, 12") + ` + return testAccNsxtPolicyGatewayInterfaceDeps("11, 12", false) + ` data "nsxt_policy_edge_node" "EN" { edge_cluster_path = data.nsxt_policy_edge_cluster.EC.path member_index = 0 diff --git a/nsxt/resource_nsxt_policy_tier1_gateway_interface_test.go b/nsxt/resource_nsxt_policy_tier1_gateway_interface_test.go index 2c35688db..cfad4e518 100644 --- a/nsxt/resource_nsxt_policy_tier1_gateway_interface_test.go +++ b/nsxt/resource_nsxt_policy_tier1_gateway_interface_test.go @@ -416,7 +416,7 @@ func testAccNsxtPolicyTier1InterfaceTemplate(name string, subnet string, mtu str if withContext { context = testAccNsxtPolicyMultitenancyContext() } - return testAccNsxtPolicyGatewayInterfaceDeps("11") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", withContext) + fmt.Sprintf(` resource "nsxt_policy_tier1_gateway" "test" { %s display_name = "%s" @@ -446,7 +446,7 @@ func testAccNsxtPolicyTier1InterfaceThinTemplate(name string, subnet string, wit if withContext { context = testAccNsxtPolicyMultitenancyContext() } - return testAccNsxtPolicyGatewayInterfaceDeps("11") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", withContext) + fmt.Sprintf(` resource "nsxt_policy_tier1_gateway" "test" { %s display_name = "%s" @@ -465,7 +465,7 @@ resource "nsxt_policy_tier1_gateway_interface" "test" { } func testAccNsxtPolicyTier1InterfaceTemplateWithID(name string, subnet string) string { - return testAccNsxtPolicyGatewayInterfaceDeps("11") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", false) + fmt.Sprintf(` resource "nsxt_policy_tier1_gateway" "test" { display_name = "%s" %s @@ -489,7 +489,7 @@ func testAccNextPolicyTier1InterfaceRealizationTemplate() string { } func testAccNsxtPolicyTier1InterfaceTemplateWithIPv6(name string, subnet string) string { - return testAccNsxtPolicyGatewayInterfaceDeps("11") + fmt.Sprintf(` + return testAccNsxtPolicyGatewayInterfaceDeps("11", false) + fmt.Sprintf(` data "nsxt_policy_ipv6_ndra_profile" "default" { display_name = "default" }