Skip to content

Commit 1f4e98c

Browse files
authored
test: add a test for unary retries of UNAVAILABLE (#1376)
1 parent 3a91671 commit 1f4e98c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/mockserver_tests/test_basics.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ def test_dbapi_partitioned_dml(self):
9393
TransactionOptions(dict(partitioned_dml={})), begin_request.options
9494
)
9595

96+
def test_batch_create_sessions_unavailable(self):
97+
add_select1_result()
98+
add_error(SpannerServicer.BatchCreateSessions.__name__, unavailable_status())
99+
with self.database.snapshot() as snapshot:
100+
results = snapshot.execute_sql("select 1")
101+
result_list = []
102+
for row in results:
103+
result_list.append(row)
104+
self.assertEqual(1, row[0])
105+
self.assertEqual(1, len(result_list))
106+
requests = self.spanner_service.requests
107+
self.assertEqual(3, len(requests), msg=requests)
108+
# The BatchCreateSessions call should be retried.
109+
self.assertTrue(isinstance(requests[0], BatchCreateSessionsRequest))
110+
self.assertTrue(isinstance(requests[1], BatchCreateSessionsRequest))
111+
self.assertTrue(isinstance(requests[2], ExecuteSqlRequest))
112+
96113
def test_execute_streaming_sql_unavailable(self):
97114
add_select1_result()
98115
# Add an UNAVAILABLE error that is returned the first time the

0 commit comments

Comments
 (0)