@@ -119,15 +119,15 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
119
119
120
120
acctest .VcrTest (t , resource.TestCase {
121
121
PreCheck : func () { acctest .AccTestPreCheck (t ) },
122
- ProtoV5ProviderFactories : acctest .ProtoV5ProviderBetaFactories (t ),
122
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
123
123
CheckDestroy : testAccCheckComputeNetworkDestroyProducer (t ),
124
124
Steps : []resource.TestStep {
125
125
{
126
126
Config : testAccComputeNetwork_best_bgp_path_selection_mode (networkName , "LEGACY" ),
127
127
Check : resource .ComposeTestCheckFunc (
128
128
testAccCheckComputeNetworkExists (
129
129
t , "google_compute_network.acc_network_bgp_best_path_selection_mode" , & network ),
130
- testAccCheckComputeNetworkHasBgpBestPathSelectionMode ( t , "google_compute_network.acc_network_bgp_best_path_selection_mode" , & network , "LEGACY" ),
130
+ resource . TestCheckResourceAttr ( "google_compute_network.acc_network_bgp_best_path_selection_mode" , "bgp_best_path_selection_mode" , "LEGACY" ),
131
131
),
132
132
},
133
133
// Test updating the best bgp path selection field (only updatable field).
@@ -136,7 +136,7 @@ func TestAccComputeNetwork_bgpBestPathSelectionModeAndUpdate(t *testing.T) {
136
136
Check : resource .ComposeTestCheckFunc (
137
137
testAccCheckComputeNetworkExists (
138
138
t , "google_compute_network.acc_network_bgp_best_path_selection_mode" , & network ),
139
- testAccCheckComputeNetworkHasBgpBestPathSelectionMode ( t , "google_compute_network.acc_network_bgp_best_path_selection_mode" , & network , "STANDARD" ),
139
+ resource . TestCheckResourceAttr ( "google_compute_network.acc_network_bgp_best_path_selection_mode" , "bgp_best_path_selection_mode" , "STANDARD" ),
140
140
),
141
141
},
142
142
},
@@ -153,16 +153,15 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
153
153
154
154
acctest .VcrTest (t , resource.TestCase {
155
155
PreCheck : func () { acctest .AccTestPreCheck (t ) },
156
- ProtoV5ProviderFactories : acctest .ProtoV5ProviderBetaFactories (t ),
156
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
157
157
CheckDestroy : testAccCheckComputeNetworkDestroyProducer (t ),
158
158
Steps : []resource.TestStep {
159
159
{
160
160
Config : testAccComputeNetwork_bgp_always_compare_med (networkName , false ),
161
161
Check : resource .ComposeTestCheckFunc (
162
162
testAccCheckComputeNetworkExists (
163
163
t , "google_compute_network.acc_network_bgp_always_compare_med" , & network ),
164
- testAccCheckComputeNetworkHasBgpAlwaysCompareMed (
165
- t , "google_compute_network.acc_network_bgp_always_compare_med" , & network , false ),
164
+ resource .TestCheckResourceAttr ("google_compute_network.acc_network_bgp_always_compare_med" , "bgp_always_compare_med" , "false" ),
166
165
),
167
166
},
168
167
// Test updating the bgpAlwaysCompareMed field (only updatable field).
@@ -171,8 +170,7 @@ func TestAccComputeNetwork_bgpAlwaysCompareMedAndUpdate(t *testing.T) {
171
170
Check : resource .ComposeTestCheckFunc (
172
171
testAccCheckComputeNetworkExists (
173
172
t , "google_compute_network.acc_network_bgp_always_compare_med" , & network ),
174
- testAccCheckComputeNetworkHasBgpAlwaysCompareMed (
175
- t , "google_compute_network.acc_network_bgp_always_compare_med" , & network , true ),
173
+ resource .TestCheckResourceAttr ("google_compute_network.acc_network_bgp_always_compare_med" , "bgp_always_compare_med" , "true" ),
176
174
),
177
175
},
178
176
},
@@ -188,16 +186,15 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
188
186
189
187
acctest .VcrTest (t , resource.TestCase {
190
188
PreCheck : func () { acctest .AccTestPreCheck (t ) },
191
- ProtoV5ProviderFactories : acctest .ProtoV5ProviderBetaFactories (t ),
189
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
192
190
CheckDestroy : testAccCheckComputeNetworkDestroyProducer (t ),
193
191
Steps : []resource.TestStep {
194
192
{
195
193
Config : testAccComputeNetwork_bgp_inter_region_cost (networkName , "DEFAULT" ),
196
194
Check : resource .ComposeTestCheckFunc (
197
195
testAccCheckComputeNetworkExists (
198
196
t , "google_compute_network.acc_network_bgp_inter_region_cost" , & network ),
199
- testAccCheckComputeNetworkHasBgpInterRegionCost (
200
- t , "google_compute_network.acc_network_bgp_inter_region_cost" , & network , "DEFAULT" ),
197
+ resource .TestCheckResourceAttr ("google_compute_network.acc_network_bgp_inter_region_cost" , "bgp_inter_region_cost" , "DEFAULT" ),
201
198
),
202
199
},
203
200
// Test updating the bgpInterRegionCost field (only updatable field).
@@ -206,8 +203,7 @@ func TestAccComputeNetwork_bgpInterRegionCostAndUpdate(t *testing.T) {
206
203
Check : resource .ComposeTestCheckFunc (
207
204
testAccCheckComputeNetworkExists (
208
205
t , "google_compute_network.acc_network_bgp_inter_region_cost" , & network ),
209
- testAccCheckComputeNetworkHasBgpInterRegionCost (
210
- t , "google_compute_network.acc_network_bgp_inter_region_cost" , & network , "ADD_COST_TO_MED" ),
206
+ resource .TestCheckResourceAttr ("google_compute_network.acc_network_bgp_inter_region_cost" , "bgp_inter_region_cost" , "ADD_COST_TO_MED" ),
211
207
),
212
208
},
213
209
},
@@ -308,15 +304,15 @@ func TestAccComputeNetwork_default_bgp_best_path_selection_mode(t *testing.T) {
308
304
309
305
acctest .VcrTest (t , resource.TestCase {
310
306
PreCheck : func () { acctest .AccTestPreCheck (t ) },
311
- ProtoV5ProviderFactories : acctest .ProtoV5ProviderBetaFactories (t ),
307
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
312
308
CheckDestroy : testAccCheckComputeNetworkDestroyProducer (t ),
313
309
Steps : []resource.TestStep {
314
310
{
315
- Config : testAccComputeBetaNetwork_basic (networkName ),
311
+ Config : testAccComputeNetwork_basic (networkName ),
316
312
Check : resource .ComposeTestCheckFunc (
317
313
testAccCheckComputeNetworkExists (
318
314
t , "google_compute_network.bar" , & network ),
319
- testAccCheckComputeNetworkHasBgpBestPathSelectionMode ( t , "google_compute_network.bar" , & network , expectedBgpBestPathSelection ),
315
+ resource . TestCheckResourceAttr ( "google_compute_network.bar" , "bgp_best_path_selection_mode" , expectedBgpBestPathSelection ),
320
316
),
321
317
},
322
318
},
@@ -330,20 +326,19 @@ func TestAccComputeNetwork_default_bgp_always_compare_med(t *testing.T) {
330
326
suffixName := acctest .RandString (t , 10 )
331
327
networkName := fmt .Sprintf ("tf-test-bgp-always-compare-med-default-routes-%s" , suffixName )
332
328
333
- expectedBgpAlwaysCompareMed := false
329
+ expectedBgpAlwaysCompareMed := " false"
334
330
335
331
acctest .VcrTest (t , resource.TestCase {
336
332
PreCheck : func () { acctest .AccTestPreCheck (t ) },
337
- ProtoV5ProviderFactories : acctest .ProtoV5ProviderBetaFactories (t ),
333
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
338
334
CheckDestroy : testAccCheckComputeNetworkDestroyProducer (t ),
339
335
Steps : []resource.TestStep {
340
336
{
341
337
Config : testAccComputeNetwork_best_bgp_path_selection_mode (networkName , "STANDARD" ),
342
338
Check : resource .ComposeTestCheckFunc (
343
339
testAccCheckComputeNetworkExists (
344
340
t , "google_compute_network.acc_network_bgp_best_path_selection_mode" , & network ),
345
- testAccCheckComputeNetworkHasBgpAlwaysCompareMed (
346
- t , "google_compute_network.acc_network_bgp_best_path_selection_mode" , & network , expectedBgpAlwaysCompareMed ),
341
+ resource .TestCheckResourceAttr ("google_compute_network.acc_network_bgp_best_path_selection_mode" , "bgp_always_compare_med" , expectedBgpAlwaysCompareMed ),
347
342
),
348
343
},
349
344
},
@@ -555,93 +550,6 @@ func testAccCheckComputeNetworkHasRoutingMode(t *testing.T, n string, network *c
555
550
}
556
551
}
557
552
558
- func testAccCheckComputeNetworkHasBgpBestPathSelectionMode (t * testing.T , n string , network * compute.Network , bgpBestPathSelectionMode string ) resource.TestCheckFunc {
559
- return func (s * terraform.State ) error {
560
- config := acctest .GoogleProviderConfig (t )
561
-
562
- rs , ok := s .RootModule ().Resources [n ]
563
- if ! ok {
564
- return fmt .Errorf ("Not found: %s" , n )
565
- }
566
-
567
- if rs .Primary .Attributes ["bgp_always_compare_med" ] == "" {
568
- return fmt .Errorf ("BGP always compare med not found on resource" )
569
- }
570
-
571
- found , err := config .NewComputeClient (config .UserAgent ).Networks .Get (
572
- config .Project , network .Name ).Do ()
573
- if err != nil {
574
- return err
575
- }
576
-
577
- foundBgpBestPathSelectionMode := found .RoutingConfig .BgpBestPathSelectionMode
578
-
579
- if bgpBestPathSelectionMode != foundBgpBestPathSelectionMode {
580
- return fmt .Errorf ("Expected BGP always compare med %s to match actual BGP always compare med %s" , bgpBestPathSelectionMode , foundBgpBestPathSelectionMode )
581
- }
582
-
583
- return nil
584
- }
585
- }
586
-
587
- func testAccCheckComputeNetworkHasBgpAlwaysCompareMed (t * testing.T , n string , network * compute.Network , bgpAlwaysCompareMed bool ) resource.TestCheckFunc {
588
- return func (s * terraform.State ) error {
589
- config := acctest .GoogleProviderConfig (t )
590
-
591
- rs , ok := s .RootModule ().Resources [n ]
592
- if ! ok {
593
- return fmt .Errorf ("Not found: %s" , n )
594
- }
595
-
596
- if rs .Primary .Attributes ["bgp_always_compare_med" ] == "" {
597
- return fmt .Errorf ("BGP always compare med not found on resource" )
598
- }
599
-
600
- found , err := config .NewComputeClient (config .UserAgent ).Networks .Get (
601
- config .Project , network .Name ).Do ()
602
- if err != nil {
603
- return err
604
- }
605
-
606
- foundBgpAlwaysCompareMed := found .RoutingConfig .BgpAlwaysCompareMed
607
-
608
- if foundBgpAlwaysCompareMed != bgpAlwaysCompareMed {
609
- return fmt .Errorf ("Expected BGP always compare med %t to match actual BGP always compare med %t" , bgpAlwaysCompareMed , foundBgpAlwaysCompareMed )
610
- }
611
-
612
- return nil
613
- }
614
- }
615
-
616
- func testAccCheckComputeNetworkHasBgpInterRegionCost (t * testing.T , n string , network * compute.Network , bgpInterRegionCost string ) resource.TestCheckFunc {
617
- return func (s * terraform.State ) error {
618
- config := acctest .GoogleProviderConfig (t )
619
-
620
- rs , ok := s .RootModule ().Resources [n ]
621
- if ! ok {
622
- return fmt .Errorf ("Not found: %s" , n )
623
- }
624
-
625
- if rs .Primary .Attributes ["bgp_inter_region_cost" ] == "" {
626
- return fmt .Errorf ("BGP inter region cost not found on resource" )
627
- }
628
-
629
- found , err := config .NewComputeClient (config .UserAgent ).Networks .Get (
630
- config .Project , network .Name ).Do ()
631
- if err != nil {
632
- return err
633
- }
634
-
635
- foundBgpInterRegionCost := found .RoutingConfig .BgpInterRegionCost
636
-
637
- if foundBgpInterRegionCost != bgpInterRegionCost {
638
- return fmt .Errorf ("Expected BGP always compare med %s to match actual BGP always compare med %s" , bgpInterRegionCost , foundBgpInterRegionCost )
639
- }
640
-
641
- return nil
642
- }
643
- }
644
-
645
553
func testAccCheckComputeNetworkHasNetworkProfile (t * testing.T , n string , network * compute.Network , networkProfile string ) resource.TestCheckFunc {
646
554
return func (s * terraform.State ) error {
647
555
config := acctest .GoogleProviderConfig (t )
@@ -736,20 +644,9 @@ resource "google_compute_network" "acc_network_routing_mode" {
736
644
` , networkName , routingMode )
737
645
}
738
646
739
- func testAccComputeBetaNetwork_basic (networkName string ) string {
740
- return fmt .Sprintf (`
741
- resource "google_compute_network" "bar" {
742
- provider = google-beta
743
- name = "%s"
744
- auto_create_subnetworks = true
745
- }
746
- ` , networkName )
747
- }
748
-
749
647
func testAccComputeNetwork_best_bgp_path_selection_mode (networkName , bgpBestPathSelection string ) string {
750
648
return fmt .Sprintf (`
751
649
resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
752
- provider = google-beta
753
650
name = "%s"
754
651
routing_mode = "GLOBAL"
755
652
bgp_best_path_selection_mode = "%s"
@@ -760,7 +657,6 @@ resource "google_compute_network" "acc_network_bgp_best_path_selection_mode" {
760
657
func testAccComputeNetwork_bgp_always_compare_med (networkName string , bgpAlwaysCompareMed bool ) string {
761
658
return fmt .Sprintf (`
762
659
resource "google_compute_network" "acc_network_bgp_always_compare_med" {
763
- provider = google-beta
764
660
name = "%s"
765
661
routing_mode = "GLOBAL"
766
662
bgp_best_path_selection_mode = "STANDARD"
@@ -772,7 +668,6 @@ resource "google_compute_network" "acc_network_bgp_always_compare_med" {
772
668
func testAccComputeNetwork_bgp_inter_region_cost (networkName , bgpInterRegionCost string ) string {
773
669
return fmt .Sprintf (`
774
670
resource "google_compute_network" "acc_network_bgp_inter_region_cost" {
775
- provider = google-beta
776
671
name = "%s"
777
672
routing_mode = "GLOBAL"
778
673
bgp_best_path_selection_mode = "STANDARD"
0 commit comments