boto3: multi-object-delete tests use client.delete_objects()

when the tests were converted from boto2, they were rewritten as loops
over client.delete_object(). switch back to multi-delete

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 787dc6bd43)
This commit is contained in:
Casey Bodley 2023-03-13 13:00:25 -04:00
parent ac25acfddb
commit 67e6c5aecc

View file

@ -7459,20 +7459,17 @@ def test_versioning_multi_object_delete():
num_versions = 2 num_versions = 2
(version_ids, contents) = create_multiple_versions(client, bucket_name, key, num_versions) (version_ids, contents) = create_multiple_versions(client, bucket_name, key, num_versions)
assert len(version_ids) == 2
response = client.list_object_versions(Bucket=bucket_name) # delete both versions
versions = response['Versions'] objects = [{'Key': key, 'VersionId': v} for v in version_ids]
versions.reverse() client.delete_objects(Bucket=bucket_name, Delete={'Objects': objects})
for version in versions:
client.delete_object(Bucket=bucket_name, Key=key, VersionId=version['VersionId'])
response = client.list_object_versions(Bucket=bucket_name) response = client.list_object_versions(Bucket=bucket_name)
assert not 'Versions' in response assert not 'Versions' in response
# now remove again, should all succeed due to idempotency # now remove again, should all succeed due to idempotency
for version in versions: client.delete_objects(Bucket=bucket_name, Delete={'Objects': objects})
client.delete_object(Bucket=bucket_name, Key=key, VersionId=version['VersionId'])
response = client.list_object_versions(Bucket=bucket_name) response = client.list_object_versions(Bucket=bucket_name)
assert not 'Versions' in response assert not 'Versions' in response
@ -7487,33 +7484,24 @@ def test_versioning_multi_object_delete_with_marker():
num_versions = 2 num_versions = 2
(version_ids, contents) = create_multiple_versions(client, bucket_name, key, num_versions) (version_ids, contents) = create_multiple_versions(client, bucket_name, key, num_versions)
assert len(version_ids) == num_versions
objects = [{'Key': key, 'VersionId': v} for v in version_ids]
client.delete_object(Bucket=bucket_name, Key=key) # create a delete marker
response = client.list_object_versions(Bucket=bucket_name) response = client.delete_object(Bucket=bucket_name, Key=key)
versions = response['Versions'] assert response['DeleteMarker']
delete_markers = response['DeleteMarkers'] objects += [{'Key': key, 'VersionId': response['VersionId']}]
version_ids.append(delete_markers[0]['VersionId']) # delete all versions
assert len(version_ids) == 3 client.delete_objects(Bucket=bucket_name, Delete={'Objects': objects})
assert len(delete_markers) == 1
for version in versions:
client.delete_object(Bucket=bucket_name, Key=key, VersionId=version['VersionId'])
for delete_marker in delete_markers:
client.delete_object(Bucket=bucket_name, Key=key, VersionId=delete_marker['VersionId'])
response = client.list_object_versions(Bucket=bucket_name) response = client.list_object_versions(Bucket=bucket_name)
assert not 'Versions' in response assert not 'Versions' in response
assert not 'DeleteMarkers' in response assert not 'DeleteMarkers' in response
for version in versions:
client.delete_object(Bucket=bucket_name, Key=key, VersionId=version['VersionId'])
for delete_marker in delete_markers:
client.delete_object(Bucket=bucket_name, Key=key, VersionId=delete_marker['VersionId'])
# now remove again, should all succeed due to idempotency # now remove again, should all succeed due to idempotency
client.delete_objects(Bucket=bucket_name, Delete={'Objects': objects})
response = client.list_object_versions(Bucket=bucket_name) response = client.list_object_versions(Bucket=bucket_name)
assert not 'Versions' in response assert not 'Versions' in response
assert not 'DeleteMarkers' in response assert not 'DeleteMarkers' in response
@ -7527,8 +7515,11 @@ def test_versioning_multi_object_delete_with_marker_create():
key = 'key' key = 'key'
response = client.delete_object(Bucket=bucket_name, Key=key) # use delete_objects() to create a delete marker
delete_marker_version_id = response['VersionId'] response = client.delete_objects(Bucket=bucket_name, Delete={'Objects': [{'Key': key}]})
assert len(response['Deleted']) == 1
assert response['Deleted'][0]['DeleteMarker']
delete_marker_version_id = response['Deleted'][0]['DeleteMarkerVersionId']
response = client.list_object_versions(Bucket=bucket_name) response = client.list_object_versions(Bucket=bucket_name)
delete_markers = response['DeleteMarkers'] delete_markers = response['DeleteMarkers']