Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud Router Standard BPS Terraform Beta to GA support #12697

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions mmv1/products/compute/Network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,18 @@ examples:
project: 'PROJECT_NAME'
- name: 'network_bgp_best_path_selection_mode'
primary_resource_id: 'vpc_network'
min_version: 'beta'
vars:
network_name: 'vpc-network'
test_env_vars:
project: 'PROJECT_NAME'
- name: 'network_bgp_best_path_selection_mode_standard'
primary_resource_id: 'vpc_network'
min_version: 'beta'
vars:
network_name: 'vpc-network'
test_env_vars:
project: 'PROJECT_NAME'
- name: 'network_bgp_best_path_selection_mode_standard_custom_fields'
primary_resource_id: 'vpc_network'
min_version: 'beta'
vars:
network_name: 'vpc-network'
test_env_vars:
Expand Down Expand Up @@ -168,7 +165,6 @@ properties:
type: Enum
description: |
The BGP best selection algorithm to be employed. MODE can be LEGACY or STANDARD.
min_version: 'beta'
default_from_api: true
update_url: 'projects/{{project}}/global/networks/{{name}}'
update_verb: 'PATCH'
Expand All @@ -180,7 +176,6 @@ properties:
description: |
Enables/disables the comparison of MED across routes with different Neighbor ASNs.
This value can only be set if the --bgp-best-path-selection-mode is STANDARD
min_version: 'beta'
required: false
default_from_api: true
update_url: 'projects/{{project}}/global/networks/{{name}}'
Expand All @@ -189,7 +184,6 @@ properties:
type: Enum
description: |
Choice of the behavior of inter-regional cost and MED in the BPS algorithm.
min_version: 'beta'
required: false
default_from_api: true
update_url: 'projects/{{project}}/global/networks/{{name}}'
Expand Down
3 changes: 0 additions & 3 deletions mmv1/products/compute/Route.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,16 @@ properties:
type: String
description: |
Indicates the origin of the route. Can be IGP (Interior Gateway Protocol), EGP (Exterior Gateway Protocol), or INCOMPLETE.
min_version: 'beta'
output: true
- name: 'nextHopMed'
type: String
description: |
Multi-Exit Discriminator, a BGP route metric that indicates the desirability of a particular route in a network.
min_version: 'beta'
output: true
- name: 'nextHopInterRegionCost'
type: String
description: |
Internal fixed region-to-region cost that Google Cloud calculates based on factors such as network performance, distance, and available bandwidth between regions.
min_version: 'beta'
output: true
- name: 'nextHopIlb'
type: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_compute_network" "{{$.PrimaryResourceId}}" {
provider = google-beta
project = "{{index $.TestEnvVars "project"}}"
name = "{{index $.Vars "network_name"}}"
routing_mode = "GLOBAL"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_compute_network" "{{$.PrimaryResourceId}}" {
provider = google-beta
project = "{{index $.TestEnvVars "project"}}"
name = "{{index $.Vars "network_name"}}"
routing_mode = "GLOBAL"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_compute_network" "{{$.PrimaryResourceId}}" {
provider = google-beta
project = "{{index $.TestEnvVars "project"}}"
name = "{{index $.Vars "network_name"}}"
routing_mode = "GLOBAL"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func TestAccComputeNetwork_routingModeAndUpdate(t *testing.T) {
})
}

{{ if ne $.TargetVersionName `ga` -}}
func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
t.Parallel()

