From ebcaf60470caa40a8e93c5b49d5de1c2feb30278 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 30 Jan 2024 15:42:06 -0800 Subject: [PATCH] Try to fix log bucket tests (#9878) (#17144) * Try to fix log bucket tests * folder and org level buckets can only be updated. [upstream:0b56797da146ac89f4427b072eb49f218b98a727] Signed-off-by: Modular Magician --- .changelog/9878.txt | 3 +++ .../resource_logging_bucket_config_test.go | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 .changelog/9878.txt diff --git a/.changelog/9878.txt b/.changelog/9878.txt new file mode 100644 index 00000000000..1cf6a8d2f25 --- /dev/null +++ b/.changelog/9878.txt @@ -0,0 +1,3 @@ +```release-note:bug + +``` \ No newline at end of file diff --git a/google/services/logging/resource_logging_bucket_config_test.go b/google/services/logging/resource_logging_bucket_config_test.go index 6ee35caff6d..7ab3673b0df 100644 --- a/google/services/logging/resource_logging_bucket_config_test.go +++ b/google/services/logging/resource_logging_bucket_config_test.go @@ -18,6 +18,7 @@ func TestAccLoggingBucketConfigFolder_basic(t *testing.T) { "random_suffix": acctest.RandString(t, 10), "folder_name": "tf-test-" + acctest.RandString(t, 10), "org_id": envvar.GetTestOrgFromEnv(t), + "bucket_id": "_Default", } acctest.VcrTest(t, resource.TestCase{ @@ -148,9 +149,9 @@ func TestAccLoggingBucketConfigProject_cmekSettings(t *testing.T) { "project_name": "tf-test-" + acctest.RandString(t, 10), "org_id": envvar.GetTestOrgFromEnv(t), "billing_account": envvar.GetTestBillingAccountFromEnv(t), + "bucket_id": "tf-test-bucket-" + acctest.RandString(t, 10), } - bucketId := fmt.Sprintf("tf-test-bucket-%s", acctest.RandString(t, 10)) keyRingName := fmt.Sprintf("tf-test-key-ring-%s", acctest.RandString(t, 10)) cryptoKeyName := fmt.Sprintf("tf-test-crypto-key-%s", acctest.RandString(t, 10)) cryptoKeyNameUpdate := fmt.Sprintf("tf-test-crypto-key-%s", acctest.RandString(t, 10)) @@ -160,7 +161,7 @@ func TestAccLoggingBucketConfigProject_cmekSettings(t *testing.T) { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), Steps: []resource.TestStep{ { - Config: testAccLoggingBucketConfigProject_cmekSettings(context, bucketId, keyRingName, cryptoKeyName, cryptoKeyNameUpdate), + Config: testAccLoggingBucketConfigProject_cmekSettings(context, keyRingName, cryptoKeyName, cryptoKeyNameUpdate), }, { ResourceName: "google_logging_project_bucket_config.basic", @@ -169,7 +170,7 @@ func TestAccLoggingBucketConfigProject_cmekSettings(t *testing.T) { ImportStateVerifyIgnore: []string{"project"}, }, { - Config: testAccLoggingBucketConfigProject_cmekSettingsUpdate(context, bucketId, keyRingName, cryptoKeyName, cryptoKeyNameUpdate), + Config: testAccLoggingBucketConfigProject_cmekSettingsUpdate(context, keyRingName, cryptoKeyName, cryptoKeyNameUpdate), }, { ResourceName: "google_logging_project_bucket_config.basic", @@ -188,6 +189,7 @@ func TestAccLoggingBucketConfigBillingAccount_basic(t *testing.T) { "random_suffix": acctest.RandString(t, 10), "billing_account_name": "billingAccounts/" + envvar.GetTestMasterBillingAccountFromEnv(t), "org_id": envvar.GetTestOrgFromEnv(t), + "bucket_id": "_Default", } acctest.VcrTest(t, resource.TestCase{ @@ -222,6 +224,7 @@ func TestAccLoggingBucketConfigOrganization_basic(t *testing.T) { context := map[string]interface{}{ "random_suffix": acctest.RandString(t, 10), "org_id": envvar.GetTestOrgFromEnv(t), + "bucket_id": "_Default", } acctest.VcrTest(t, resource.TestCase{ @@ -390,7 +393,7 @@ resource "google_kms_crypto_key_iam_member" "crypto_key_member2" { `, context), keyRingName, cryptoKeyName, cryptoKeyNameUpdate) } -func testAccLoggingBucketConfigProject_cmekSettings(context map[string]interface{}, bucketId, keyRingName, cryptoKeyName, cryptoKeyNameUpdate string) string { +func testAccLoggingBucketConfigProject_cmekSettings(context map[string]interface{}, keyRingName, cryptoKeyName, cryptoKeyNameUpdate string) string { return fmt.Sprintf(` %s @@ -407,10 +410,10 @@ resource "google_logging_project_bucket_config" "basic" { depends_on = [google_kms_crypto_key_iam_member.crypto_key_member1] } -`, testAccLoggingBucketConfigProject_preCmekSettings(context, keyRingName, cryptoKeyName, cryptoKeyNameUpdate), bucketId) +`, testAccLoggingBucketConfigProject_preCmekSettings(context, keyRingName, cryptoKeyName, cryptoKeyNameUpdate), context["bucket_id"]) } -func testAccLoggingBucketConfigProject_cmekSettingsUpdate(context map[string]interface{}, bucketId, keyRingName, cryptoKeyName, cryptoKeyNameUpdate string) string { +func testAccLoggingBucketConfigProject_cmekSettingsUpdate(context map[string]interface{}, keyRingName, cryptoKeyName, cryptoKeyNameUpdate string) string { return fmt.Sprintf(` %s @@ -427,7 +430,7 @@ resource "google_logging_project_bucket_config" "basic" { depends_on = [google_kms_crypto_key_iam_member.crypto_key_member2] } -`, testAccLoggingBucketConfigProject_preCmekSettings(context, keyRingName, cryptoKeyName, cryptoKeyNameUpdate), bucketId) +`, testAccLoggingBucketConfigProject_preCmekSettings(context, keyRingName, cryptoKeyName, cryptoKeyNameUpdate), context["bucket_id"]) } func TestAccLoggingBucketConfig_CreateBuckets_withCustomId(t *testing.T) { @@ -521,6 +524,7 @@ func TestAccLoggingBucketConfigOrganization_indexConfigs(t *testing.T) { context := map[string]interface{}{ "random_suffix": acctest.RandString(t, 10), "org_id": envvar.GetTestOrgFromEnv(t), + "bucket_id": "_Default", } acctest.VcrTest(t, resource.TestCase{