Skip to content

Commit

Permalink
Merge pull request #605 from TejasC88/marker1
Browse files Browse the repository at this point in the history
List Versioned bucket with marker entry
  • Loading branch information
mergify[bot] authored Jul 3, 2024
2 parents 1ce1862 + ac8b06b commit cd3a51f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rgw/v2/tests/aws/configs/test_versioned_list_marker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# script: test_aws.py
# polarion-ID: CEPH-83572736
config:
user_count: 1
bucket_count: 1
objects_count: 3
user_remove: true
objects_size_range:
min: 1M
max: 3M
test_ops:
versioned_list_objects_marker: true
enable_version: true
33 changes: 33 additions & 0 deletions rgw/v2/tests/aws/reusable.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,36 @@ def get_object(bucket_name, object_name, end_point, ssl=None):
return get_response
except Exception as e:
raise AWSCommandExecError(message=str(e))


def list_objects(bucket_name, endpoint, marker=None, ssl=None):
"""
List all the objects in the bucket
Args:
bucket_name(str): Name of the bucket from which object needs to be listed
end_point(str): endpoint
marker(str): The key name from where the listing needs to start
ssl:
Return:
Returns details of every object in the bucket post the marker
"""
get_method = AWS(operation="list-objects")
if ssl:
ssl_param = "-s"
else:
ssl_param = " "
if marker:
marker_param = marker
else:
marker_param = " "
command = get_method.command(
params=[
f"--bucket {bucket_name} --marker {marker_param} --endpoint-url {endpoint}",
ssl_param,
]
)
try:
get_response = utils.exec_shell_cmd(command)
return get_response
except Exception as e:
raise AWSCommandExecError(message=str(e))
19 changes: 19 additions & 0 deletions rgw/v2/tests/aws/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
configs/test_aws_versioned_bucket_creation.yaml
configs/test_aws_regular_and_versioned_bucket_creation.yaml
configs/test_complete_multipart_upload_etag_not_empty.yaml
configs/test_versioned_list_marker.yaml
Operation:
Expand Down Expand Up @@ -117,6 +118,24 @@ def test_exec(config, ssh_con):
aws_reusable.get_object(bucket_name, object_name, endpoint)
log.info("Object download successful")

if config.test_ops.get("versioned_list_objects_marker", False):
log.info("Upload minimum of 3 objects onto a versioned bucket")
object_names = ["1.txt", "2.txt", "3.txt"]
for obj in object_names:
utils.exec_shell_cmd(f"fallocate -l 1K {obj}")
aws_reusable.put_object(bucket_name, obj, endpoint)
log.info("Object uplod successful")
log.info("List bucket with marker object 1.txt")
marker = "1.txt"
response = aws_reusable.list_objects(bucket_name, endpoint, marker)
res_json = json.loads(response)
log.info("The list should not have the marker object entry")
for obj in res_json["Contents"]:
log.info("Key :" + obj["Key"])
if obj["Key"] == "1.txt":
raise Exception(f"Marker is being listed in the list objects")
log.info("Marker entry not found")

if config.user_remove is True:
s3_reusable.remove_user(user)

Expand Down

0 comments on commit cd3a51f

Please sign in to comment.