Skip to content

Commit

Permalink
add acceptance test with processing units as config
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Oct 26, 2023
1 parent 741ae59 commit cc0755b
Showing 1 changed file with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestAccSpannerInstance_virtualUpdate(t *testing.T) {
})
}

func TestAccSpannerInstance_basicWithAutoscaler(t *testing.T) {
func TestAccSpannerInstance_basicWithAutoscalingUsingNodeConfig(t *testing.T) {
// Randomness
acctest.SkipIfVcr(t)
t.Parallel()
Expand All @@ -154,7 +154,33 @@ func TestAccSpannerInstance_basicWithAutoscaler(t *testing.T) {
CheckDestroy: testAccCheckSpannerInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccSpannerInstance_basicWithAutoscalerConfig(displayName),
Config: testAccSpannerInstance_basicWithAutoscalerConfigUsingNodeAsConfigs(displayName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("google_spanner_instance.basic", "state"),
),
},
{
ResourceName: "google_spanner_instance.basic",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccSpannerInstance_basicWithAutoscalingUsingProcessingUnitConfig(t *testing.T) {
// Randomness
acctest.SkipIfVcr(t)
t.Parallel()

displayName := fmt.Sprintf("spanner-test-%s-dname", acctest.RandString(t, 10))
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckSpannerInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccSpannerInstance_basicWithAutoscalerConfigUsingProcessingUnitsAsConfigs(displayName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("google_spanner_instance.basic", "state"),
),
Expand Down Expand Up @@ -230,7 +256,7 @@ resource "google_spanner_instance" "basic" {
`, name, name, virtual)
}

func testAccSpannerInstance_basicWithAutoscalerConfig(name string) string {
func testAccSpannerInstance_basicWithAutoscalerConfigUsingNodeAsConfigs(name string) string {
return fmt.Sprintf(`
resource "google_spanner_instance" "basic" {
name = "%s"
Expand All @@ -254,3 +280,28 @@ resource "google_spanner_instance" "basic" {
}
`, name, name)
}

func testAccSpannerInstance_basicWithAutoscalerConfigUsingProcessingUnitsAsConfigs(name string) string {
return fmt.Sprintf(`
resource "google_spanner_instance" "basic" {
name = "%s"
config = "regional-us-central1"
display_name = "%s-dname"
num_nodes = 1
autoscaling_config {
autoscaling_limits {
max_limit {
max_processing_units = 2000
}
min_limit {
min_processing_units = 1000
}
}
autoscaling_targets {
high_priority_cpu_utilization_percent = 65
storage_utilization_percent = 95
}
}
}
`, name, name)
}

0 comments on commit cc0755b

Please sign in to comment.