@@ -312,14 +312,61 @@ func TestAccSpannerInstance_basicWithAutoscalingUsingNodeConfigUpdate(t *testing
312
312
})
313
313
}
314
314
315
+ func TestAccSpannerInstance_basicWithAsymmetricAutoscalingConfigsUpdate (t * testing.T ) {
316
+ displayName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (t , 10 ))
317
+ acctest .VcrTest (t , resource.TestCase {
318
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
319
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
320
+ CheckDestroy : testAccCheckSpannerInstanceDestroyProducer (t ),
321
+ Steps : []resource.TestStep {
322
+ {
323
+ Config : testAccSpannerInstance_main (displayName ),
324
+ Check : resource .ComposeTestCheckFunc (
325
+ resource .TestCheckResourceAttrSet ("google_spanner_instance.main" , "state" ),
326
+ ),
327
+ },
328
+ {
329
+ ResourceName : "google_spanner_instance.main" ,
330
+ ImportState : true ,
331
+ ImportStateVerify : true ,
332
+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
333
+ },
334
+ {
335
+ Config : testAccSpannerInstance_basicWithAsymmetricAutoscalingConfigsUpdate (displayName , 1 , 10 ),
336
+ Check : resource .ComposeTestCheckFunc (
337
+ resource .TestCheckResourceAttrSet ("google_spanner_instance.main" , "state" ),
338
+ ),
339
+ },
340
+ {
341
+ ResourceName : "google_spanner_instance.main" ,
342
+ ImportState : true ,
343
+ ImportStateVerify : true ,
344
+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
345
+ },
346
+ {
347
+ Config : testAccSpannerInstance_basicWithAsymmetricAutoscalingConfigsUpdate (displayName , 3 , 5 ),
348
+ Check : resource .ComposeTestCheckFunc (
349
+ resource .TestCheckResourceAttrSet ("google_spanner_instance.main" , "state" ),
350
+ ),
351
+ },
352
+ {
353
+ ResourceName : "google_spanner_instance.main" ,
354
+ ImportState : true ,
355
+ ImportStateVerify : true ,
356
+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
357
+ },
358
+ },
359
+ })
360
+ }
361
+
315
362
func testAccSpannerInstance_basic (name string ) string {
316
363
return fmt .Sprintf (`
317
364
resource "google_spanner_instance" "basic" {
318
365
name = "%s"
319
366
config = "regional-us-central1"
320
367
display_name = "%s-dname"
321
368
num_nodes = 1
322
- edition = "ENTERPRISE"
369
+ edition = "ENTERPRISE"
323
370
}
324
371
` , name , name )
325
372
}
@@ -458,3 +505,63 @@ resource "google_spanner_instance" "basic" {
458
505
}
459
506
` , name , name , maxNodes , minNodes , cupUtilizationPercent , storageUtilizationPercent )
460
507
}
508
+
509
+ func testAccSpannerInstance_main (name string ) string {
510
+ return fmt .Sprintf (`
511
+ resource "google_spanner_instance" "main" {
512
+ name = "%s"
513
+ config = "nam-eur-asia3"
514
+ display_name = "%s"
515
+ num_nodes = 1
516
+ edition = "ENTERPRISE_PLUS"
517
+ }
518
+ ` , name , name )
519
+ }
520
+
521
+ func testAccSpannerInstance_basicWithAsymmetricAutoscalingConfigsUpdate (name string , minNodes , maxNodes int ) string {
522
+ return fmt .Sprintf (`
523
+ provider "google" {
524
+ alias = "user-project-override"
525
+ user_project_override = true
526
+ }
527
+
528
+ resource "google_spanner_instance" "main" {
529
+ provider = google.user-project-override
530
+ name = "%s"
531
+ config = "nam-eur-asia3"
532
+ display_name = "%s"
533
+ autoscaling_config {
534
+ autoscaling_limits {
535
+ max_nodes = 3
536
+ min_nodes = 1
537
+ }
538
+ autoscaling_targets {
539
+ high_priority_cpu_utilization_percent = 75
540
+ storage_utilization_percent = 90
541
+ }
542
+ asymmetric_autoscaling_options {
543
+ replica_selection {
544
+ location = "europe-west1"
545
+ }
546
+ overrides {
547
+ autoscaling_limits {
548
+ min_nodes = 3
549
+ max_nodes = 30
550
+ }
551
+ }
552
+ }
553
+ asymmetric_autoscaling_options {
554
+ replica_selection {
555
+ location = "asia-east1"
556
+ }
557
+ overrides {
558
+ autoscaling_limits {
559
+ min_nodes = %d
560
+ max_nodes = %d
561
+ }
562
+ }
563
+ }
564
+ }
565
+ edition = "ENTERPRISE_PLUS"
566
+ }` , name , name , minNodes , maxNodes )
567
+ }
0 commit comments