Skip to content

Commit 5e7e96b

Browse files
Fix Failing test TestAccSecurityCenterV2ProjectBigQueryExportConfig_basic + others (#12334) (#8916)
[upstream:654663666d97447080ded5cd3e5cb3b62e2dfffc] Signed-off-by: Modular Magician <[email protected]>
1 parent b3a1598 commit 5e7e96b

6 files changed

+99
-17
lines changed

.changelog/12334.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
securitycenterv2: fixed flaky test TestAccSecurityCenterV2ProjectBigQueryExportConfig_basic
3+
```

google-beta/services/securitycenter/resource_scc_organization_big_query_export_config_test.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ func TestAccSecurityCenterOrganizationBigQueryExportConfig_basic(t *testing.T) {
1515
t.Parallel()
1616

1717
randomSuffix := acctest.RandString(t, 10)
18-
dataset_id := "tf_test_" + randomSuffix
18+
datasetID := "tf_test_" + randomSuffix
1919
orgID := envvar.GetTestOrgFromEnv(t)
2020

2121
context := map[string]interface{}{
2222
"org_id": orgID,
2323
"random_suffix": randomSuffix,
24-
"dataset_id": dataset_id,
24+
"dataset_id": datasetID,
2525
"big_query_export_id": "tf-test-export-" + randomSuffix,
2626
"name": fmt.Sprintf("organizations/%s/bigQueryExports/%s",
2727
orgID, "tf-test-export-"+randomSuffix),
@@ -67,6 +67,7 @@ resource "google_bigquery_dataset" "default" {
6767
location = "US"
6868
default_table_expiration_ms = 3600000
6969
default_partition_expiration_ms = null
70+
delete_contents_on_destroy = true
7071
7172
labels = {
7273
env = "default"
@@ -79,7 +80,7 @@ resource "google_bigquery_dataset" "default" {
7980
8081
resource "time_sleep" "wait_1_minute" {
8182
depends_on = [google_bigquery_dataset.default]
82-
create_duration = "3m"
83+
create_duration = "6m"
8384
}
8485
8586
resource "google_scc_organization_scc_big_query_export" "default" {
@@ -92,6 +93,10 @@ resource "google_scc_organization_scc_big_query_export" "default" {
9293
depends_on = [time_sleep.wait_1_minute]
9394
}
9495
96+
resource "time_sleep" "wait_for_cleanup" {
97+
create_duration = "6m"
98+
depends_on = [google_scc_organization_scc_big_query_export.default]
99+
}
95100
`, context)
96101
}
97102

@@ -105,6 +110,7 @@ resource "google_bigquery_dataset" "default" {
105110
location = "US"
106111
default_table_expiration_ms = 3600000
107112
default_partition_expiration_ms = null
113+
delete_contents_on_destroy = true
108114
109115
labels = {
110116
env = "default"
@@ -115,12 +121,24 @@ resource "google_bigquery_dataset" "default" {
115121
}
116122
}
117123
124+
resource "time_sleep" "wait_1_minute" {
125+
depends_on = [google_bigquery_dataset.default]
126+
create_duration = "6m"
127+
}
128+
118129
resource "google_scc_organization_scc_big_query_export" "default" {
119130
big_query_export_id = "%{big_query_export_id}"
120131
organization = "%{org_id}"
121132
dataset = google_bigquery_dataset.default.id
122133
description = "SCC Findings Big Query Export Update"
123134
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\""
135+
136+
depends_on = [time_sleep.wait_1_minute]
137+
}
138+
139+
resource "time_sleep" "wait_for_cleanup" {
140+
create_duration = "6m"
141+
depends_on = [google_scc_organization_scc_big_query_export.default]
124142
}
125143
`, context)
126144
}

google-beta/services/securitycenter/resource_scc_project_big_query_export_config_test.go

+25-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ func TestAccSecurityCenterProjectBigQueryExportConfig_basic(t *testing.T) {
1414
t.Parallel()
1515

1616
randomSuffix := acctest.RandString(t, 10)
17-
dataset_id := "tf_test_" + randomSuffix
17+
datasetID := "tf_test_" + randomSuffix
1818
orgID := envvar.GetTestOrgFromEnv(t)
1919

2020
context := map[string]interface{}{
2121
"org_id": orgID,
2222
"random_suffix": randomSuffix,
23-
"dataset_id": dataset_id,
23+
"dataset_id": datasetID,
2424
"big_query_export_id": "tf-test-export-" + randomSuffix,
2525
"project": envvar.GetTestProjectFromEnv(),
2626
}
@@ -65,6 +65,7 @@ resource "google_bigquery_dataset" "default" {
6565
location = "US"
6666
default_table_expiration_ms = 3600000
6767
default_partition_expiration_ms = null
68+
delete_contents_on_destroy = true
6869
6970
labels = {
7071
env = "default"
@@ -77,7 +78,7 @@ resource "google_bigquery_dataset" "default" {
7778
7879
resource "time_sleep" "wait_x_minutes" {
7980
depends_on = [google_bigquery_dataset.default]
80-
create_duration = "3m"
81+
create_duration = "6m"
8182
# need to wait for destruction due to
8283
# 'still in use' error from api
8384
destroy_duration = "1m"
@@ -93,6 +94,11 @@ resource "google_scc_project_scc_big_query_export" "default" {
9394
depends_on = [time_sleep.wait_x_minutes]
9495
}
9596
97+
resource "time_sleep" "wait_for_cleanup" {
98+
create_duration = "6m"
99+
depends_on = [google_scc_project_scc_big_query_export.default]
100+
}
101+
96102
`, context)
97103
}
98104

