59
59
except ImportError :
60
60
NotFound = None
61
61
62
- # Number of seconds to wait for bucket deletion to propagate.
63
- WAIT_DELETE_BUCKET_PROPAGATION_SECONDS = 10
62
+ # Number of seconds to wait for bucket deletion or creation to propagate.
63
+ WAIT_BUCKET_PROPAGATION_SECONDS = 60
64
64
65
65
66
66
@unittest .skipIf (gcsio is None , 'GCP dependencies are not installed' )
@@ -208,15 +208,17 @@ def test_create_default_bucket(self, mock_default_gcs_bucket_name):
208
208
google_cloud_options .dataflow_kms_key = None
209
209
210
210
import random
211
- from hashlib import md5
211
+ from hashlib import blake2b
212
212
# Add a random number to avoid collision if multiple test instances
213
213
# are run at the same time. To avoid too many dangling buckets if bucket
214
214
# removal fails, we limit the max number of possible bucket names in this
215
215
# test to 1000.
216
- overridden_bucket_name = 'gcsio-it-%d-%s-%s' % (
216
+ overridden_bucket_name = 'gcsio-it-%d-%s-%s-%d ' % (
217
217
random .randint (0 , 999 ),
218
218
google_cloud_options .region ,
219
- md5 (google_cloud_options .project .encode ('utf8' )).hexdigest ())
219
+ blake2b (google_cloud_options .project .encode ('utf8' ),
220
+ digest_size = 4 ).hexdigest (),
221
+ int (time .time ()))
220
222
221
223
mock_default_gcs_bucket_name .return_value = overridden_bucket_name
222
224
@@ -225,13 +227,14 @@ def test_create_default_bucket(self, mock_default_gcs_bucket_name):
225
227
if existing_bucket :
226
228
try :
227
229
existing_bucket .delete ()
228
- time .sleep (WAIT_DELETE_BUCKET_PROPAGATION_SECONDS )
230
+ time .sleep (WAIT_BUCKET_PROPAGATION_SECONDS )
229
231
except NotFound :
230
232
# Bucket existence check from get_bucket may be inaccurate due to gcs
231
233
# cache or delay
232
234
pass
233
235
234
236
bucket = gcsio .get_or_create_default_gcs_bucket (google_cloud_options )
237
+ time .sleep (WAIT_BUCKET_PROPAGATION_SECONDS )
235
238
self .assertIsNotNone (bucket )
236
239
self .assertEqual (bucket .name , overridden_bucket_name )
237
240
0 commit comments