Repository navigation
Conversation
Enterprise Spanner databases reduce backup storage and cost with IncrementalBackupSpec schedules via create_backup_schedule. Add a standalone spanner_create_incremental_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 script to create incremental backup schedules on Enterprise Spanner databases, along with unit and live integration tests. The feedback suggests refining the live integration test to avoid deleting all existing backup schedules on the shared database, which could disrupt concurrent tests. Instead, the cleanup should target only the specific test-created schedules using a safer teardown pattern.
| # Remove any default incremental schedule temporarily if present | ||
| 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 shared live database can disrupt other concurrent tests or delete persistent schedules. It is safer to only clean up leftover schedules created by this test suite (e.g., those matching the 'example-isc-' prefix). Additionally, ensure consistency in test structures by using a try...finally block or teardown function for resource cleanup, matching neighboring tests in the same directory.
try:
# Run test logic
pass
finally:
# Remove any leftover test incremental schedules if present
for existing in admin.list_backup_schedules(parent=db_path):
if "example-isc-" in existing.name:
admin.delete_backup_schedule(name=existing.name)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 these tests (4b37cc7).
…chedule 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_incremental_backup_schedule_test.py
Description
Adds
spanner_create_incremental_backup_schedulecreating an automatedIncrementalBackupSpecbackup schedule.Checklist
Testing
Compliance & Style
spanner/, which the default repository owners cover.Post-Approval Actions