@@ -106,6 +112,7 @@ resource "google_bigquery_dataset" "default" {
106112
location = "US"
107113
default_table_expiration_ms = 3600000
108114
default_partition_expiration_ms = null
115+
delete_contents_on_destroy = true
109116
110117
labels = {
111118
env = "default"
@@ -116,12 +123,27 @@ resource "google_bigquery_dataset" "default" {
116123
}
117124
}
118125
126+
resource "time_sleep" "wait_x_minutes" {
127+
depends_on = [google_bigquery_dataset.default]
128+
create_duration = "6m"
129+
# need to wait for destruction due to
130+
# 'still in use' error from api
131+
destroy_duration = "1m"
132+
}
133+
119134
resource "google_scc_project_scc_big_query_export" "default" {
120135
big_query_export_id = "%{big_query_export_id}"
121136
project = "%{project}"
122137
dataset = google_bigquery_dataset.default.id
123138
description = "SCC Findings Big Query Export Update"
124139
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\""
140+
141+
depends_on = [time_sleep.wait_x_minutes]
142+
}
143+
144+
resource "time_sleep" "wait_for_cleanup" {
145+
create_duration = "6m"
146+
depends_on = [google_scc_project_scc_big_query_export.default]
125147
}
126148
127149
`, context)

google-beta/services/securitycenterv2/resource_scc_v2_organization_big_query_export_config_test.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ func TestAccSecurityCenterV2OrganizationBigQueryExportConfig_basic(t *testing.T)
1515
t.Parallel()
1616

1717
randomSuffix := acctest.RandString(t, 10)
18-
dataset_id := "tf_test_" + randomSuffix
18+
datasetID := "tf_test_" + randomSuffix
1919
orgID := envvar.GetTestOrgFromEnv(t)
2020

2121
context := map[string]interface{}{
2222
"org_id": orgID,
2323
"random_suffix": randomSuffix,
24-
"dataset_id": dataset_id,
24+
"dataset_id": datasetID,
2525
"big_query_export_id": "tf-test-export-" + randomSuffix,
2626
"name": fmt.Sprintf("organizations/%s/locations/global/bigQueryExports/%s",
2727
orgID, "tf-test-export-"+randomSuffix),
@@ -96,7 +96,7 @@ resource "google_scc_v2_organization_scc_big_query_export" "default" {
9696
}
9797
9898
resource "time_sleep" "wait_for_cleanup" {
99-
create_duration = "3m"
99+
create_duration = "6m"
100100
depends_on = [google_scc_v2_organization_scc_big_query_export.default]
101101
}
102102
`, context)
@@ -123,6 +123,11 @@ resource "google_bigquery_dataset" "default" {
123123
}
124124
}
125125
126+
resource "time_sleep" "wait_1_minute" {
127+
depends_on = [google_bigquery_dataset.default]
128+
create_duration = "6m"
129+
}
130+
126131
resource "google_scc_v2_organization_scc_big_query_export" "default" {
127132
name = "%{name}"
128133
big_query_export_id = "%{big_query_export_id}"
@@ -131,10 +136,12 @@ resource "google_scc_v2_organization_scc_big_query_export" "default" {
131136
location = "global"
132137
description = "SCC Findings Big Query Export Update"
133138
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\""
139+
140+
depends_on = [time_sleep.wait_1_minute]
134141
}
135142
136143
resource "time_sleep" "wait_for_cleanup" {
137-
create_duration = "3m"
144+
create_duration = "6m"
138145
depends_on = [google_scc_v2_organization_scc_big_query_export.default]
139146
}
140147
`, context)

google-beta/services/securitycenterv2/resource_scc_v2_organization_big_query_exports_config_test.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ func TestAccSecurityCenterV2OrganizationBigQueryExportsConfig_basic(t *testing.T
1515
t.Parallel()
1616

1717
randomSuffix := acctest.RandString(t, 10)
18-
dataset_id := "tf_test_" + randomSuffix
18+
datasetID := "tf_test_" + randomSuffix
1919
orgID := envvar.GetTestOrgFromEnv(t)
2020

2121
context := map[string]interface{}{
2222
"org_id": orgID,
2323
"random_suffix": randomSuffix,
24-
"dataset_id": dataset_id,
24+
"dataset_id": datasetID,
2525
"big_query_export_id": "tf-test-export-" + randomSuffix,
2626
"name": fmt.Sprintf("organizations/%s/locations/global/bigQueryExports/%s",
2727
orgID, "tf-test-export-"+randomSuffix),
@@ -96,7 +96,7 @@ resource "google_scc_v2_organization_scc_big_query_exports" "default" {
9696
}
9797
9898
resource "time_sleep" "wait_for_cleanup" {
99-
create_duration = "3m"
99+
create_duration = "6m"
100100
depends_on = [google_scc_v2_organization_scc_big_query_exports.default]
101101
}
102102
`, context)
@@ -123,6 +123,11 @@ resource "google_bigquery_dataset" "default" {
123123
}
124124
}
125125
126+
resource "time_sleep" "wait_1_minute" {
127+
depends_on = [google_bigquery_dataset.default]
128+
create_duration = "6m"
129+
}
130+
126131
resource "google_scc_v2_organization_scc_big_query_exports" "default" {
127132
name = "%{name}"
128133
big_query_export_id = "%{big_query_export_id}"
@@ -131,10 +136,12 @@ resource "google_scc_v2_organization_scc_big_query_exports" "default" {
131136
location = "global"
132137
description = "SCC Findings Big Query Export Update"
133138
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\""
139+
140+
depends_on = [time_sleep.wait_1_minute]
134141
}
135142
136143
resource "time_sleep" "wait_for_cleanup" {
137-
create_duration = "3m"
144+
create_duration = "6m"
138145
depends_on = [google_scc_v2_organization_scc_big_query_exports.default]
139146
}
140147
`, context)

google-beta/services/securitycenterv2/resource_scc_v2_project_big_query_export_config_test.go

+28-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ func TestAccSecurityCenterV2ProjectBigQueryExportConfig_basic(t *testing.T) {
1515
t.Parallel()
1616

1717
randomSuffix := acctest.RandString(t, 10)
18-
dataset_id := "tf_test_" + randomSuffix
18+
datasetID := "tf_test_" + randomSuffix
1919
orgID := envvar.GetTestOrgFromEnv(t)
2020

2121
context := map[string]interface{}{
2222
"org_id": orgID,
2323
"random_suffix": randomSuffix,
24-
"dataset_id": dataset_id,
24+
"dataset_id": datasetID,
2525
"big_query_export_id": "tf-test-export-" + randomSuffix,
2626
"name": fmt.Sprintf("projects/%s/locations/global/bigQueryExports/%s",
2727
envvar.GetTestProjectFromEnv(), "tf-test-export-"+randomSuffix),
@@ -68,6 +68,7 @@ resource "google_bigquery_dataset" "default" {
6868
location = "US"
6969
default_table_expiration_ms = 3600000
7070
default_partition_expiration_ms = null
71+
delete_contents_on_destroy = true
7172
7273
labels = {
7374
env = "default"
@@ -80,7 +81,10 @@ resource "google_bigquery_dataset" "default" {
8081
8182
resource "time_sleep" "wait_1_minute" {
8283
depends_on = [google_bigquery_dataset.default]
83-
create_duration = "3m"
84+
create_duration = "6m"
85+
# need to wait for destruction due to
86+
# 'still in use' error from api
87+
destroy_duration = "1m"
8488
}
8589
8690
resource "google_scc_v2_project_scc_big_query_export" "default" {
@@ -94,6 +98,11 @@ resource "google_scc_v2_project_scc_big_query_export" "default" {
9498
depends_on = [time_sleep.wait_1_minute]
9599
}
96100
101+
resource "time_sleep" "wait_for_cleanup" {
102+
create_duration = "6m"
103+
depends_on = [google_scc_v2_project_scc_big_query_export.default]
104+
}
105+
97106
`, context)
98107
}
99108

