Skip to content

Commit

Permalink
Try to fix log bucket tests (#9878) (#17144)
Browse files Browse the repository at this point in the history
* Try to fix log bucket tests

* folder and org level buckets can only be updated.

[upstream:0b56797da146ac89f4427b072eb49f218b98a727]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jan 30, 2024
1 parent b0eb4ed commit ebcaf60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/9878.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug

```
18 changes: 11 additions & 7 deletions google/services/logging/resource_logging_bucket_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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))
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit ebcaf60

Please sign in to comment.