Skip to content

Commit ee31e8a

Browse files
authored
tests: retry 'create_instance_with_processing_units' on 429 (googleapis#419)
Closes googleapis#416.
1 parent ca793cb commit ee31e8a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

samples/samples/snippets_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
import time
1616
import uuid
1717

18+
from google.api_core import exceptions
1819
from google.cloud import spanner
1920
from google.cloud.spanner_v1.instance import Backup
2021
from google.cloud.spanner_v1.instance import Instance
2122
import pytest
23+
from test_utils.retry import RetryErrors
2224

2325
import snippets
2426

@@ -84,7 +86,10 @@ def test_create_instance(spanner_instance):
8486

8587
def test_create_instance_with_processing_units(capsys):
8688
processing_units = 500
87-
snippets.create_instance_with_processing_units(LCI_INSTANCE_ID, processing_units)
89+
retry_429 = RetryErrors(exceptions.ResourceExhausted, delay=15)
90+
retry_429(snippets.create_instance_with_processing_units)(
91+
LCI_INSTANCE_ID, processing_units,
92+
)
8893
out, _ = capsys.readouterr()
8994
assert LCI_INSTANCE_ID in out
9095
assert "{} processing units".format(processing_units) in out

0 commit comments

Comments
 (0)