Skip to content

Commit cacc0c7

Browse files
authored
test(spanner): fix flaky restore_database() sample test (#4641)
* 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 <[email protected]>
1 parent 41b9a57 commit cacc0c7

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

spanner/cloud-client/backup_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def restore_database(instance_id, new_database_id, backup_id):
6868
operation = new_database.restore(backup)
6969

7070
# Wait for restore operation to complete.
71-
operation.result(1200)
71+
operation.result(1600)
7272

7373
# Newly created database has restore information.
7474
new_database.reload()

spanner/cloud-client/backup_sample_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
# limitations under the License.
1414
import uuid
1515

16+
from google.api_core.exceptions import DeadlineExceeded
1617
from google.cloud import spanner
1718
import pytest
19+
from test_utils.retry import RetryErrors
1820

1921
import backup_sample
2022

@@ -67,6 +69,7 @@ def test_create_backup(capsys, database):
6769
assert BACKUP_ID in out
6870

6971

72+
@RetryErrors(exception=DeadlineExceeded, max_tries=2)
7073
def test_restore_database(capsys):
7174
backup_sample.restore_database(INSTANCE_ID, RESTORE_DB_ID, BACKUP_ID)
7275
out, _ = capsys.readouterr()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pytest==6.0.1
22
mock==4.0.2
3+
google-cloud-testutils==0.1.0

0 commit comments

Comments
 (0)