Repository navigation
Conversation
Automated full backup schedules configure cron timing and retention on a database via FullBackupSpec and create_backup_schedule. Add a standalone spanner_create_full_backup_schedule sample.
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new script to create daily full backup schedules on Google Cloud Spanner databases, along with unit and live integration tests. A critical issue was identified in the live integration test, where all existing backup schedules on the database are deleted before running the test. This destructive pre-cleanup step is unnecessary and risky, as the test already generates a unique schedule ID and cleans it up in a try-finally block.
| for existing in admin.list_backup_schedules(parent=db_path): | ||
| admin.delete_backup_schedule(name=existing.name) |
There was a problem hiding this comment.
Deleting all existing backup schedules on the live database is highly destructive and can cause flaky tests or disrupt other concurrent test runs or resources sharing the same database. Since the test already generates a unique schedule ID using a UUID and cleans it up in the finally block, this pre-cleanup step is unnecessary and should be removed.
References
- Maintain consistency in test structures by matching the patterns employed by existing or neighboring tests in the same directory, such as using a try...finally block with a teardown function for resource cleanup.
There was a problem hiding this comment.
Good point, done: the pre-cleanup now only removes schedules left behind by earlier runs of this test (8b1636e).
Problem: review of this sample identified correctness and robustness improvements in the sample and its tests. Solution: apply the accepted review suggestions and extend the tests to cover the updated behavior. Details are in the review thread replies. Files updated: - spanner/backups/tests/create_full_backup_schedule_test.py
Description
Adds
spanner_create_full_backup_schedulecreating an automatedFullBackupSpecbackup schedule.Checklist
Testing
Compliance & Style
spanner/, which the default repository owners cover.Post-Approval Actions