Skip to content

Commit 93ed94f

Browse files
SarahFrenchjashansudan
authored andcommitted
Address dependency issues in TestAccFirestoreField_* tests (GoogleCloudPlatform#9957)
* Add additional wait in TestAccFirestoreField_* tests * Boost wait in test to 6 minutes * Add dependency between database and service to control delete order * Update dependency to explicitly include project * Make firestore fields be removed from state when they're 'deleted' * Add `destroy_duration` * Remove from state after log line that uses id value * Update destory check to accept a 403 as valid * Remove unneeded changes in PR * Remove call to SetId
1 parent 66de16a commit 93ed94f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

mmv1/templates/terraform/custom_check_destroy/firestore_field.go.erb

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
1616
UserAgent: config.UserAgent,
1717
})
1818
if err != nil {
19-
return err
19+
e := err.(*googleapi.Error)
20+
if e.Code == 403 && strings.Contains(e.Message, "Cloud Firestore API has not been used in project") {
21+
// The acceptance test has provisioned the resources under test in a new project, and the destory check is seeing the
22+
// effects of the project not existing. This means the service isn't enabled, and that the resource is definitely destroyed.
23+
// We do not return the error in this case - destroy was successful
24+
return nil
25+
}
26+
27+
// Return err in all other cases
28+
return err
2029
}
2130

2231
if v := res["indexConfig"]; v != nil {

mmv1/third_party/terraform/services/firestore/resource_firestore_field_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ resource "google_firestore_database" "database" {
103103
location_id = "nam5"
104104
type = "FIRESTORE_NATIVE"
105105
106-
depends_on = [google_project_service.firestore]
106+
# used to control delete order
107+
depends_on = [
108+
google_project_service.firestore,
109+
google_project.project
110+
]
107111
}
108112
`, context)
109113
} else {
@@ -115,7 +119,7 @@ resource "google_firestore_database" "database" {
115119
type = "FIRESTORE_NATIVE"
116120
117121
delete_protection_state = "DELETE_PROTECTION_DISABLED"
118-
deletion_policy = "DELETE"
122+
deletion_policy = "DELETE"
119123
}
120124
`, context)
121125
}

0 commit comments

Comments
 (0)