Skip to content

Commit

Permalink
Add missing context in T1 GW interface tests
Browse files Browse the repository at this point in the history
And update affected tests.

Signed-off-by: Kobi Samoray <[email protected]>
  • Loading branch information
ksamoray committed Dec 6, 2023
1 parent 92dc814 commit 7efe862
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
19 changes: 12 additions & 7 deletions nsxt/resource_nsxt_policy_tier0_gateway_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nsxt/resource_nsxt_policy_tier0_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions nsxt/resource_nsxt_policy_tier1_gateway_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"
}
Expand Down

0 comments on commit 7efe862

Please sign in to comment.