Skip to content

Commit

Permalink
test(spanner): fix flaky restore_database() sample test (#4641)
Browse files Browse the repository at this point in the history
* test(spanner): fix flaky restore backup sample test

* fix: update timeout to match other languages

* test: import test_utils and set max retries to 2

Co-authored-by: larkee <larkee@users.noreply.github.com>
  • Loading branch information
larkee and larkee authored Sep 18, 2020
1 parent 41b9a57 commit cacc0c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spanner/cloud-client/backup_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def restore_database(instance_id, new_database_id, backup_id):
operation = new_database.restore(backup)

# Wait for restore operation to complete.
operation.result(1200)
operation.result(1600)

# Newly created database has restore information.
new_database.reload()
Expand Down
3 changes: 3 additions & 0 deletions spanner/cloud-client/backup_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
# limitations under the License.
import uuid

from google.api_core.exceptions import DeadlineExceeded
from google.cloud import spanner
import pytest
from test_utils.retry import RetryErrors

import backup_sample

Expand Down Expand Up @@ -67,6 +69,7 @@ def test_create_backup(capsys, database):
assert BACKUP_ID in out


@RetryErrors(exception=DeadlineExceeded, max_tries=2)
def test_restore_database(capsys):
backup_sample.restore_database(INSTANCE_ID, RESTORE_DB_ID, BACKUP_ID)
out, _ = capsys.readouterr()
Expand Down
1 change: 1 addition & 0 deletions spanner/cloud-client/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest==6.0.1
mock==4.0.2
google-cloud-testutils==0.1.0

0 comments on commit cacc0c7

Please sign in to comment.