Skip to content

Commit

Permalink
Address dependency issues in TestAccFirestoreField_* tests (GoogleClo…
Browse files Browse the repository at this point in the history
…udPlatform#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
  • Loading branch information
SarahFrench authored Mar 5, 2024
1 parent 2c6c6a1 commit 3791c34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
UserAgent: config.UserAgent,
})
if err != nil {
return err
e := err.(*googleapi.Error)
if e.Code == 403 && strings.Contains(e.Message, "Cloud Firestore API has not been used in project") {
// The acceptance test has provisioned the resources under test in a new project, and the destory check is seeing the
// effects of the project not existing. This means the service isn't enabled, and that the resource is definitely destroyed.
// We do not return the error in this case - destroy was successful
return nil
}

// Return err in all other cases
return err
}

if v := res["indexConfig"]; v != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ resource "google_firestore_database" "database" {
location_id = "nam5"
type = "FIRESTORE_NATIVE"
depends_on = [google_project_service.firestore]
# used to control delete order
depends_on = [
google_project_service.firestore,
google_project.project
]
}
`, context)
} else {
Expand All @@ -115,7 +119,7 @@ resource "google_firestore_database" "database" {
type = "FIRESTORE_NATIVE"
delete_protection_state = "DELETE_PROTECTION_DISABLED"
deletion_policy = "DELETE"
deletion_policy = "DELETE"
}
`, context)
}
Expand Down

0 comments on commit 3791c34

Please sign in to comment.