@@ -543,6 +543,45 @@ func TestAccSpannerInstance_freeInstanceBasicUpdate(t *testing.T) {
543543 })
544544}
545545
546+ func TestAccSpannerInstance_autoscalingWithTotalCPUUtilizationPercent (t * testing.T ) {
547+ t .Parallel ()
548+
549+ displayName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (t , 10 ))
550+ acctest .VcrTest (t , resource.TestCase {
551+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
552+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
553+ CheckDestroy : testAccCheckSpannerInstanceDestroyProducer (t ),
554+ Steps : []resource.TestStep {
555+ {
556+ Config : testAccSpannerInstance_autoscalingWithTotalCPUUtilizationPercent (displayName , 2000 , 4000 , 65 , 85 , 95 ),
557+ Check : resource .ComposeTestCheckFunc (
558+ resource .TestCheckResourceAttrSet ("google_spanner_instance.test" , "state" ),
559+ resource .TestCheckResourceAttr ("google_spanner_instance.test" , "autoscaling_config.0.autoscaling_targets.0.total_cpu_utilization_percent" , "85" ),
560+ ),
561+ },
562+ {
563+ ResourceName : "google_spanner_instance.test" ,
564+ ImportState : true ,
565+ ImportStateVerify : true ,
566+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
567+ },
568+ {
569+ Config : testAccSpannerInstance_autoscalingWithTotalCPUUtilizationPercent (displayName , 3000 , 5000 , 75 , 90 , 95 ),
570+ Check : resource .ComposeTestCheckFunc (
571+ resource .TestCheckResourceAttrSet ("google_spanner_instance.test" , "state" ),
572+ resource .TestCheckResourceAttr ("google_spanner_instance.test" , "autoscaling_config.0.autoscaling_targets.0.total_cpu_utilization_percent" , "90" ),
573+ ),
574+ },
575+ {
576+ ResourceName : "google_spanner_instance.test" ,
577+ ImportState : true ,
578+ ImportStateVerify : true ,
579+ ImportStateVerifyIgnore : []string {"labels" , "terraform_labels" },
580+ },
581+ },
582+ })
583+ }
584+
546585func testAccSpannerInstance_basic (name string ) string {
547586 return fmt .Sprintf (`
548587resource "google_spanner_instance" "basic" {
@@ -701,6 +740,7 @@ resource "google_spanner_instance" "basic" {
701740 }
702741 autoscaling_targets {
703742 high_priority_cpu_utilization_percent = %v
743+ total_cpu_utilization_percent = 85
704744 storage_utilization_percent = %v
705745 }
706746 }
@@ -905,3 +945,25 @@ resource "google_spanner_instance" "main" {
905945}
906946` , context )
907947}
948+
949+ func testAccSpannerInstance_autoscalingWithTotalCPUUtilizationPercent (name string , minProcessingUnits , maxProcessingUnits , highPriorityCPU , totalCPU , storageUtilization int ) string {
950+ return fmt .Sprintf (`
951+ resource "google_spanner_instance" "test" {
952+ name = "%s"
953+ config = "regional-us-central1"
954+ display_name = "%s"
955+ autoscaling_config {
956+ autoscaling_limits {
957+ max_processing_units = %d
958+ min_processing_units = %d
959+ }
960+ autoscaling_targets {
961+ high_priority_cpu_utilization_percent = %d
962+ total_cpu_utilization_percent = %d
963+ storage_utilization_percent = %d
964+ }
965+ }
966+ edition = "ENTERPRISE"
967+ }
968+ ` , name , name , maxProcessingUnits , minProcessingUnits , highPriorityCPU , totalCPU , storageUtilization )
969+ }
0 commit comments