Skip to content

Commit 4a940a9

Browse files
Cloud Router Standard BPS Terraform Beta to GA support (GoogleCloudPlatform#12697)
1 parent 4ba60c4 commit 4a940a9

6 files changed

+18
-135
lines changed

mmv1/products/compute/Network.yaml

-6
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,18 @@ examples:
6060
project: 'PROJECT_NAME'
6161
- name: 'network_bgp_best_path_selection_mode'
6262
primary_resource_id: 'vpc_network'
63-
min_version: 'beta'
6463
vars:
6564
network_name: 'vpc-network'
6665
test_env_vars:
6766
project: 'PROJECT_NAME'
6867
- name: 'network_bgp_best_path_selection_mode_standard'
6968
primary_resource_id: 'vpc_network'
70-
min_version: 'beta'
7169
vars:
7270
network_name: 'vpc-network'
7371
test_env_vars:
7472
project: 'PROJECT_NAME'
7573
- name: 'network_bgp_best_path_selection_mode_standard_custom_fields'
7674
primary_resource_id: 'vpc_network'
77-
min_version: 'beta'
7875
vars:
7976
network_name: 'vpc-network'
8077
test_env_vars:
@@ -168,7 +165,6 @@ properties:
168165
type: Enum
169166
description: |
170167
The BGP best selection algorithm to be employed. MODE can be LEGACY or STANDARD.
171-
min_version: 'beta'
172168
default_from_api: true
173169
update_url: 'projects/{{project}}/global/networks/{{name}}'
174170
update_verb: 'PATCH'
@@ -180,7 +176,6 @@ properties:
180176
description: |
181177
Enables/disables the comparison of MED across routes with different Neighbor ASNs.
182178
This value can only be set if the --bgp-best-path-selection-mode is STANDARD
183-
min_version: 'beta'
184179
required: false
185180
default_from_api: true
186181
update_url: 'projects/{{project}}/global/networks/{{name}}'
@@ -189,7 +184,6 @@ properties:
189184
type: Enum
190185
description: |
191186
Choice of the behavior of inter-regional cost and MED in the BPS algorithm.
192-
min_version: 'beta'
193187
required: false
194188
default_from_api: true
195189
update_url: 'projects/{{project}}/global/networks/{{name}}'

mmv1/products/compute/Route.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,16 @@ properties:
225225
type: String
226226
description: |
227227
Indicates the origin of the route. Can be IGP (Interior Gateway Protocol), EGP (Exterior Gateway Protocol), or INCOMPLETE.
228-
min_version: 'beta'
229228
output: true
230229
- name: 'nextHopMed'
231230
type: String
232231
description: |
233232
Multi-Exit Discriminator, a BGP route metric that indicates the desirability of a particular route in a network.
234-
min_version: 'beta'
235233
output: true
236234
- name: 'nextHopInterRegionCost'
237235
type: String
238236
description: |
239237
Internal fixed region-to-region cost that Google Cloud calculates based on factors such as network performance, distance, and available bandwidth between regions.
240-
min_version: 'beta'
241238
output: true
242239
- name: 'nextHopIlb'
243240
type: String

mmv1/templates/terraform/examples/network_bgp_best_path_selection_mode.tf.tmpl

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
resource "google_compute_network" "{{$.PrimaryResourceId}}" {
2-
provider = google-beta
32
project = "{{index $.TestEnvVars "project"}}"
43
name = "{{index $.Vars "network_name"}}"
54
routing_mode = "GLOBAL"

mmv1/templates/terraform/examples/network_bgp_best_path_selection_mode_standard.tf.tmpl

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
resource "google_compute_network" "{{$.PrimaryResourceId}}" {
2-
provider = google-beta
32
project = "{{index $.TestEnvVars "project"}}"
43
name = "{{index $.Vars "network_name"}}"
54
routing_mode = "GLOBAL"

mmv1/templates/terraform/examples/network_bgp_best_path_selection_mode_standard_custom_fields.tf.tmpl

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
resource "google_compute_network" "{{$.PrimaryResourceId}}" {
2-
provider = google-beta
32
project = "{{index $.TestEnvVars "project"}}"
43
name = "{{index $.Vars "network_name"}}"
54
routing_mode = "GLOBAL"

mmv1/third_party/terraform/services/compute/resource_compute_network_test.go.tmpl

+18-123
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ func TestAccComputeNetwork_routingModeAndUpdate(t *testing.T) {
112112
})
113113
}
114114

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

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

123122
acctest.VcrTest(t, resource.TestCase{
124123
PreCheck: func() { acctest.AccTestPreCheck(t) },
125-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
124+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
126125
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
127126
Steps: []resource.TestStep{
128127
{
129128
Config: testAccComputeNetwork_best_bgp_path_selection_mode(networkName, "LEGACY"),
130129
Check: resource.ComposeTestCheckFunc(
131130
testAccCheckComputeNetworkExists(
132131
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
133-
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, "LEGACY"),
132+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_best_path_selection_mode", "LEGACY"),
134133
),
135134
},
136135
// Test updating the best bgp path selection field (only updatable field).
@@ -139,7 +138,7 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
139138
Check: resource.ComposeTestCheckFunc(
140139
testAccCheckComputeNetworkExists(
141140
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
142-
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, "STANDARD"),
141+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_best_path_selection_mode", "STANDARD"),
143142
),
144143
},
145144
},
@@ -157,16 +156,15 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
157156

158157
acctest.VcrTest(t, resource.TestCase{
159158
PreCheck: func() { acctest.AccTestPreCheck(t) },
160-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
159+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
161160
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
162161
Steps: []resource.TestStep{
163162
{
164163
Config: testAccComputeNetwork_bgp_always_compare_med(networkName, false),
165164
Check: resource.ComposeTestCheckFunc(
166165
testAccCheckComputeNetworkExists(
167166
t, "google_compute_network.acc_network_bgp_always_compare_med", &network),
168-
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
169-
t, "google_compute_network.acc_network_bgp_always_compare_med", &network, false),
167+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_always_compare_med", "bgp_always_compare_med", "false"),
170168
),
171169
},
172170
// Test updating the bgpAlwaysCompareMed field (only updatable field).
@@ -175,8 +173,7 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
175173
Check: resource.ComposeTestCheckFunc(
176174
testAccCheckComputeNetworkExists(
177175
t, "google_compute_network.acc_network_bgp_always_compare_med", &network),
178-
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
179-
t, "google_compute_network.acc_network_bgp_always_compare_med", &network, true),
176+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_always_compare_med", "bgp_always_compare_med", "true"),
180177
),
181178
},
182179
},
@@ -193,16 +190,15 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
193190

194191
acctest.VcrTest(t, resource.TestCase{
195192
PreCheck: func() { acctest.AccTestPreCheck(t) },
196-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
193+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
197194
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
198195
Steps: []resource.TestStep{
199196
{
200197
Config: testAccComputeNetwork_bgp_inter_region_cost(networkName, "DEFAULT"),
201198
Check: resource.ComposeTestCheckFunc(
202199
testAccCheckComputeNetworkExists(
203200
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network),
204-
testAccCheckComputeNetworkHasBgpInterRegionCost(
205-
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network, "DEFAULT"),
201+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_inter_region_cost", "bgp_inter_region_cost", "DEFAULT"),
206202
),
207203
},
208204
// Test updating the bgpInterRegionCost field (only updatable field).
@@ -211,14 +207,14 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
211207
Check: resource.ComposeTestCheckFunc(
212208
testAccCheckComputeNetworkExists(
213209
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network),
214-
testAccCheckComputeNetworkHasBgpInterRegionCost(
215-
t, "google_compute_network.acc_network_bgp_inter_region_cost", &network, "ADD_COST_TO_MED"),
210+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_inter_region_cost", "bgp_inter_region_cost", "ADD_COST_TO_MED"),
216211
),
217212
},
218213
},
219214
})
220215
}
221216

