Skip to content

Commit b8553aa

Browse files
authored
tests: restore coverage for 'google.cloud.bigtable.table' to 100% (googleapis#337)
Also, document retryable errors as a module scope constant. Toward googleapis#335
1 parent 108d770 commit b8553aa

2 files changed

Lines changed: 213 additions & 229 deletions

File tree

google/cloud/bigtable/table.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
_MAX_BULK_MUTATIONS = 100000
5454
VIEW_NAME_ONLY = enums.Table.View.NAME_ONLY
5555

56+
RETRYABLE_MUTATION_ERRORS = (Aborted, DeadlineExceeded, ServiceUnavailable)
57+
"""Errors which can be retried during row mutation."""
58+
5659

5760
class _BigtableRetryableError(Exception):
5861
"""Retry-able error expected by the default retry strategy."""
@@ -1039,10 +1042,8 @@ class _RetryableMutateRowsWorker(object):
10391042
are retryable, any subsequent call on this callable will be a no-op.
10401043
"""
10411044

1042-
RETRY_CODES = (
1043-
Aborted.grpc_status_code.value[0],
1044-
DeadlineExceeded.grpc_status_code.value[0],
1045-
ServiceUnavailable.grpc_status_code.value[0],
1045+
RETRY_CODES = tuple(
1046+
retryable.grpc_status_code.value[0] for retryable in RETRYABLE_MUTATION_ERRORS
10461047
)
10471048

10481049
def __init__(self, client, table_name, rows, app_profile_id=None, timeout=None):
@@ -1125,7 +1126,7 @@ def _do_mutate_retryable_rows(self):
11251126
retry=None,
11261127
**kwargs
11271128
)
1128-
except (ServiceUnavailable, DeadlineExceeded, Aborted):
1129+
except RETRYABLE_MUTATION_ERRORS:
11291130
# If an exception, considered retryable by `RETRY_CODES`, is
11301131
# returned from the initial call, consider
11311132
# it to be retryable. Wrap as a Bigtable Retryable Error.

0 commit comments

Comments
 (0)