From c9792cb9750618773a82cdadb9784a537f94b998 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Tue, 15 Sep 2020 09:57:00 -0400 Subject: [PATCH] add lifecycle expiration test mixing 2-tag filter w/versioning By design this test duplicates test_lifecycle_expiration_tags2, but enables object versioning on the bucket. The tests install a rule which requires -2- tags to be matched, and creates 2 objects, one matching only 1 of the required tags, the other matching both. Only the 2nd object should expire. Signed-off-by: Matt Benjamin --- s3tests_boto3/functional/test_s3.py | 46 ++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 2925b59..649cccc 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -9053,16 +9053,8 @@ def test_lifecycle_expiration_tags1(): eq(len(expire_objects), 0) -@attr(resource='bucket') -@attr(method='put') -@attr(operation='test lifecycle expiration with 2 tags') -@attr('lifecycle') -@attr('lifecycle_expiration') -@attr('fails_on_aws') -def test_lifecycle_expiration_tags2(): - bucket_name = get_new_bucket() - client = get_client() - +# factor out common setup code +def setup_lifecycle_tags2(client, bucket_name): tom_key = 'days1/tom' tom_tagset = {'TagSet': [{'Key': 'tom', 'Value': 'sawyer'}]} @@ -9116,6 +9108,40 @@ def test_lifecycle_expiration_tags2(): response = client.put_bucket_lifecycle_configuration( Bucket=bucket_name, LifecycleConfiguration=lifecycle_config) eq(response['ResponseMetadata']['HTTPStatusCode'], 200) + return response + +@attr(resource='bucket') +@attr(method='put') +@attr(operation='test lifecycle expiration with 2 tags') +@attr('lifecycle') +@attr('lifecycle_expiration') +@attr('fails_on_aws') +def test_lifecycle_expiration_tags2(): + bucket_name = get_new_bucket() + client = get_client() + + response = setup_lifecycle_tags2(client, bucket_name) + + time.sleep(28) + response = client.list_objects(Bucket=bucket_name) + expire1_objects = response['Contents'] + + eq(len(expire1_objects), 1) + +@attr(resource='bucket') +@attr(method='put') +@attr(operation='test lifecycle expiration with versioning and 2 tags') +@attr('lifecycle') +@attr('lifecycle_expiration') +@attr('fails_on_aws') +def test_lifecycle_expiration_versioned_tags2(): + bucket_name = get_new_bucket() + client = get_client() + + # mix in versioning + check_configure_versioning_retry(bucket_name, "Enabled", "Enabled") + + response = setup_lifecycle_tags2(client, bucket_name) time.sleep(28) response = client.list_objects(Bucket=bucket_name)