217+
{{ if ne $.TargetVersionName `ga` -}}
222218
func TestAccComputeNetwork_networkProfile(t *testing.T) {
223219
t.Parallel()
224220

@@ -303,7 +299,6 @@ func TestAccComputeNetwork_default_routing_mode(t *testing.T) {
303299
})
304300
}
305301

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

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

316311
acctest.VcrTest(t, resource.TestCase{
317312
PreCheck: func() { acctest.AccTestPreCheck(t) },
318-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
313+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
319314
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
320315
Steps: []resource.TestStep{
321316
{
322-
Config: testAccComputeBetaNetwork_basic(networkName),
317+
Config: testAccComputeNetwork_basic(networkName),
323318
Check: resource.ComposeTestCheckFunc(
324319
testAccCheckComputeNetworkExists(
325320
t, "google_compute_network.bar", &network),
326-
testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t, "google_compute_network.bar", &network, expectedBgpBestPathSelection),
321+
resource.TestCheckResourceAttr("google_compute_network.bar", "bgp_best_path_selection_mode", expectedBgpBestPathSelection),
327322
),
328323
},
329324
},
@@ -338,26 +333,24 @@ func TestAccComputeNetwork_default_bgp_always_compare_med(t *testing.T) {
338333
suffixName := acctest.RandString(t, 10)
339334
networkName := fmt.Sprintf("tf-test-bgp-always-compare-med-default-routes-%s", suffixName)
340335

341-
expectedBgpAlwaysCompareMed := false
336+
expectedBgpAlwaysCompareMed := "false"
342337

343338
acctest.VcrTest(t, resource.TestCase{
344339
PreCheck: func() { acctest.AccTestPreCheck(t) },
345-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
340+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
346341
CheckDestroy: testAccCheckComputeNetworkDestroyProducer(t),
347342
Steps: []resource.TestStep{
348343
{
349344
Config: testAccComputeNetwork_best_bgp_path_selection_mode(networkName, "STANDARD"),
350345
Check: resource.ComposeTestCheckFunc(
351346
testAccCheckComputeNetworkExists(
352347
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network),
353-
testAccCheckComputeNetworkHasBgpAlwaysCompareMed(
354-
t, "google_compute_network.acc_network_bgp_best_path_selection_mode", &network, expectedBgpAlwaysCompareMed),
348+
resource.TestCheckResourceAttr("google_compute_network.acc_network_bgp_best_path_selection_mode", "bgp_always_compare_med", expectedBgpAlwaysCompareMed),
355349
),
356350
},
357351
},
358352
})
359353
}
360-
{{- end }}
361354

362355
func TestAccComputeNetwork_networkDeleteDefaultRoute(t *testing.T) {
363356
t.Parallel()
@@ -564,94 +557,8 @@ func testAccCheckComputeNetworkHasRoutingMode(t *testing.T, n string, network *c
564557
}
565558
}
566559

567-
{{ if ne $.TargetVersionName `ga` -}}
568-
func testAccCheckComputeNetworkHasBgpBestPathSelectionMode(t *testing.T, n string, network *compute.Network, bgpBestPathSelectionMode string) resource.TestCheckFunc {
569-
return func(s *terraform.State) error {
570-
config := acctest.GoogleProviderConfig(t)
571-
572-
rs, ok := s.RootModule().Resources[n]
573-
if !ok {
574-
return fmt.Errorf("Not found: %s", n)
575-
}
576-
577-
if rs.Primary.Attributes["bgp_always_compare_med"] == "" {
578-
return fmt.Errorf("BGP always compare med not found on resource")
579-
}
580-
581-
found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
582-
config.Project, network.Name).Do()
583-
if err != nil {
584-
return err
585-
}
586-
587-
foundBgpBestPathSelectionMode := found.RoutingConfig.BgpBestPathSelectionMode
588-
589-
if bgpBestPathSelectionMode != foundBgpBestPathSelectionMode {
590-
return fmt.Errorf("Expected BGP always compare med %s to match actual BGP always compare med %s", bgpBestPathSelectionMode, foundBgpBestPathSelectionMode)
591-
}
592-
593-
return nil
594-
}
595-
}
596-
597-
func testAccCheckComputeNetworkHasBgpAlwaysCompareMed(t *testing.T, n string, network *compute.Network, bgpAlwaysCompareMed bool) resource.TestCheckFunc {
598-
return func(s *terraform.State) error {
599-
config := acctest.GoogleProviderConfig(t)
600-
601-
rs, ok := s.RootModule().Resources[n]
602-
if !ok {
603-
return fmt.Errorf("Not found: %s", n)
604-
}
605-
606-
if rs.Primary.Attributes["bgp_always_compare_med"] == "" {
607-
return fmt.Errorf("BGP always compare med not found on resource")
608-
}
609-
610-
found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
611-
config.Project, network.Name).Do()
612-
if err != nil {
613-
return err
614-
}
615-
616-
foundBgpAlwaysCompareMed := found.RoutingConfig.BgpAlwaysCompareMed
617-
618-
if foundBgpAlwaysCompareMed != bgpAlwaysCompareMed {
619-
return fmt.Errorf("Expected BGP always compare med %t to match actual BGP always compare med %t", bgpAlwaysCompareMed, foundBgpAlwaysCompareMed)
620-
}
621-
622-
return nil
623-
}
624-
}
625-
626-
func testAccCheckComputeNetworkHasBgpInterRegionCost(t *testing.T, n string, network *compute.Network, bgpInterRegionCost string) resource.TestCheckFunc {
627-
return func(s *terraform.State) error {
628-
config := acctest.GoogleProviderConfig(t)
629-
630-
rs, ok := s.RootModule().Resources[n]
631-
if !ok {
632-
return fmt.Errorf("Not found: %s", n)
633-
}
634-
635-
if rs.Primary.Attributes["bgp_inter_region_cost"] == "" {
636-
return fmt.Errorf("BGP inter region cost not found on resource")
637-
}
638-
639-
found, err := config.NewComputeClient(config.UserAgent).Networks.Get(
640-
config.Project, network.Name).Do()
641-
if err != nil {
642-
return err
643-
}
644-
645-
foundBgpInterRegionCost := found.RoutingConfig.BgpInterRegionCost
646-
647-
if foundBgpInterRegionCost != bgpInterRegionCost {
648-
return fmt.Errorf("Expected BGP always compare med %s to match actual BGP always compare med %s", bgpInterRegionCost, foundBgpInterRegionCost)
649-
}
650-
651-
return nil
652-
}
653-
}
654560

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

