GoogleCloudPlatform / terraform-validator

Terraform Validator is not an officially supported Google product; it is a library for conversion of Terraform plan data to CAI Assets. If you have been using terraform-validator directly in the past, we recommend migrating to `gcloud beta terraform vet`.
https://cloud.google.com/docs/terraform/policy-validation
Apache License 2.0
437 stars 93 forks source link

Fix SQL instance sweeper to only delete sweepable instances #1528

Closed modular-magician closed 1 year ago

modular-magician commented 1 year ago

This sweeper was mistakenly deleting all SQL instances, instead of only deleting instances whose name matched IsSweepableTestResource(). In practice, this meant that our bootstrapped instance was being deleted on every run in GA.

Besides reducing churn and test run time, this change greatly reduces the chance of test failures that occur when relying on the bootstrapped instance immediately after it is created. Specifically, it appears that some of our tests will mistakenly try to clone the bootstrapped instance based off of a backup that is automatically created before the instance is actually done being created, and then they fail. This should not occur after the bootstrapped instance has had time to create other backups.

If this PR is for Terraform, I acknowledge that I have:

Release Note Template for Downstream PRs (will be copied)

Derived from https://github.com/GoogleCloudPlatform/magic-modules/pull/7602