Skip to content

Commit

Permalink
Merge pull request #1403 from ksamoray/testfix-vpc20
Browse files Browse the repository at this point in the history
Fix VPC20 tests for latest platform changes
  • Loading branch information
salv-orlando authored Oct 10, 2024
2 parents f8b3fd0 + 268d696 commit 1562eaa
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
9 changes: 4 additions & 5 deletions nsxt/resource_nsxt_policy_transit_gateway_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,15 @@ resource "nsxt_policy_project" "test" {
tgw_external_connections = [nsxt_policy_gateway_connection.test.path]
}
resource "nsxt_policy_transit_gateway" "test" {
data "nsxt_policy_transit_gateway" "test" {
context {
project_id = nsxt_policy_project.test.id
}
display_name = "%s"
transit_subnets = ["192.168.7.0/24"]
id = "default"
}
resource "nsxt_policy_transit_gateway_attachment" "test" {
parent_path = nsxt_policy_transit_gateway.test.path
parent_path = data.nsxt_policy_transit_gateway.test.path
connection_path = nsxt_policy_gateway_connection.test.path
display_name = "%s"
description = "%s"
Expand All @@ -184,5 +183,5 @@ resource "nsxt_policy_transit_gateway_attachment" "test" {
scope = "scope1"
tag = "tag1"
}
}`, getEdgeClusterName(), dependantEntityName, dependantEntityName, dependantEntityName, dependantEntityName, attrMap["display_name"], attrMap["description"])
}`, getEdgeClusterName(), dependantEntityName, dependantEntityName, dependantEntityName, attrMap["display_name"], attrMap["description"])
}
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_transit_gateway_nat_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ resource "nsxt_policy_transit_gateway" "test" {
}
data "nsxt_policy_transit_gateway_nat" "test" {
transit_gateway_path = nsxt_policy_transit_gateway.test.path
transit_gateway_path = data.nsxt_policy_transit_gateway.test.path
}
`, testAccNsxtProjectContext(), accTestTransitGatewayNatRuleHelperName)
}
Expand Down
12 changes: 10 additions & 2 deletions nsxt/resource_nsxt_policy_transit_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ func TestAccResourceNsxtPolicyTransitGateway_basic(t *testing.T) {
testDataSourceName := "nsxt_policy_transit_gateway.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccOnlyVPC(t) },
PreCheck: func() {
testAccPreCheck(t)
testAccOnlyVPC(t)
testAccNSXVersion(t, "9.1.0")
},
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
return testAccNsxtPolicyTransitGatewayCheckDestroy(state, accTestTransitGatewayUpdateAttributes["display_name"])
Expand Down Expand Up @@ -88,7 +92,11 @@ func TestAccResourceNsxtPolicyTransitGateway_importBasic(t *testing.T) {
testResourceName := "nsxt_policy_transit_gateway.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccOnlyVPC(t) },
PreCheck: func() {
testAccPreCheck(t)
testAccOnlyVPC(t)
testAccNSXVersion(t, "9.1.0")
},
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
return testAccNsxtPolicyTransitGatewayCheckDestroy(state, name)
Expand Down
15 changes: 7 additions & 8 deletions nsxt/resource_nsxt_vpc_connectivity_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,14 @@ func testAccNsxtVpcConnectivityProfileCheckDestroy(state *terraform.State, displ
return nil
}

var testAccNsxtVpcConnectivityProfileHelper = getAccTestResourceName()

func testAccNsxtVpcConnectivityProfilePrerequisite() string {
//TODO: replace datasource with resource when transit GW creation is enabled
return fmt.Sprintf(`
resource "nsxt_policy_transit_gateway" "test" {
data "nsxt_policy_transit_gateway" "test" {
%s
display_name = "%s"
transit_subnets = ["192.168.7.0/24"]
}`, testAccNsxtProjectContext(), testAccNsxtVpcConnectivityProfileHelper)
id = "default"
}
`, testAccNsxtProjectContext())
}

func testAccNsxtVpcConnectivityProfileTemplate(createFlow bool) string {
Expand All @@ -192,7 +191,7 @@ resource "nsxt_vpc_connectivity_profile" "test" {
%s
display_name = "%s"
description = "%s"
transit_gateway_path = nsxt_policy_transit_gateway.test.path
transit_gateway_path = data.nsxt_policy_transit_gateway.test.path
service_gateway {
nat_config {
Expand Down Expand Up @@ -220,7 +219,7 @@ func testAccNsxtVpcConnectivityProfileMinimalistic() string {
resource "nsxt_vpc_connectivity_profile" "test" {
%s
display_name = "%s"
transit_gateway_path = nsxt_policy_transit_gateway.test.path
transit_gateway_path = data.nsxt_policy_transit_gateway.test.path
}`, testAccNsxtProjectContext(), accTestVpcConnectivityProfileUpdateAttributes["display_name"])
}
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ resource "nsxt_vpc_connectivity_profile" "test" {
%s
display_name = "%s"
transit_gateway_path = nsxt_policy_transit_gateway.test.path
transit_gateway_path = data.nsxt_policy_transit_gateway.test.path
service_gateway {
enable = false
}
Expand Down

0 comments on commit 1562eaa

Please sign in to comment.