Expand All @@ -122,15 +121,15 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeNetwork_best_bgp_path_selection_mode(networkName, "LEGACY"),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeNetworkExists(
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, "LEGACY"),
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_best_path_selection_mode", "LEGACY"),
),
},
// Test updating the best bgp path selection field (only updatable field).
Expand All @@ -139,7 +138,7 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeNetworkExists(
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, "STANDARD"),
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_best_path_selection_mode", "STANDARD"),
),
},
},
Expand All @@ -157,16 +156,15 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeNetwork_bgp_always_compare_med(networkName, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeNetworkExists(
t, "google_compute_network.acc_network_bgp_always_compare_med", &network),
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
t, "google_compute_network.acc_network_bgp_always_compare_med", &network, false),
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_always_compare_med", "bgp_always_compare_med", "false"),
),
},
// Test updating the bgpAlwaysCompareMed field (only updatable field).
Expand All @@ -175,8 +173,7 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeNetworkExists(
t, "google_compute_network.acc_network_bgp_always_compare_med", &network),
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
t, "google_compute_network.acc_network_bgp_always_compare_med", &network, true),
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_always_compare_med", "bgp_always_compare_med", "true"),
),
},
},
Expand All @@ -193,16 +190,15 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeNetwork_bgp_inter_region_cost(networkName, "DEFAULT"),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeNetworkExists(
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network),
testAccCheckComputeNetworkHasBgpInterRegionCost(
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network, "DEFAULT"),
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_inter_region_cost", "bgp_inter_region_cost", "DEFAULT"),
),
},
// Test updating the bgpInterRegionCost field (only updatable field).
Expand All @@ -211,14 +207,14 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeNetworkExists(
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network),
testAccCheckComputeNetworkHasBgpInterRegionCost(
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network, "ADD_COST_TO_MED"),
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_inter_region_cost", "bgp_inter_region_cost", "ADD_COST_TO_MED"),
),
},
},
})
}

{{ if ne $.TargetVersionName `ga` -}}
func TestAccComputeNetwork_networkProfile(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -303,7 +299,6 @@ func TestAccComputeNetwork_default_routing_mode(t *testing.T) {
})
}

{{ if ne $.TargetVersionName `ga` -}}
func TestAccComputeNetwork_default_bgp_best_path_selection_mode(t *testing.T) {
t.Parallel()

Expand All @@ -315,15 +310,15 @@ func TestAccComputeNetwork_default_bgp_best_path_selection_mode(t *testing.T) {

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeBetaNetwork_basic(networkName),
Config: testAccComputeNetwork_basic(networkName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeNetworkExists(
t, "google_compute_network.bar", &network),
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.bar", &network, expectedBgpBestPathSelection),
akshat-jindal-nit marked this conversation as resolved.
Show resolved Hide resolved
resource.TestCheckResourceAttr("google_compute_network.bar", "bgp_best_path_selection_mode", expectedBgpBestPathSelection),
),
},
},
Expand All @@ -338,26 +333,24 @@ func TestAccComputeNetwork_default_bgp_always_compare_med(t *testing.T) {
suffixName := acctest.RandString(t, 10)
networkName := fmt.Sprintf("tf-test-bgp-always-compare-med-default-routes-%s", suffixName)

expectedBgpAlwaysCompareMed := false
expectedBgpAlwaysCompareMed := "false"

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeNetwork_best_bgp_path_selection_mode(networkName, "STANDARD"),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeNetworkExists(
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, expectedBgpAlwaysCompareMed),
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_always_compare_med", expectedBgpAlwaysCompareMed),
),
},
},
})
}
{{- end }}

func TestAccComputeNetwork_networkDeleteDefaultRoute(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -564,94 +557,8 @@ func testAccCheckComputeNetworkHasRoutingMode(t *testing.T, n string, network *c
}
}

{{ if ne $.TargetVersionName `ga` -}}
func testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t *testing.T, n string, network *compute.Network, bgpBestPathSelectionMode string) resource.TestCheckFunc {
return func(s *terraform.State) error {
config := acctest.GoogleProviderConfig(t)

rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}

if rs.Primary.Attributes["bgp_always_compare_med"] == "" {
return fmt.Errorf("BGP always compare med not found on resource")
}

found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
config.Project, network.Name).Do()
if err != nil {
return err
}

foundBgpBestPathSelectionMode := found.RoutingConfig.BgpBestPathSelectionMode

if bgpBestPathSelectionMode != foundBgpBestPathSelectionMode {
return fmt.Errorf("Expected BGP always compare med %s to match actual BGP always compare med %s", bgpBestPathSelectionMode, foundBgpBestPathSelectionMode)
}

return nil
}
}

