Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit e3e6a0a

Browse files
cojencotseaver
andauthored
tests: update retry conf tests using the updated testbench emulator (#555)
* tests: address changes to the updated testbench emulator * fix typo * Add comment to explain clearing etag in bucket_set_iampolicy Co-authored-by: Tres Seaver <tseaver@palladion.com> Co-authored-by: Tres Seaver <tseaver@palladion.com>
1 parent e5f2d13 commit e3e6a0a

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

tests/conformance/retry_strategy_test_data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@
5454
]
5555
},
5656
{
57-
"name": "storage.buckets.lockRententionPolicy",
57+
"name": "storage.buckets.lockRetentionPolicy",
5858
"resources": [
5959
"BUCKET"
6060
]
6161
},
6262
{
63-
"name": "storage.buckets.testIamPermission",
63+
"name": "storage.buckets.testIamPermissions",
6464
"resources": [
6565
"BUCKET"
6666
]

tests/conformance/test_conformance.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ def bucket_test_iam_permissions(client, _preconditions, **resources):
164164
bucket.test_iam_permissions(permissions)
165165

166166

167-
# TODO(cathyo@): issue resolved in the new testbench where buckets have a valid metageneration
168167
def bucket_lock_retention_policy(client, _preconditions, **resources):
169168
bucket = client.bucket(resources.get("bucket").name)
170169
bucket.retention_period = 60
@@ -222,8 +221,8 @@ def client_get_service_account_email(client, _preconditions, **_):
222221
client.get_service_account_email()
223222

224223

225-
def bucket_patch(client, _preconditions, **_):
226-
bucket = client.get_bucket("bucket")
224+
def bucket_patch(client, _preconditions, **resources):
225+
bucket = client.get_bucket(resources.get("bucket").name)
227226
metageneration = bucket.metageneration
228227
bucket.storage_class = "COLDLINE"
229228
if _preconditions:
@@ -233,7 +232,7 @@ def bucket_patch(client, _preconditions, **_):
233232

234233

235234
def bucket_update(client, _preconditions, **resources):
236-
bucket = client.get_bucket("bucket")
235+
bucket = client.get_bucket(resources.get("bucket").name)
237236
metageneration = bucket.metageneration
238237
bucket._properties = {"storageClass": "STANDARD"}
239238
if _preconditions:
@@ -252,6 +251,8 @@ def bucket_set_iam_policy(client, _preconditions, **resources):
252251
if _preconditions:
253252
bucket.set_iam_policy(policy)
254253
else:
254+
# IAM policies have no metageneration: clear ETag to avoid checking that it matches.
255+
policy.etag = None
255256
bucket.set_iam_policy(policy)
256257

257258

@@ -311,7 +312,7 @@ def blob_update(client, _preconditions, **resources):
311312
def bucket_copy_blob(client, _preconditions, **resources):
312313
object = resources.get("object")
313314
bucket = client.bucket(resources.get("bucket").name)
314-
destination = client.bucket("bucket")
315+
destination = client.create_bucket(uuid.uuid4().hex)
315316
if _preconditions:
316317
bucket.copy_blob(
317318
object, destination, new_name=uuid.uuid4().hex, if_generation_match=0
@@ -443,8 +444,8 @@ def blob_create_resumable_upload_session(client, _preconditions, **resources):
443444
"storage.buckets.getIamPolicy": [bucket_get_iam_policy],
444445
"storage.buckets.insert": [client_create_bucket, bucket_create],
445446
"storage.buckets.list": [client_list_buckets],
446-
"storage.buckets.lockRententionPolicy": [],
447-
"storage.buckets.testIamPermission": [bucket_test_iam_permissions],
447+
"storage.buckets.lockRetentionPolicy": [bucket_lock_retention_policy],
448+
"storage.buckets.testIamPermissions": [bucket_test_iam_permissions],
448449
"storage.notifications.delete": [notification_delete],
449450
"storage.notifications.get": [
450451
bucket_get_notification,
@@ -466,15 +467,14 @@ def blob_create_resumable_upload_session(client, _preconditions, **resources):
466467
bucket_list_blobs,
467468
bucket_delete,
468469
], # S1 end
469-
"storage.buckets.patch": [bucket_patch], # S2 start
470+
"storage.buckets.patch": [bucket_patch], # S2/S3 start
470471
"storage.buckets.setIamPolicy": [bucket_set_iam_policy],
471472
"storage.buckets.update": [bucket_update],
472473
"storage.objects.compose": [blob_compose],
473474
"storage.objects.copy": [bucket_copy_blob, bucket_rename_blob],
474475
"storage.objects.delete": [
475476
bucket_delete_blob,
476477
bucket_delete_blobs,
477-
bucket_delete,
478478
blob_delete,
479479
bucket_rename_blob,
480480
],
@@ -487,7 +487,7 @@ def blob_create_resumable_upload_session(client, _preconditions, **resources):
487487
],
488488
"storage.objects.patch": [blob_patch],
489489
"storage.objects.rewrite": [blob_rewrite, blob_update_storage_class],
490-
"storage.objects.update": [blob_update], # S2 end
490+
"storage.objects.update": [blob_update], # S2/S3 end
491491
}
492492

493493

0 commit comments

Comments
 (0)