mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-28 09:31:38 +00:00
add tests for lifecycle expiration w/1 and 2 object tags
Note that the 1-tag case contains a filter prefix--which exposes an apparent bug parsing Filter when it contains a Prefix element and a single Tag element (without And). Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This commit is contained in:
parent
c2b59fb714
commit
e79dffa731
1 changed files with 122 additions and 0 deletions
|
@ -9001,6 +9001,128 @@ def test_lifecycle_expiration_versioning_enabled():
|
|||
eq(len(versions), 1)
|
||||
eq(len(delete_markers), 1)
|
||||
|
||||
@attr(resource='bucket')
|
||||
@attr(method='put')
|
||||
@attr(operation='test lifecycle expiration with 1 tag')
|
||||
@attr('lifecycle')
|
||||
@attr('lifecycle_expiration')
|
||||
@attr('fails_on_aws')
|
||||
def test_lifecycle_expiration_tags1():
|
||||
bucket_name = get_new_bucket()
|
||||
client = get_client()
|
||||
|
||||
tom_key = 'days1/tom'
|
||||
tom_tagset = {'TagSet':
|
||||
[{'Key': 'tom', 'Value': 'sawyer'}]}
|
||||
|
||||
client.put_object(Bucket=bucket_name, Key=tom_key, Body='tom_body')
|
||||
|
||||
response = client.put_object_tagging(Bucket=bucket_name, Key=tom_key,
|
||||
Tagging=tom_tagset)
|
||||
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
||||
|
||||
lifecycle_config = {
|
||||
'Rules': [
|
||||
{
|
||||
'Expiration': {
|
||||
'Days': 1,
|
||||
},
|
||||
'ID': 'rule_tag1',
|
||||
'Filter': {
|
||||
'Prefix': 'days1/',
|
||||
'Tag': {
|
||||
'Key': 'tom',
|
||||
'Value': 'sawyer'
|
||||
},
|
||||
},
|
||||
'Status': 'Enabled',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
response = client.put_bucket_lifecycle_configuration(
|
||||
Bucket=bucket_name, LifecycleConfiguration=lifecycle_config)
|
||||
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
||||
|
||||
time.sleep(28)
|
||||
|
||||
try:
|
||||
expire_objects = response['Contents']
|
||||
except KeyError:
|
||||
expire_objects = []
|
||||
|
||||
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()
|
||||
|
||||
tom_key = 'days1/tom'
|
||||
tom_tagset = {'TagSet':
|
||||
[{'Key': 'tom', 'Value': 'sawyer'}]}
|
||||
|
||||
client.put_object(Bucket=bucket_name, Key=tom_key, Body='tom_body')
|
||||
|
||||
response = client.put_object_tagging(Bucket=bucket_name, Key=tom_key,
|
||||
Tagging=tom_tagset)
|
||||
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
||||
|
||||
huck_key = 'days1/huck'
|
||||
huck_tagset = {
|
||||
'TagSet':
|
||||
[{'Key': 'tom', 'Value': 'sawyer'},
|
||||
{'Key': 'huck', 'Value': 'finn'}]}
|
||||
|
||||
client.put_object(Bucket=bucket_name, Key=huck_key, Body='huck_body')
|
||||
|
||||
response = client.put_object_tagging(Bucket=bucket_name, Key=huck_key,
|
||||
Tagging=huck_tagset)
|
||||
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
||||
|
||||
lifecycle_config = {
|
||||
'Rules': [
|
||||
{
|
||||
'Expiration': {
|
||||
'Days': 1,
|
||||
},
|
||||
'ID': 'rule_tag1',
|
||||
'Filter': {
|
||||
'Prefix': 'days1/',
|
||||
'Tag': {
|
||||
'Key': 'tom',
|
||||
'Value': 'sawyer'
|
||||
},
|
||||
'And': {
|
||||
'Prefix': 'days1',
|
||||
'Tags': [
|
||||
{
|
||||
'Key': 'huck',
|
||||
'Value': 'finn'
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
'Status': 'Enabled',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
response = client.put_bucket_lifecycle_configuration(
|
||||
Bucket=bucket_name, LifecycleConfiguration=lifecycle_config)
|
||||
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
||||
|
||||
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='id too long in lifecycle rule')
|
||||
|
|
Loading…
Reference in a new issue