func testAccCheckComputeNetworkHasBgpAlwaysCompareMed(t *testing.T, n string, network *compute.Network, bgpAlwaysCompareMed bool) resource.TestCheckFunc {
return func(s *terraform.State) error {
config := acctest.GoogleProviderConfig(t)

rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}

if rs.Primary.Attributes["bgp_always_compare_med"] == "" {
return fmt.Errorf("BGP always compare med not found on resource")
}

found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
config.Project, network.Name).Do()
if err != nil {
return err
}

foundBgpAlwaysCompareMed := found.RoutingConfig.BgpAlwaysCompareMed

if foundBgpAlwaysCompareMed != bgpAlwaysCompareMed {
return fmt.Errorf("Expected BGP always compare med %t to match actual BGP always compare med %t", bgpAlwaysCompareMed, foundBgpAlwaysCompareMed)
}

return nil
}
}

func testAccCheckComputeNetworkHasBgpInterRegionCost(t *testing.T, n string, network *compute.Network, bgpInterRegionCost string) resource.TestCheckFunc {
return func(s *terraform.State) error {
config := acctest.GoogleProviderConfig(t)

rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}

if rs.Primary.Attributes["bgp_inter_region_cost"] == "" {
return fmt.Errorf("BGP inter region cost not found on resource")
}

found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
config.Project, network.Name).Do()
if err != nil {
return err
}

foundBgpInterRegionCost := found.RoutingConfig.BgpInterRegionCost

if foundBgpInterRegionCost != bgpInterRegionCost {
return fmt.Errorf("Expected BGP always compare med %s to match actual BGP always compare med %s", bgpInterRegionCost, foundBgpInterRegionCost)
}

return nil
}
}

{{ if ne $.TargetVersionName `ga` -}}
func testAccCheckComputeNetworkHasNetworkProfile(t *testing.T, n string, network *compute.Network, networkProfile string) resource.TestCheckFunc {
return func(s *terraform.State) error {
config := acctest.GoogleProviderConfig(t)
Expand Down Expand Up @@ -747,21 +654,10 @@ resource "google_compute_network" "acc_network_routing_mode" {
`, networkName, routingMode)
}

{{ if ne $.TargetVersionName `ga` -}}
func testAccComputeBetaNetwork_basic(networkName string) string {
return fmt.Sprintf(`
resource "google_compute_network" "bar" {
provider = google-beta
name = "%s"
auto_create_subnetworks = true
}
`, networkName)
}

func testAccComputeNetwork_best_bgp_path_selection_mode(networkName, bgpBestPathSelection string) string {
return fmt.Sprintf(`
resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
provider = google-beta
name = "%s"
routing_mode = "GLOBAL"
bgp_best_path_selection_mode = "%s"
Expand All @@ -772,7 +668,6 @@ resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
func testAccComputeNetwork_bgp_always_compare_med(networkName string, bgpAlwaysCompareMed bool) string {
return fmt.Sprintf(`
resource "google_compute_network" "acc_network_bgp_always_compare_med" {
provider = google-beta
name = "%s"
routing_mode = "GLOBAL"
bgp_best_path_selection_mode = "STANDARD"
Expand All @@ -784,7 +679,6 @@ resource "google_compute_network" "acc_network_bgp_always_compare_med" {
func testAccComputeNetwork_bgp_inter_region_cost(networkName, bgpInterRegionCost string) string {
return fmt.Sprintf(`
resource "google_compute_network" "acc_network_bgp_inter_region_cost" {
provider = google-beta
name = "%s"
routing_mode = "GLOBAL"
bgp_best_path_selection_mode = "STANDARD"
Expand All @@ -793,6 +687,7 @@ resource "google_compute_network" "acc_network_bgp_inter_region_cost" {
`, networkName, bgpInterRegionCost)
}

{{ if ne $.TargetVersionName `ga` -}}
func testAccComputeNetwork_network_profile(networkName, networkProfile string) string {
return fmt.Sprintf(`
resource "google_compute_network" "acc_network_network_profile" {
Expand Down
Loading