From 62e6d604d16836f6ff76d6f8006462f3afe0dab5 Mon Sep 17 00:00:00 2001 From: Jane Zhu Date: Mon, 12 Feb 2024 16:01:28 -0500 Subject: [PATCH] add test case for delete-marker expiration with 'Days' tag Signed-off-by: Juan Zhu --- s3tests_boto3/functional/test_s3.py | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index f7dcfc29..75b167d6 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -8701,6 +8701,40 @@ def test_lifecycle_deletemarker_expiration(): assert len(total_init_versions) == 4 assert len(total_expire_versions) == 2 +@pytest.mark.lifecycle +@pytest.mark.lifecycle_expiration +@pytest.mark.fails_on_aws +@pytest.mark.fails_on_dbstore +def test_lifecycle_deletemarker_expiration_with_days_tag(): + bucket_name = get_new_bucket() + client = get_client() + check_configure_versioning_retry(bucket_name, "Enabled", "Enabled") + create_multiple_versions(client, bucket_name, "test1/a", 1) + client.delete_object(Bucket=bucket_name, Key="test1/a") + + rules=[{'ID': 'rule1', 'NoncurrentVersionExpiration': {'NoncurrentDays': 1}, 'Expiration': {'Days': 5}, 'Prefix': 'test1/', 'Status':'Enabled'}] + lifecycle = {'Rules': rules} + client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) + + lc_interval = get_lc_debug_interval() + + # Wait for first expiration (plus fudge to handle the timer window) + time.sleep(2*lc_interval) + + response = client.list_object_versions(Bucket=bucket_name) + versions = response['Versions'] if ('Versions' in response) else [] + delete_markers = response['DeleteMarkers'] if ('DeleteMarkers' in response) else [] + + assert len(versions) == 0 + assert len(delete_markers) == 1 + + time.sleep(4*lc_interval) + + response = client.list_object_versions(Bucket=bucket_name) + delete_markers = response['DeleteMarkers'] if ('DeleteMarkers' in response) else [] + + assert len(delete_markers) == 0 + @pytest.mark.lifecycle def test_lifecycle_set_multipart(): bucket_name = get_new_bucket()