Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bb83cea

Browse filesBrowse files
author
Takashi Matsuo
authored
[bigtable] fix: wrap sample invocations with retries (GoogleCloudPlatform#3494)
fix GoogleCloudPlatform#3070 Also added `BIGTABLE_INSTANCE` to testing/test-env.tmpl.sh
1 parent 86a552c commit bb83cea
Copy full SHA for bb83cea

File tree

Expand file treeCollapse file tree

3 files changed

+23
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+23
-4
lines changed
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
backoff==1.10.0
12
pytest==5.3.2

‎bigtable/snippets/writes/writes_test.py

Copy file name to clipboardExpand all lines: bigtable/snippets/writes/writes_test.py
+21-4Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import uuid
1717
import pytest
1818

19+
import backoff
20+
from google.api_core.exceptions import DeadlineExceeded
1921
from google.cloud import bigtable
2022

2123
from .write_batch import write_batch
@@ -55,22 +57,37 @@ def table_id(bigtable_instance):
5557

5658

5759
def test_writes(capsys, table_id):
58-
write_simple(PROJECT, BIGTABLE_INSTANCE, table_id)
5960

61+
# `row.commit()` sometimes ends up with DeadlineExceeded, so now
62+
# we put retries with a hard deadline.
63+
@backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=60)
64+
def _write_simple():
65+
write_simple(PROJECT, BIGTABLE_INSTANCE, table_id)
66+
67+
_write_simple()
6068
out, _ = capsys.readouterr()
6169
assert 'Successfully wrote row' in out
6270

63-
write_increment(PROJECT, BIGTABLE_INSTANCE, table_id)
71+
@backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=60)
72+
def _write_increment():
73+
write_increment(PROJECT, BIGTABLE_INSTANCE, table_id)
6474

75+
_write_increment()
6576
out, _ = capsys.readouterr()
6677
assert 'Successfully updated row' in out
6778

68-
write_conditional(PROJECT, BIGTABLE_INSTANCE, table_id)
79+
@backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=60)
80+
def _write_conditional():
81+
write_conditional(PROJECT, BIGTABLE_INSTANCE, table_id)
6982

83+
_write_conditional()
7084
out, _ = capsys.readouterr()
7185
assert 'Successfully updated row\'s os_name' in out
7286

73-
write_batch(PROJECT, BIGTABLE_INSTANCE, table_id)
87+
@backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=60)
88+
def _write_batch():
89+
write_batch(PROJECT, BIGTABLE_INSTANCE, table_id)
7490

91+
_write_batch()
7592
out, _ = capsys.readouterr()
7693
assert 'Successfully wrote 2 rows' in out

‎testing/test-env.tmpl.sh

Copy file name to clipboardExpand all lines: testing/test-env.tmpl.sh
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export CLOUD_STORAGE_BUCKET=$GCLOUD_PROJECT
88
export API_KEY=
99
export BIGTABLE_CLUSTER=bigtable-test
1010
export BIGTABLE_ZONE=us-central1-c
11+
export BIGTABLE_INSTANCE=
1112
export SPANNER_INSTANCE=
1213
export COMPOSER_LOCATION=us-central1
1314
export COMPOSER_ENVIRONMENT=

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.