|
16 | 16 | import uuid
|
17 | 17 | import pytest
|
18 | 18 |
|
| 19 | +import backoff |
| 20 | +from google.api_core.exceptions import DeadlineExceeded |
19 | 21 | from google.cloud import bigtable
|
20 | 22 |
|
21 | 23 | from .write_batch import write_batch
|
@@ -55,22 +57,37 @@ def table_id(bigtable_instance):
|
55 | 57 |
|
56 | 58 |
|
57 | 59 | def test_writes(capsys, table_id):
|
58 |
| - write_simple(PROJECT, BIGTABLE_INSTANCE, table_id) |
59 | 60 |
|
| 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() |
60 | 68 | out, _ = capsys.readouterr()
|
61 | 69 | assert 'Successfully wrote row' in out
|
62 | 70 |
|
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) |
64 | 74 |
|
| 75 | + _write_increment() |
65 | 76 | out, _ = capsys.readouterr()
|
66 | 77 | assert 'Successfully updated row' in out
|
67 | 78 |
|
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) |
69 | 82 |
|
| 83 | + _write_conditional() |
70 | 84 | out, _ = capsys.readouterr()
|
71 | 85 | assert 'Successfully updated row\'s os_name' in out
|
72 | 86 |
|
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) |
74 | 90 |
|
| 91 | + _write_batch() |
75 | 92 | out, _ = capsys.readouterr()
|
76 | 93 | assert 'Successfully wrote 2 rows' in out
|
0 commit comments