Skip to content

Commit

Permalink
update test_locking
Browse files Browse the repository at this point in the history
Signed-off-by: fbalak <[email protected]>
  • Loading branch information
fbalak committed Nov 14, 2023
1 parent b675b91 commit 68107f1
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tests/manage/mcg/test_object_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test_versioning_properties_and_deletion(self, bucket_factory, mcg_obj_sessio
assert versioning_info["Status"] == "Enabled"
object_info = bucket.s3client.list_object_versions(Bucket=bucket.name)
logger.info(f"object info of bucket {bucket.name}: {object_info}")
assert object_info["Versions"][0]["IsLatest"] == False
assert object_info["Versions"][0]["IsLatest"] is False
assert len(object_info["DeleteMarkers"]) == 1
assert len(object_info["Versions"]) == 8

Expand All @@ -270,7 +270,7 @@ def test_versioning_properties_and_deletion(self, bucket_factory, mcg_obj_sessio
object_info = bucket.s3client.list_object_versions(Bucket=bucket.name)
logger.info(f"object info of bucket {bucket.name}: {object_info}")
for version in object_info["Versions"]:
assert version["IsLatest"] == False
assert version["IsLatest"] is False
assert len(object_info["DeleteMarkers"]) == 6

logger.info("Deleting all object versions and delete markers")
Expand Down Expand Up @@ -396,7 +396,7 @@ def test_locking(self, bucket_factory, mcg_obj_session, retention):
"""
s3_obj = mcg_obj_session
bucket = bucket_factory(interface="S3", versioning=True)[0]
bucket = bucket_factory(interface="S3", versioning=True, object_lock=True)[0]
logger.info(f"Bucket {bucket.name} created")
filename = f"file-{uuid4().hex}"
with open(filename, "wb") as f:
Expand All @@ -405,6 +405,25 @@ def test_locking(self, bucket_factory, mcg_obj_session, retention):
logger.info(f"Putting file {filename} into bucket {bucket.name}")
s3_put_object(s3_obj, bucket.name, filename, filename)

logger.info(
f"Setting object lock with with retention policy {retention} to {bucket.name}"
)
policy_response = bucket.s3client.put_object_lock_configuration(
Bucket=bucket.name,
ObjectLockConfiguration={
"ObjectLockEnabled": "Enabled",
"Rule": {"DefaultRetention": {"Mode": retention, "Days": 12}},
},
)
logger.debug(f"policy response: {policy_response}")
object_info = bucket.s3client.list_object_versions(Bucket=bucket.name)
logger.info(f"object info of bucket {bucket.name}: {object_info}")
put_object_response = s3_put_object(s3_obj, bucket.name, filename, filename)
logger.info(f"put object response: {put_object_response}")

object_info = bucket.s3client.list_object_versions(Bucket=bucket.name)
logger.info(f"object info of bucket {bucket.name}: {object_info}")

@tier2
def test_version_restore(self, bucket_factory, mcg_obj_session):
"""
Expand Down

0 comments on commit 68107f1

Please sign in to comment.