55
55
CREATE_INSTANCE = os .getenv ("GOOGLE_CLOUD_TESTS_CREATE_SPANNER_INSTANCE" ) is not None
56
56
USE_EMULATOR = os .getenv ("SPANNER_EMULATOR_HOST" ) is not None
57
57
SKIP_BACKUP_TESTS = os .getenv ("SKIP_BACKUP_TESTS" ) is not None
58
+ SPANNER_OPERATION_TIMEOUT_IN_SECONDS = int (
59
+ os .getenv ("SPANNER_OPERATION_TIMEOUT_IN_SECONDS" , 60 )
60
+ )
58
61
59
62
if CREATE_INSTANCE :
60
63
INSTANCE_ID = "google-cloud" + unique_resource_id ("-" )
@@ -149,7 +152,9 @@ def setUpModule():
149
152
INSTANCE_ID , config_name , labels = labels
150
153
)
151
154
created_op = Config .INSTANCE .create ()
152
- created_op .result (30 ) # block until completion
155
+ created_op .result (
156
+ SPANNER_OPERATION_TIMEOUT_IN_SECONDS
157
+ ) # block until completion
153
158
154
159
else :
155
160
Config .INSTANCE = Config .CLIENT .instance (INSTANCE_ID )
@@ -208,7 +213,9 @@ def test_create_instance(self):
208
213
self .instances_to_delete .append (instance )
209
214
210
215
# We want to make sure the operation completes.
211
- operation .result (30 ) # raises on failure / timeout.
216
+ operation .result (
217
+ SPANNER_OPERATION_TIMEOUT_IN_SECONDS
218
+ ) # raises on failure / timeout.
212
219
213
220
# Create a new instance instance and make sure it is the same.
214
221
instance_alt = Config .CLIENT .instance (
@@ -227,7 +234,9 @@ def test_update_instance(self):
227
234
operation = Config .INSTANCE .update ()
228
235
229
236
# We want to make sure the operation completes.
230
- operation .result (30 ) # raises on failure / timeout.
237
+ operation .result (
238
+ SPANNER_OPERATION_TIMEOUT_IN_SECONDS
239
+ ) # raises on failure / timeout.
231
240
232
241
# Create a new instance instance and reload it.
233
242
instance_alt = Config .CLIENT .instance (INSTANCE_ID , None )
@@ -308,7 +317,9 @@ def setUpClass(cls):
308
317
cls .DATABASE_NAME , ddl_statements = ddl_statements , pool = pool
309
318
)
310
319
operation = cls ._db .create ()
311
- operation .result (30 ) # raises on failure / timeout.
320
+ operation .result (
321
+ SPANNER_OPERATION_TIMEOUT_IN_SECONDS
322
+ ) # raises on failure / timeout.
312
323
313
324
@classmethod
314
325
def tearDownClass (cls ):
@@ -337,7 +348,9 @@ def test_create_database(self):
337
348
self .to_delete .append (temp_db )
338
349
339
350
# We want to make sure the operation completes.
340
- operation .result (30 ) # raises on failure / timeout.
351
+ operation .result (
352
+ SPANNER_OPERATION_TIMEOUT_IN_SECONDS
353
+ ) # raises on failure / timeout.
341
354
342
355
database_ids = [database .name for database in Config .INSTANCE .list_databases ()]
343
356
self .assertIn (temp_db .name , database_ids )
@@ -483,8 +496,8 @@ def setUpClass(cls):
483
496
cls ._dbs = [db1 , db2 ]
484
497
op1 = db1 .create ()
485
498
op2 = db2 .create ()
486
- op1 .result (30 ) # raises on failure / timeout.
487
- op2 .result (30 ) # raises on failure / timeout.
499
+ op1 .result (SPANNER_OPERATION_TIMEOUT_IN_SECONDS ) # raises on failure / timeout.
500
+ op2 .result (SPANNER_OPERATION_TIMEOUT_IN_SECONDS ) # raises on failure / timeout.
488
501
489
502
current_config = Config .INSTANCE .configuration_name
490
503
same_config_instance_id = "same-config" + unique_resource_id ("-" )
@@ -494,7 +507,7 @@ def setUpClass(cls):
494
507
same_config_instance_id , current_config , labels = labels
495
508
)
496
509
op = cls ._same_config_instance .create ()
497
- op .result (30 )
510
+ op .result (SPANNER_OPERATION_TIMEOUT_IN_SECONDS )
498
511
cls ._instances = [cls ._same_config_instance ]
499
512
500
513
retry = RetryErrors (exceptions .ServiceUnavailable )
@@ -513,7 +526,7 @@ def setUpClass(cls):
513
526
diff_config_instance_id , diff_configs [0 ], labels = labels
514
527
)
515
528
op = cls ._diff_config_instance .create ()
516
- op .result (30 )
529
+ op .result (SPANNER_OPERATION_TIMEOUT_IN_SECONDS )
517
530
cls ._instances .append (cls ._diff_config_instance )
518
531
519
532
@classmethod
@@ -675,7 +688,7 @@ def test_multi_create_cancel_update_error_restore_errors(self):
675
688
return
676
689
new_db = self ._diff_config_instance .database ("diff_config" )
677
690
op = new_db .create ()
678
- op .result (30 )
691
+ op .result (SPANNER_OPERATION_TIMEOUT_IN_SECONDS )
679
692
self .to_drop .append (new_db )
680
693
with self .assertRaises (exceptions .InvalidArgument ):
681
694
new_db .restore (source = backup1 )
@@ -866,7 +879,9 @@ def setUpClass(cls):
866
879
cls .DATABASE_NAME , ddl_statements = ddl_statements , pool = pool
867
880
)
868
881
operation = cls ._db .create ()
869
- operation .result (30 ) # raises on failure / timeout.
882
+ operation .result (
883
+ SPANNER_OPERATION_TIMEOUT_IN_SECONDS
884
+ ) # raises on failure / timeout.
870
885
871
886
@classmethod
872
887
def tearDownClass (cls ):
@@ -1788,7 +1803,9 @@ def test_read_w_index(self):
1788
1803
self .
341A
to_delete .append (_DatabaseDropper (temp_db ))
1789
1804
1790
1805
# We want to make sure the operation completes.
1791
- operation .result (30 ) # raises on failure / timeout.
1806
+ operation .result (
1807
+ SPANNER_OPERATION_TIMEOUT_IN_SECONDS
1808
+ ) # raises on failure / timeout.
1792
1809
committed = self ._set_up_table (row_count , database = temp_db )
1793
1810
1794
1811
with temp_db .snapshot (read_timestamp = committed ) as snapshot :
0 commit comments