1616import os
1717import uuid
1818
19+ from google .api_core import exceptions
20+ from test_utils .retry import RetryErrors
21+
1922from tableadmin import create_table
2023from tableadmin import delete_table
2124from tableadmin import run_table_operations
2427BIGTABLE_INSTANCE = os .environ ['BIGTABLE_INSTANCE' ]
2528TABLE_ID_FORMAT = 'tableadmin-test-{}'
2629
30+ retry_429_503 = RetryErrors (exceptions .TooManyRequests , exceptions .ServiceUnavailable )
31+
2732
2833def test_run_table_operations (capsys ):
2934 table_id = TABLE_ID_FORMAT .format (uuid .uuid4 ().hex [:8 ])
3035
31- run_table_operations (PROJECT , BIGTABLE_INSTANCE , table_id )
36+ retry_429_503 ( run_table_operations ) (PROJECT , BIGTABLE_INSTANCE , table_id )
3237 out , _ = capsys .readouterr ()
3338
3439 assert 'Creating the ' + table_id + ' table.' in out
@@ -48,14 +53,14 @@ def test_run_table_operations(capsys):
4853 assert 'Delete a column family cf2...' in out
4954 assert 'Column family cf2 deleted successfully.' in out
5055
51- delete_table (PROJECT , BIGTABLE_INSTANCE , table_id )
56+ retry_429_503 ( delete_table ) (PROJECT , BIGTABLE_INSTANCE , table_id )
5257
5358
5459def test_delete_table (capsys ):
5560 table_id = TABLE_ID_FORMAT .format (uuid .uuid4 ().hex [:8 ])
56- create_table (PROJECT , BIGTABLE_INSTANCE , table_id )
61+ retry_429_503 ( create_table ) (PROJECT , BIGTABLE_INSTANCE , table_id )
5762
58- delete_table (PROJECT , BIGTABLE_INSTANCE , table_id )
63+ retry_429_503 ( delete_table ) (PROJECT , BIGTABLE_INSTANCE , table_id )
5964 out , _ = capsys .readouterr ()
6065
6166 assert 'Table ' + table_id + ' exists.' in out
0 commit comments