diff --git a/mmv1/third_party/terraform/services/spanner/data_source_spanner_instance_test.go b/mmv1/third_party/terraform/services/spanner/data_source_spanner_instance_test.go index f6ae6c175bae..04b86a377392 100644 --- a/mmv1/third_party/terraform/services/spanner/data_source_spanner_instance_test.go +++ b/mmv1/third_party/terraform/services/spanner/data_source_spanner_instance_test.go @@ -8,8 +8,6 @@ import ( ) func TestAccDataSourceSpannerInstance_basic(t *testing.T) { - // Randomness from spanner instance - acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -34,16 +32,18 @@ func TestAccDataSourceSpannerInstance_basic(t *testing.T) { func testAccDataSourceSpannerInstanceBasic(context map[string]interface{}) string { return acctest.Nprintf(` resource "google_spanner_instance" "bar" { - config = "regional-us-central1" - display_name = "Test Spanner Instance" - num_nodes = 2 - labels = { - "foo" = "bar" - } + name = "tf-test-%{random_suffix}" + display_name = "Test Spanner Instance" + config = "regional-us-central1" + + processing_units = 100 + labels = { + "foo" = "bar" + } } data "google_spanner_instance" "foo" { - name = google_spanner_instance.bar.name + name = google_spanner_instance.bar.name } `, context) } diff --git a/mmv1/third_party/terraform/services/spanner/resource_spanner_database_test.go.tmpl b/mmv1/third_party/terraform/services/spanner/resource_spanner_database_test.go.tmpl index c3b5ef0862b6..c5ba7eecf981 100644 --- a/mmv1/third_party/terraform/services/spanner/resource_spanner_database_test.go.tmpl +++ b/mmv1/third_party/terraform/services/spanner/resource_spanner_database_test.go.tmpl @@ -289,8 +289,8 @@ func TestAccSpannerDatabase_versionRetentionPeriod(t *testing.T) { // Test that when the above config is reapplied: // - changes the value (reverts to set value of `version_retention_period`, 2h) // - is stable; no further conflict - Config: testAccSpannerDatabase_versionRetentionPeriodUpdate3(instanceName, databaseName), //same as previous step - ExpectNonEmptyPlan: false, // is stable + Config: testAccSpannerDatabase_versionRetentionPeriodUpdate3(instanceName, databaseName), // same as previous step + ExpectNonEmptyPlan: false, // is stable Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("google_spanner_database.basic", "state"), resource.TestCheckResourceAttr("google_spanner_database.basic", "version_retention_period", "2h"), @@ -465,7 +465,6 @@ resource "google_spanner_database" "basic" { } func TestAccSpannerDatabase_deletionProtection(t *testing.T) { - acctest.SkipIfVcr(t) t.Parallel() context := map[string]interface{}{ @@ -501,8 +500,9 @@ func TestAccSpannerDatabase_deletionProtection(t *testing.T) { func testAccSpannerDatabase_deletionProtection(context map[string]interface{}) string { return acctest.Nprintf(` resource "google_spanner_instance" "main" { - config = "regional-europe-west1" + name = "tf-test-%{random_suffix}" display_name = "main-instance" + config = "regional-europe-west1" num_nodes = 1 } diff --git a/mmv1/third_party/terraform/services/spanner/resource_spanner_instance_test.go b/mmv1/third_party/terraform/services/spanner/resource_spanner_instance_test.go index 59ed840dc7c2..6643921dd708 100644 --- a/mmv1/third_party/terraform/services/spanner/resource_spanner_instance_test.go +++ b/mmv1/third_party/terraform/services/spanner/resource_spanner_instance_test.go @@ -15,7 +15,7 @@ import ( func TestAccSpannerInstance_basic(t *testing.T) { t.Parallel() - idName := fmt.Sprintf("spanner-test-%s", acctest.RandString(t, 10)) + idName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), @@ -39,7 +39,7 @@ func TestAccSpannerInstance_basic(t *testing.T) { func TestAccSpannerInstance_noNodeCountSpecified(t *testing.T) { t.Parallel() - idName := fmt.Sprintf("spanner-test-%s", acctest.RandString(t, 10)) + idName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), @@ -54,11 +54,12 @@ func TestAccSpannerInstance_noNodeCountSpecified(t *testing.T) { } func TestAccSpannerInstance_basicWithAutogenName(t *testing.T) { - // Randomness + // Since we're testing the autogenerated name specifically here, we can't use VCR. This shouldn't be copy / + // pasted to other configs, though. acctest.SkipIfVcr(t) t.Parallel() - displayName := fmt.Sprintf("spanner-test-%s-dname", acctest.RandString(t, 10)) + displayName := fmt.Sprintf("tf-test-%s-dname", acctest.RandString(t, 10)) acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), @@ -80,19 +81,21 @@ func TestAccSpannerInstance_basicWithAutogenName(t *testing.T) { } func TestAccSpannerInstance_update(t *testing.T) { - // Randomness - acctest.SkipIfVcr(t) t.Parallel() - dName1 := fmt.Sprintf("spanner-dname1-%s", acctest.RandString(t, 10)) - dName2 := fmt.Sprintf("spanner-dname2-%s", acctest.RandString(t, 10)) + // Update display name, but keep real name consistent, as it cannot be + // updated after creation. + name := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) + dName1 := fmt.Sprintf("tf-test-dname1-%s", acctest.RandString(t, 10)) + dName2 := fmt.Sprintf("tf-test-dname2-%s", 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_update(dName1, 1, false), + Config: testAccSpannerInstance_update(name, dName1, 1, false), }, { ResourceName: "google_spanner_instance.updater", @@ -101,7 +104,7 @@ func TestAccSpannerInstance_update(t *testing.T) { ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, }, { - Config: testAccSpannerInstance_update(dName2, 2, true), + Config: testAccSpannerInstance_update(name, dName2, 2, true), }, { ResourceName: "google_spanner_instance.updater", @@ -114,11 +117,9 @@ func TestAccSpannerInstance_update(t *testing.T) { } func TestAccSpannerInstance_virtualUpdate(t *testing.T) { - // Randomness - acctest.SkipIfVcr(t) t.Parallel() - dName := fmt.Sprintf("spanner-dname1-%s", acctest.RandString(t, 10)) + dName := fmt.Sprintf("tf-test-dname1-%s", acctest.RandString(t, 10)) acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), @@ -145,7 +146,7 @@ func TestAccSpannerInstance_virtualUpdate(t *testing.T) { func TestAccSpannerInstance_basicWithAutoscalingUsingProcessingUnitConfig(t *testing.T) { t.Parallel() - displayName := fmt.Sprintf("spanner-test-%s-dname", acctest.RandString(t, 10)) + displayName := fmt.Sprintf("tf-test-%s-dname", acctest.RandString(t, 10)) acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), @@ -230,7 +231,7 @@ func TestAccSpannerInstance_basicWithAutoscalingUsingProcessingUnitConfigUpdate( func TestAccSpannerInstance_basicWithAutoscalingUsingNodeConfig(t *testing.T) { t.Parallel() - displayName := fmt.Sprintf("spanner-test-%s-dname", acctest.RandString(t, 10)) + displayName := fmt.Sprintf("tf-test-%s-dname", acctest.RandString(t, 10)) acctest.VcrTest(t, resource.TestCase{ PreCheck: func() { acctest.AccTestPreCheck(t) }, ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), @@ -365,8 +366,9 @@ resource "google_spanner_instance" "basic" { name = "%s" config = "regional-us-central1" display_name = "%s-dname" - num_nodes = 1 - edition = "ENTERPRISE" + + processing_units = 100 + edition = "ENTERPRISE" default_backup_schedule_type = "NONE" } `, name, name) @@ -387,12 +389,13 @@ func testAccSpannerInstance_basicWithAutogenName(name string) string { resource "google_spanner_instance" "basic" { config = "regional-us-central1" display_name = "%s" - num_nodes = 1 + + processing_units = 100 } `, name) } -func testAccSpannerInstance_update(name string, nodes int, addLabel bool) string { +func testAccSpannerInstance_update(name, dname string, nodes int, addLabel bool) string { extraLabel := "" if addLabel { extraLabel = "\"key2\" = \"value2\"" @@ -400,6 +403,7 @@ func testAccSpannerInstance_update(name string, nodes int, addLabel bool) string return fmt.Sprintf(` resource "google_spanner_instance" "updater" { config = "regional-us-central1" + name = "%s" display_name = "%s" num_nodes = %d @@ -408,15 +412,16 @@ resource "google_spanner_instance" "updater" { %s } } -`, name, nodes, extraLabel) +`, name, dname, nodes, extraLabel) } func testAccSpannerInstance_virtualUpdate(name, virtual string) string { return fmt.Sprintf(` resource "google_spanner_instance" "basic" { name = "%s" - config = "regional-us-central1" display_name = "%s" + config = "regional-us-central1" + processing_units = 100 force_destroy = "%s" }