Skip to content

test(spanner): unflake test_create_backup - #19171

Open
sakthivelmanii wants to merge 2 commits into
mainfrom
unflake-test-create-backup
Open

sakthivelmanii wants to merge 2 commits into
mainfrom
unflake-test-create-backup

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

Problem

  • create_backup, create_backup_with_encryption_key, create_backup_with_multiple_kms_keys, copy_backup, and copy_backup_with_multiple_kms_keys in packages/google-cloud-spanner/samples/samples/backup_sample.py poll the backup long-running operation with operation.result(2100) (35 minutes).
  • On a 1-node regional instance, CreateBackup operations routinely take 25–36 minutes; when an operation slightly exceeds 2100 seconds, PollingFuture._blocking_poll raises TimeoutError in test_create_backup without cancelling the server-side backup operation.
  • The still-pending backup operation then causes test_create_backup_with_encryption_key to fail with FailedPrecondition (maximum number of pending backups (1) for the database has been reached) and module teardown (sample_database.drop()) to fail with FailedPrecondition (backups pending creation).

Solution

  • Update the operation.result(...) polling timeout from 2100 to 3600 seconds across all five backup creation and copy sample functions in packages/google-cloud-spanner/samples/samples/backup_sample.py, matching the DatabaseAdmin GAPIC default_timeout (3600.0 seconds).
  • Add hermetic unit tests in packages/google-cloud-spanner/samples/samples/backup_sample_timeout_test.py verifying that all five sample functions poll operation.result(3600) and assert Backup.State.READY.

Align backup creation and copy sample LRO polling timeouts with the 3600s DatabaseAdmin GAPIC default timeout and add hermetic timeout unit tests.
@sakthivelmanii
sakthivelmanii requested a review from a team as a code owner November 21, 2026 20:38
@sakthivelmanii
sakthivelmanii enabled auto-merge (squash) November 21, 2026 20:38
@sakthivelmanii

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request increases the backup operation polling timeout from 2100 to 3600 seconds across multiple functions in backup_sample.py and adds a new test file backup_sample_timeout_test.py to verify this behavior. Feedback on the new test file suggests a more idiomatic approach to setting the mock return value by directly assigning to the attribute instead of using setattr.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request increases the backup and copy backup LRO polling timeout from 2100 to 3600 seconds across several functions in backup_sample.py. It also introduces a new test file, backup_sample_timeout_test.py, to verify these timeout settings. A review comment suggests a more idiomatic way to configure the mock's return value in the test by directly assigning to the attribute returned by getattr instead of using setattr.

@sakthivelmanii

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request increases the long-running operation (LRO) polling timeout from 2100 to 3600 seconds for backup creation and copying functions in backup_sample.py. It also adds a new unit test file, backup_sample_timeout_test.py, to verify that the updated timeout is correctly used. There are no review comments, so no further feedback is provided.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant