tests: cleanup stale databases in spanner system tests#17668
Merged
Conversation
Contributor
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
Contributor
Author
|
/gemini review |
Contributor
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
Contributor
|
/gemini review |
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a cleanup_stale_databases helper function to remove stale databases during system tests, which is integrated into the shared_instance fixture. The review feedback points out that instance.list_databases() already returns Database wrapper objects, making the manual instantiation of db redundant, and suggests a simplified loop structure.
parthea
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Spanner system tests can sometimes leave behind test databases if a run is interrupted or fails to clean up properly. Over time, these stale databases can accumulate, potentially hitting quota limits or cluttering the test environment.
Solution
Introduced a proactive cleanup mechanism to remove stale databases during test setup.
cleanup_stale_databaseshelper: A new function in_helpers.pythat lists databases in a given instance and drops any that are older than a specified cutoff (defaulting to 10 minutes/600 seconds).enable_drop_protectionif it's set, ensuring that even protected test databases can be cleaned up automatically.shared_instancefixture inconftest.py, ensuring that every test session starts by cleaning up residue from previous runs.Impact
NotFoundand other API errors during cleanup.