750-
{{ if ne $.TargetVersionName `ga` -}}
751-
func testAccComputeBetaNetwork_basic(networkName string) string {
752-
return fmt.Sprintf(`
753-
resource "google_compute_network" "bar" {
754-
provider = google-beta
755-
name = "%s"
756-
auto_create_subnetworks = true
757-
}
758-
`, networkName)
759-
}
760657

761658
func testAccComputeNetwork_best_bgp_path_selection_mode(networkName, bgpBestPathSelection string) string {
762659
return fmt.Sprintf(`
763660
resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
764-
provider = google-beta
765661
name = "%s"
766662
routing_mode = "GLOBAL"
767663
bgp_best_path_selection_mode = "%s"
@@ -772,7 +668,6 @@ resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
772668
func testAccComputeNetwork_bgp_always_compare_med(networkName string, bgpAlwaysCompareMed bool) string {
773669
return fmt.Sprintf(`
774670
resource "google_compute_network" "acc_network_bgp_always_compare_med" {
775-
provider = google-beta
776671
name = "%s"
777672
routing_mode = "GLOBAL"
778673
bgp_best_path_selection_mode = "STANDARD"
@@ -784,7 +679,6 @@ resource "google_compute_network" "acc_network_bgp_always_compare_med" {
784679
func testAccComputeNetwork_bgp_inter_region_cost(networkName, bgpInterRegionCost string) string {
785680
return fmt.Sprintf(`
786681
resource "google_compute_network" "acc_network_bgp_inter_region_cost" {
787-
provider = google-beta
788682
name = "%s"
789683
routing_mode = "GLOBAL"
790684
bgp_best_path_selection_mode = "STANDARD"
@@ -793,6 +687,7 @@ resource "google_compute_network" "acc_network_bgp_inter_region_cost" {
793687
`, networkName, bgpInterRegionCost)
794688
}
795689

690+
{{ if ne $.TargetVersionName `ga` -}}
796691
func testAccComputeNetwork_network_profile(networkName, networkProfile string) string {
797692
return fmt.Sprintf(`
798693
resource "google_compute_network" "acc_network_network_profile" {

0 commit comments

Comments
 (0)