From 64bdc3beec46bb5e786146629430fa54d417cd36 Mon Sep 17 00:00:00 2001 From: iraj465 Date: Tue, 13 Jul 2021 23:20:35 +0530 Subject: [PATCH 1/4] rgw/s3_boto3:Adds new delete_objects tests for checking key delete limit --- s3tests_boto3/functional/test_s3.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 51483cc..bc067d4 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -2027,6 +2027,22 @@ def test_multi_objectv2_delete(): response = client.list_objects_v2(Bucket=bucket_name) assert 'Contents' not in response +@attr(resource='object') +@attr(method='post') +@attr(operation='delete multiple objects has upper limit of 1000 keys') +@attr(assertion='fails 400') +def test_multi_object_delete_key_limit(): + key_names = [f"key-{i}" for i in range(1001)] + bucket_name = _create_objects(keys=key_names) + client = get_client() + + response = client.list_objects(Bucket=bucket_name) + eq(len(response['Contents']), 1001) + + objs_dict = _make_objs_dict(key_names=key_names) + e = assert_raises(ClientError,client.delete_objects,Bucket=bucket_name,Delete=objs_dict) + eq(e.response['Error']['Code'], 400) + @attr(resource='object') @attr(method='put') @attr(operation='write zero-byte key') From 20aa9aa071e704020c7fbf1b95f447cb7f33a763 Mon Sep 17 00:00:00 2001 From: iraj465 Date: Fri, 16 Jul 2021 03:07:21 +0530 Subject: [PATCH 2/4] chore:Bump the list-objects to paginator --- s3tests_boto3/functional/test_s3.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index bc067d4..9263cfd 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -2036,12 +2036,20 @@ def test_multi_object_delete_key_limit(): bucket_name = _create_objects(keys=key_names) client = get_client() + paginator = client.get_paginator('list_objects') + pages = paginator.paginate(Bucket=bucket_name) + numKeys = 0 + for page in pages: + numKeys += len(page['Contents']) + response = client.list_objects(Bucket=bucket_name) - eq(len(response['Contents']), 1001) + eq(numKeys, 1001) objs_dict = _make_objs_dict(key_names=key_names) e = assert_raises(ClientError,client.delete_objects,Bucket=bucket_name,Delete=objs_dict) - eq(e.response['Error']['Code'], 400) + + status, error_code = _get_status_and_error_code(e.response) + eq(status, 400) @attr(resource='object') @attr(method='put') From 459e3c870a8b9bed7a47f354390b1343acb32708 Mon Sep 17 00:00:00 2001 From: iraj465 Date: Fri, 16 Jul 2021 03:15:53 +0530 Subject: [PATCH 3/4] rgw/boto3_s3:Adds delete_objects key limit for list-objects-v2 --- s3tests_boto3/functional/test_s3.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 9263cfd..45a2d6f 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -2051,6 +2051,30 @@ def test_multi_object_delete_key_limit(): status, error_code = _get_status_and_error_code(e.response) eq(status, 400) +@attr(resource='object') +@attr(method='post') +@attr(operation='delete multiple objects has upper limit of 1000 keys with list-objects-v2') +@attr(assertion='fails 400') +def test_multi_objectv2_delete_key_limit(): + key_names = [f"key-{i}" for i in range(1001)] + bucket_name = _create_objects(keys=key_names) + client = get_client() + + paginator = client.get_paginator('list_objects_v2') + pages = paginator.paginate(Bucket=bucket_name) + numKeys = 0 + for page in pages: + numKeys += len(page['Contents']) + + response = client.list_objects(Bucket=bucket_name) + eq(numKeys, 1001) + + objs_dict = _make_objs_dict(key_names=key_names) + e = assert_raises(ClientError,client.delete_objects,Bucket=bucket_name,Delete=objs_dict) + + status, error_code = _get_status_and_error_code(e.response) + eq(status, 400) + @attr(resource='object') @attr(method='put') @attr(operation='write zero-byte key') From d2a7ed88f169fd4ea9864b7fc640ddfe5518a19c Mon Sep 17 00:00:00 2001 From: iraj465 Date: Fri, 16 Jul 2021 03:29:36 +0530 Subject: [PATCH 4/4] chore:Removes unused scaffolds --- s3tests_boto3/functional/test_s3.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 45a2d6f..6ec12e3 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -2041,13 +2041,10 @@ def test_multi_object_delete_key_limit(): numKeys = 0 for page in pages: numKeys += len(page['Contents']) - - response = client.list_objects(Bucket=bucket_name) eq(numKeys, 1001) objs_dict = _make_objs_dict(key_names=key_names) e = assert_raises(ClientError,client.delete_objects,Bucket=bucket_name,Delete=objs_dict) - status, error_code = _get_status_and_error_code(e.response) eq(status, 400) @@ -2065,13 +2062,10 @@ def test_multi_objectv2_delete_key_limit(): numKeys = 0 for page in pages: numKeys += len(page['Contents']) - - response = client.list_objects(Bucket=bucket_name) eq(numKeys, 1001) objs_dict = _make_objs_dict(key_names=key_names) e = assert_raises(ClientError,client.delete_objects,Bucket=bucket_name,Delete=objs_dict) - status, error_code = _get_status_and_error_code(e.response) eq(status, 400)