Skip to content

Commit 7df0be7

Browse files
authored
Make BootstrapSharedTestTagKey wait for operation (GoogleCloudPlatform#13650)
1 parent 5e02af6 commit 7df0be7

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

mmv1/third_party/terraform/acctest/bootstrap_test_utils.go.tmpl

+22-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
{{- end }}
2020

2121
"github.com/hashicorp/terraform-provider-google/google/envvar"
22+
"github.com/hashicorp/terraform-provider-google/google/services/tags"
2223
tpgcompute "github.com/hashicorp/terraform-provider-google/google/services/compute"
2324
"github.com/hashicorp/terraform-provider-google/google/services/privateca"
2425
"github.com/hashicorp/terraform-provider-google/google/services/resourcemanager"
@@ -2087,7 +2088,7 @@ func BootstrapSharedTestTagKey(t *testing.T, testId string) string {
20872088
"description": "Bootstrapped tag key for Terraform Acceptance testing",
20882089
}
20892090

2090-
_, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
2091+
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
20912092
Config: config,
20922093
Method: "POST",
20932094
Project: config.Project,
@@ -2101,6 +2102,15 @@ func BootstrapSharedTestTagKey(t *testing.T, testId string) string {
21012102
}
21022103

21032104
log.Printf("[DEBUG] Waiting for shared tag key creation to finish")
2105+
2106+
err = tags.TagsOperationWaitTime(
2107+
config, res, "Creating TagKey", config.UserAgent,
2108+
20 * time.Minute)
2109+
2110+
if err != nil {
2111+
// The resource didn't actually create
2112+
t.Fatalf("Error waiting to create TagKey: %s", err)
2113+
}
21042114
}
21052115

21062116
_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
@@ -2163,7 +2173,7 @@ func BootstrapSharedTestTagValue(t *testing.T, testId string, tagKey string) str
21632173
"description": "Bootstrapped tag value for Terraform Acceptance testing",
21642174
}
21652175

2166-
_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
2176+
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
21672177
Config: config,
21682178
Method: "POST",
21692179
Project: config.Project,
@@ -2172,11 +2182,21 @@ func BootstrapSharedTestTagValue(t *testing.T, testId string, tagKey string) str
21722182
Body: tagKeyObj,
21732183
Timeout: 10 * time.Minute,
21742184
})
2185+
21752186
if err != nil {
21762187
t.Fatalf("Error bootstrapping shared tag value %q: %s", sharedTagValue, err)
21772188
}
21782189

21792190
log.Printf("[DEBUG] Waiting for shared tag value creation to finish")
2191+
2192+
err = tags.TagsOperationWaitTime(
2193+
config, res, "Creating TagValue", config.UserAgent,
2194+
20 * time.Minute)
2195+
2196+
if err != nil {
2197+
// The resource didn't actually create
2198+
t.Fatalf("Error waiting to create TagValue: %s", err)
2199+
}
21802200
}
21812201

21822202
_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{

0 commit comments

Comments
 (0)