Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add retry and timeout for batch dml #1107

Merged
merged 7 commits into from
Mar 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(spanner): update unittest
  • Loading branch information
harshachinta committed Feb 26, 2024
commit 8efa9a55ee94fd8b608fe71ef77aed892d58b543
14 changes: 14 additions & 0 deletions tests/unit/test_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ def test_transaction_should_include_begin_with_first_batch_update(self):
("google-cloud-resource-prefix", database.name),
("x-goog-spanner-route-to-leader", "true"),
],
retry=RETRY,
timeout=TIMEOUT,
)

def test_transaction_should_use_transaction_id_if_error_with_first_batch_update(
Expand All @@ -574,6 +576,8 @@ def test_transaction_should_use_transaction_id_if_error_with_first_batch_update(
("google-cloud-resource-prefix", database.name),
("x-goog-spanner-route-to-leader", "true"),
],
retry=RETRY,
timeout=TIMEOUT,
)
self._execute_update_helper(transaction=transaction, api=api)
api.execute_sql.assert_called_once_with(
Expand Down Expand Up @@ -715,6 +719,8 @@ def test_transaction_should_use_transaction_id_returned_by_first_read(self):
("google-cloud-resource-prefix", database.name),
("x-goog-spanner-route-to-leader", "true"),
],
retry=RETRY,
timeout=TIMEOUT,
)

def test_transaction_should_use_transaction_id_returned_by_first_batch_update(self):
Expand All @@ -729,6 +735,8 @@ def test_transaction_should_use_transaction_id_returned_by_first_batch_update(se
("google-cloud-resource-prefix", database.name),
("x-goog-spanner-route-to-leader", "true"),
],
retry=RETRY,
timeout=TIMEOUT,
)
self._read_helper(transaction=transaction, api=api)
api.streaming_read.assert_called_once_with(
Expand Down Expand Up @@ -797,6 +805,8 @@ def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_
("google-cloud-resource-prefix", database.name),
("x-goog-spanner-route-to-leader", "true"),
],
retry=RETRY,
timeout=TIMEOUT,
)

self.assertEqual(api.execute_sql.call_count, 2)
Expand Down Expand Up @@ -846,6 +856,8 @@ def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_
("google-cloud-resource-prefix", database.name),
("x-goog-spanner-route-to-leader", "true"),
],
retry=RETRY,
timeout=TIMEOUT,
)

api.execute_batch_dml.assert_any_call(
Expand All @@ -854,6 +866,8 @@ def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_
("google-cloud-resource-prefix", database.name),
("x-goog-spanner-route-to-leader", "true"),
],
retry=RETRY,
timeout=TIMEOUT,
)

self.assertEqual(api.execute_sql.call_count, 1)
Expand Down