From 342db79fcc739acab119fb5f1c2651ee81b8da11 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Mon, 16 Dec 2024 14:56:45 +0000 Subject: [PATCH] Fix Failing test TestAccSecurityCenterV2ProjectBigQueryExportConfig_basic + others (#12334) [upstream:654663666d97447080ded5cd3e5cb3b62e2dfffc] Signed-off-by: Modular Magician --- .changelog/12334.txt | 3 ++ ...ganization_big_query_export_config_test.go | 24 ++++++++++++-- ...cc_project_big_query_export_config_test.go | 28 +++++++++++++++-- ...ganization_big_query_export_config_test.go | 15 ++++++--- ...anization_big_query_exports_config_test.go | 15 ++++++--- ...v2_project_big_query_export_config_test.go | 31 +++++++++++++++++-- 6 files changed, 99 insertions(+), 17 deletions(-) create mode 100644 .changelog/12334.txt diff --git a/.changelog/12334.txt b/.changelog/12334.txt new file mode 100644 index 00000000000..2e9cfb04c99 --- /dev/null +++ b/.changelog/12334.txt @@ -0,0 +1,3 @@ +```release-note:none +securitycenterv2: fixed flaky test TestAccSecurityCenterV2ProjectBigQueryExportConfig_basic +``` \ No newline at end of file diff --git a/google/services/securitycenter/resource_scc_organization_big_query_export_config_test.go b/google/services/securitycenter/resource_scc_organization_big_query_export_config_test.go index d6d5d698e3b..c7fc7eeed74 100644 --- a/google/services/securitycenter/resource_scc_organization_big_query_export_config_test.go +++ b/google/services/securitycenter/resource_scc_organization_big_query_export_config_test.go @@ -15,13 +15,13 @@ func TestAccSecurityCenterOrganizationBigQueryExportConfig_basic(t *testing.T) { t.Parallel() randomSuffix := acctest.RandString(t, 10) - dataset_id := "tf_test_" + randomSuffix + datasetID := "tf_test_" + randomSuffix orgID := envvar.GetTestOrgFromEnv(t) context := map[string]interface{}{ "org_id": orgID, "random_suffix": randomSuffix, - "dataset_id": dataset_id, + "dataset_id": datasetID, "big_query_export_id": "tf-test-export-" + randomSuffix, "name": fmt.Sprintf("organizations/%s/bigQueryExports/%s", orgID, "tf-test-export-"+randomSuffix), @@ -67,6 +67,7 @@ resource "google_bigquery_dataset" "default" { location = "US" default_table_expiration_ms = 3600000 default_partition_expiration_ms = null + delete_contents_on_destroy = true labels = { env = "default" @@ -79,7 +80,7 @@ resource "google_bigquery_dataset" "default" { resource "time_sleep" "wait_1_minute" { depends_on = [google_bigquery_dataset.default] - create_duration = "3m" + create_duration = "6m" } resource "google_scc_organization_scc_big_query_export" "default" { @@ -92,6 +93,10 @@ resource "google_scc_organization_scc_big_query_export" "default" { depends_on = [time_sleep.wait_1_minute] } +resource "time_sleep" "wait_for_cleanup" { + create_duration = "6m" + depends_on = [google_scc_organization_scc_big_query_export.default] +} `, context) } @@ -105,6 +110,7 @@ resource "google_bigquery_dataset" "default" { location = "US" default_table_expiration_ms = 3600000 default_partition_expiration_ms = null + delete_contents_on_destroy = true labels = { env = "default" @@ -115,12 +121,24 @@ resource "google_bigquery_dataset" "default" { } } +resource "time_sleep" "wait_1_minute" { + depends_on = [google_bigquery_dataset.default] + create_duration = "6m" +} + resource "google_scc_organization_scc_big_query_export" "default" { big_query_export_id = "%{big_query_export_id}" organization = "%{org_id}" dataset = google_bigquery_dataset.default.id description = "SCC Findings Big Query Export Update" filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" + + depends_on = [time_sleep.wait_1_minute] +} + +resource "time_sleep" "wait_for_cleanup" { + create_duration = "6m" + depends_on = [google_scc_organization_scc_big_query_export.default] } `, context) } diff --git a/google/services/securitycenter/resource_scc_project_big_query_export_config_test.go b/google/services/securitycenter/resource_scc_project_big_query_export_config_test.go index 719780e4f93..2ddbd16a91b 100644 --- a/google/services/securitycenter/resource_scc_project_big_query_export_config_test.go +++ b/google/services/securitycenter/resource_scc_project_big_query_export_config_test.go @@ -14,13 +14,13 @@ func TestAccSecurityCenterProjectBigQueryExportConfig_basic(t *testing.T) { t.Parallel() randomSuffix := acctest.RandString(t, 10) - dataset_id := "tf_test_" + randomSuffix + datasetID := "tf_test_" + randomSuffix orgID := envvar.GetTestOrgFromEnv(t) context := map[string]interface{}{ "org_id": orgID, "random_suffix": randomSuffix, - "dataset_id": dataset_id, + "dataset_id": datasetID, "big_query_export_id": "tf-test-export-" + randomSuffix, "project": envvar.GetTestProjectFromEnv(), } @@ -65,6 +65,7 @@ resource "google_bigquery_dataset" "default" { location = "US" default_table_expiration_ms = 3600000 default_partition_expiration_ms = null + delete_contents_on_destroy = true labels = { env = "default" @@ -77,7 +78,7 @@ resource "google_bigquery_dataset" "default" { resource "time_sleep" "wait_x_minutes" { depends_on = [google_bigquery_dataset.default] - create_duration = "3m" + create_duration = "6m" # need to wait for destruction due to # 'still in use' error from api destroy_duration = "1m" @@ -93,6 +94,11 @@ resource "google_scc_project_scc_big_query_export" "default" { depends_on = [time_sleep.wait_x_minutes] } +resource "time_sleep" "wait_for_cleanup" { + create_duration = "6m" + depends_on = [google_scc_project_scc_big_query_export.default] +} + `, context) } @@ -106,6 +112,7 @@ resource "google_bigquery_dataset" "default" { location = "US" default_table_expiration_ms = 3600000 default_partition_expiration_ms = null + delete_contents_on_destroy = true labels = { env = "default" @@ -116,12 +123,27 @@ resource "google_bigquery_dataset" "default" { } } +resource "time_sleep" "wait_x_minutes" { + depends_on = [google_bigquery_dataset.default] + create_duration = "6m" + # need to wait for destruction due to + # 'still in use' error from api + destroy_duration = "1m" +} + resource "google_scc_project_scc_big_query_export" "default" { big_query_export_id = "%{big_query_export_id}" project = "%{project}" dataset = google_bigquery_dataset.default.id description = "SCC Findings Big Query Export Update" filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" + + depends_on = [time_sleep.wait_x_minutes] +} + +resource "time_sleep" "wait_for_cleanup" { + create_duration = "6m" + depends_on = [google_scc_project_scc_big_query_export.default] } `, context) diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_big_query_export_config_test.go b/google/services/securitycenterv2/resource_scc_v2_organization_big_query_export_config_test.go index e34da113459..870214a81fc 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_big_query_export_config_test.go +++ b/google/services/securitycenterv2/resource_scc_v2_organization_big_query_export_config_test.go @@ -15,13 +15,13 @@ func TestAccSecurityCenterV2OrganizationBigQueryExportConfig_basic(t *testing.T) t.Parallel() randomSuffix := acctest.RandString(t, 10) - dataset_id := "tf_test_" + randomSuffix + datasetID := "tf_test_" + randomSuffix orgID := envvar.GetTestOrgFromEnv(t) context := map[string]interface{}{ "org_id": orgID, "random_suffix": randomSuffix, - "dataset_id": dataset_id, + "dataset_id": datasetID, "big_query_export_id": "tf-test-export-" + randomSuffix, "name": fmt.Sprintf("organizations/%s/locations/global/bigQueryExports/%s", orgID, "tf-test-export-"+randomSuffix), @@ -96,7 +96,7 @@ resource "google_scc_v2_organization_scc_big_query_export" "default" { } resource "time_sleep" "wait_for_cleanup" { - create_duration = "3m" + create_duration = "6m" depends_on = [google_scc_v2_organization_scc_big_query_export.default] } `, context) @@ -123,6 +123,11 @@ resource "google_bigquery_dataset" "default" { } } +resource "time_sleep" "wait_1_minute" { + depends_on = [google_bigquery_dataset.default] + create_duration = "6m" +} + resource "google_scc_v2_organization_scc_big_query_export" "default" { name = "%{name}" big_query_export_id = "%{big_query_export_id}" @@ -131,10 +136,12 @@ resource "google_scc_v2_organization_scc_big_query_export" "default" { location = "global" description = "SCC Findings Big Query Export Update" filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" + + depends_on = [time_sleep.wait_1_minute] } resource "time_sleep" "wait_for_cleanup" { - create_duration = "3m" + create_duration = "6m" depends_on = [google_scc_v2_organization_scc_big_query_export.default] } `, context) diff --git a/google/services/securitycenterv2/resource_scc_v2_organization_big_query_exports_config_test.go b/google/services/securitycenterv2/resource_scc_v2_organization_big_query_exports_config_test.go index 514e109b881..a43fdd34249 100644 --- a/google/services/securitycenterv2/resource_scc_v2_organization_big_query_exports_config_test.go +++ b/google/services/securitycenterv2/resource_scc_v2_organization_big_query_exports_config_test.go @@ -15,13 +15,13 @@ func TestAccSecurityCenterV2OrganizationBigQueryExportsConfig_basic(t *testing.T t.Parallel() randomSuffix := acctest.RandString(t, 10) - dataset_id := "tf_test_" + randomSuffix + datasetID := "tf_test_" + randomSuffix orgID := envvar.GetTestOrgFromEnv(t) context := map[string]interface{}{ "org_id": orgID, "random_suffix": randomSuffix, - "dataset_id": dataset_id, + "dataset_id": datasetID, "big_query_export_id": "tf-test-export-" + randomSuffix, "name": fmt.Sprintf("organizations/%s/locations/global/bigQueryExports/%s", orgID, "tf-test-export-"+randomSuffix), @@ -96,7 +96,7 @@ resource "google_scc_v2_organization_scc_big_query_exports" "default" { } resource "time_sleep" "wait_for_cleanup" { - create_duration = "3m" + create_duration = "6m" depends_on = [google_scc_v2_organization_scc_big_query_exports.default] } `, context) @@ -123,6 +123,11 @@ resource "google_bigquery_dataset" "default" { } } +resource "time_sleep" "wait_1_minute" { + depends_on = [google_bigquery_dataset.default] + create_duration = "6m" +} + resource "google_scc_v2_organization_scc_big_query_exports" "default" { name = "%{name}" big_query_export_id = "%{big_query_export_id}" @@ -131,10 +136,12 @@ resource "google_scc_v2_organization_scc_big_query_exports" "default" { location = "global" description = "SCC Findings Big Query Export Update" filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" + + depends_on = [time_sleep.wait_1_minute] } resource "time_sleep" "wait_for_cleanup" { - create_duration = "3m" + create_duration = "6m" depends_on = [google_scc_v2_organization_scc_big_query_exports.default] } `, context) diff --git a/google/services/securitycenterv2/resource_scc_v2_project_big_query_export_config_test.go b/google/services/securitycenterv2/resource_scc_v2_project_big_query_export_config_test.go index bb1fdc4407f..5a53616ec64 100644 --- a/google/services/securitycenterv2/resource_scc_v2_project_big_query_export_config_test.go +++ b/google/services/securitycenterv2/resource_scc_v2_project_big_query_export_config_test.go @@ -15,13 +15,13 @@ func TestAccSecurityCenterV2ProjectBigQueryExportConfig_basic(t *testing.T) { t.Parallel() randomSuffix := acctest.RandString(t, 10) - dataset_id := "tf_test_" + randomSuffix + datasetID := "tf_test_" + randomSuffix orgID := envvar.GetTestOrgFromEnv(t) context := map[string]interface{}{ "org_id": orgID, "random_suffix": randomSuffix, - "dataset_id": dataset_id, + "dataset_id": datasetID, "big_query_export_id": "tf-test-export-" + randomSuffix, "name": fmt.Sprintf("projects/%s/locations/global/bigQueryExports/%s", envvar.GetTestProjectFromEnv(), "tf-test-export-"+randomSuffix), @@ -68,6 +68,7 @@ resource "google_bigquery_dataset" "default" { location = "US" default_table_expiration_ms = 3600000 default_partition_expiration_ms = null + delete_contents_on_destroy = true labels = { env = "default" @@ -80,7 +81,10 @@ resource "google_bigquery_dataset" "default" { resource "time_sleep" "wait_1_minute" { depends_on = [google_bigquery_dataset.default] - create_duration = "3m" + create_duration = "6m" + # need to wait for destruction due to + # 'still in use' error from api + destroy_duration = "1m" } resource "google_scc_v2_project_scc_big_query_export" "default" { @@ -94,6 +98,11 @@ resource "google_scc_v2_project_scc_big_query_export" "default" { depends_on = [time_sleep.wait_1_minute] } +resource "time_sleep" "wait_for_cleanup" { + create_duration = "6m" + depends_on = [google_scc_v2_project_scc_big_query_export.default] +} + `, context) } @@ -107,6 +116,7 @@ resource "google_bigquery_dataset" "default" { location = "US" default_table_expiration_ms = 3600000 default_partition_expiration_ms = null + delete_contents_on_destroy = true labels = { env = "default" @@ -117,6 +127,14 @@ resource "google_bigquery_dataset" "default" { } } +resource "time_sleep" "wait_1_minute" { + depends_on = [google_bigquery_dataset.default] + create_duration = "6m" + # need to wait for destruction due to + # 'still in use' error from api + destroy_duration = "1m" +} + resource "google_scc_v2_project_scc_big_query_export" "default" { big_query_export_id = "%{big_query_export_id}" project = "%{project}" @@ -125,6 +143,13 @@ resource "google_scc_v2_project_scc_big_query_export" "default" { description = "SCC Findings Big Query Export Update" filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\"" + depends_on = [time_sleep.wait_1_minute] + +} + +resource "time_sleep" "wait_for_cleanup" { + create_duration = "6m" + depends_on = [google_scc_v2_project_scc_big_query_export.default] } `, context)