@@ -107,6 +116,7 @@ resource "google_bigquery_dataset" "default" {
107116
location = "US"
108117
default_table_expiration_ms = 3600000
109118
default_partition_expiration_ms = null
119+
delete_contents_on_destroy = true
110120
111121
labels = {
112122
env = "default"
@@ -117,6 +127,14 @@ resource "google_bigquery_dataset" "default" {
117127
}
118128
}
119129
130+
resource "time_sleep" "wait_1_minute" {
131+
depends_on = [google_bigquery_dataset.default]
132+
create_duration = "6m"
133+
# need to wait for destruction due to
134+
# 'still in use' error from api
135+
destroy_duration = "1m"
136+
}
137+
120138
resource "google_scc_v2_project_scc_big_query_export" "default" {
121139
big_query_export_id = "%{big_query_export_id}"
122140
project = "%{project}"
@@ -125,6 +143,13 @@ resource "google_scc_v2_project_scc_big_query_export" "default" {
125143
description = "SCC Findings Big Query Export Update"
126144
filter = "state=\"ACTIVE\" AND NOT mute=\"MUTED\""
127145
146+
depends_on = [time_sleep.wait_1_minute]
147+
148+
}
149+
150+
resource "time_sleep" "wait_for_cleanup" {
151+
create_duration = "6m"
152+
depends_on = [google_scc_v2_project_scc_big_query_export.default]
128153
}
129154
130155
`, context)

0 commit comments

Comments
 (0)