From 1c5d2d1aa1758c6c112e4cb0cd979e23778c230d Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Tue, 10 Nov 2020 19:21:33 -0800 Subject: [PATCH 1/4] Add to create call --- products/bigtable/api.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/products/bigtable/api.yaml b/products/bigtable/api.yaml index ce094e525df9..23c8e4c060fd 100644 --- a/products/bigtable/api.yaml +++ b/products/bigtable/api.yaml @@ -29,13 +29,16 @@ objects: name: 'AppProfile' kind: 'bigtable#appProfile' base_url: projects/{{project}}/instances/{{instance}}/appProfiles?appProfileId={{app_profile_id}} - update_url: projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}?ignoreWarnings={{ignore_warnings}} + create_url: projects/{{project}}/instances/{{instance}}/appProfiles?appProfileId={{app_profile_id}}&ignoreWarnings={{ignore_warnings}} delete_url: projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}?ignoreWarnings={{ignore_warnings}} + update_url: projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}?ignoreWarnings={{ignore_warnings}} update_verb: :PATCH update_mask: true self_link: 'projects/{{project}}/instances/{{instance}}/appProfiles/{{app_profile_id}}' description: | App profile is a configuration object describing how Cloud Bigtable should treat traffic from a particular end user application. + references: !ruby/object:Api::Resource::ReferenceLinks + api: 'https://cloud.google.com/bigtable/docs/reference/admin/rest/v2/projects.instances.appProfiles' parameters: - !ruby/object:Api::Type::String name: 'appProfileId' From 74ac729fbda202a1d3ab0c8d137921d486c26d41 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Wed, 11 Nov 2020 20:22:54 -0800 Subject: [PATCH 2/4] add testcase to valid scenario is workign appropriately --- .../resource_bigtable_app_profile_test.go | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/third_party/terraform/tests/resource_bigtable_app_profile_test.go b/third_party/terraform/tests/resource_bigtable_app_profile_test.go index a98a9d2ee7fb..e4624520bcaa 100644 --- a/third_party/terraform/tests/resource_bigtable_app_profile_test.go +++ b/third_party/terraform/tests/resource_bigtable_app_profile_test.go @@ -41,6 +41,31 @@ func TestAccBigtableAppProfile_update(t *testing.T) { }) } +func TestAccBigtableAppProfile_ignoreWarnings(t *testing.T) { + // bigtable instance does not use the shared HTTP client, this test creates an instance + skipIfVcr(t) + t.Parallel() + + instanceName := fmt.Sprintf("tf-test-%s", randString(t, 10)) + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckBigtableAppProfileDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccBigtableAppProfile_update1(instanceName), + }, + { + ResourceName: "google_bigtable_app_profile.ap", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"ignore_warnings"}, + }, + }, + }) +} + func testAccBigtableAppProfile_update1(instanceName string) string { return fmt.Sprintf(` resource "google_bigtable_instance" "instance" { @@ -97,3 +122,68 @@ resource "google_bigtable_app_profile" "ap" { } `, instanceName, instanceName, instanceName) } + +func testAccBigtableAppProfile_warningsProduced(instanceName string) string { + return fmt.Sprintf(` + resource "google_bigtable_instance" "instance" { + name = "%s" + instance_type = "PRODUCTION" + cluster { + cluster_id = "%s1" + zone = "us-central1-b" + num_nodes = 3 + } + + cluster { + cluster_id = "%s2" + zone = "us-west1-a" + num_nodes = 3 + } + + cluster { + cluster_id = "%s3" + zone = "us-west1-b" + num_nodes = 3 + } + + deletion_protection = false + } + + resource "google_bigtable_app_profile" "gae-profile1" { + instance = google_bigtable_instance.instance.id + app_profile_id = "bigtableinstance-sample1" + + single_cluster_routing { + cluster_id = "%s1" + allow_transactional_writes = true + } + + ignore_warnings = true + } + + resource "google_bigtable_app_profile" "gae-profile2" { + instance = google_bigtable_instance.instance.id + app_profile_id = "bigtableinstance-sample2" + + single_cluster_routing { + cluster_id = "%s2" + allow_transactional_writes = true + } + + ignore_warnings = true + } + + resource "google_bigtable_app_profile" "gae-profile3" { + instance = google_bigtable_instance.instance.id + app_profile_id = "bigtableinstance-sample3" + + single_cluster_routing { + cluster_id = "%s3" + allow_transactional_writes = true + } + + ignore_warnings = true + } +} +`, instanceName, instanceName, instanceName, instanceName, instanceName, instanceName, instanceName) +} From 1ad82d44a4c19faa048ed8754af46aa1b342636c Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Thu, 12 Nov 2020 15:45:25 -0800 Subject: [PATCH 3/4] use test config --- .../terraform/tests/resource_bigtable_app_profile_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/terraform/tests/resource_bigtable_app_profile_test.go b/third_party/terraform/tests/resource_bigtable_app_profile_test.go index e4624520bcaa..8b50c3b40b58 100644 --- a/third_party/terraform/tests/resource_bigtable_app_profile_test.go +++ b/third_party/terraform/tests/resource_bigtable_app_profile_test.go @@ -54,7 +54,7 @@ func TestAccBigtableAppProfile_ignoreWarnings(t *testing.T) { CheckDestroy: testAccCheckBigtableAppProfileDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccBigtableAppProfile_update1(instanceName), + Config: testAccBigtableAppProfile_warningsProduced(instanceName), }, { ResourceName: "google_bigtable_app_profile.ap", From 854815ce90cbd80492926cabf6980d25024ffa93 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Thu, 12 Nov 2020 15:57:19 -0800 Subject: [PATCH 4/4] update testcase with correct import name --- .../terraform/tests/resource_bigtable_app_profile_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/third_party/terraform/tests/resource_bigtable_app_profile_test.go b/third_party/terraform/tests/resource_bigtable_app_profile_test.go index 8b50c3b40b58..bd53ca861144 100644 --- a/third_party/terraform/tests/resource_bigtable_app_profile_test.go +++ b/third_party/terraform/tests/resource_bigtable_app_profile_test.go @@ -57,7 +57,7 @@ func TestAccBigtableAppProfile_ignoreWarnings(t *testing.T) { Config: testAccBigtableAppProfile_warningsProduced(instanceName), }, { - ResourceName: "google_bigtable_app_profile.ap", + ResourceName: "google_bigtable_app_profile.gae-profile1", ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{"ignore_warnings"}, @@ -184,6 +184,5 @@ func testAccBigtableAppProfile_warningsProduced(instanceName string) string { ignore_warnings = true } -} `, instanceName, instanceName, instanceName, instanceName, instanceName, instanceName, instanceName) }