mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-22 09:29:43 +00:00
fix test_lifecycle_expiration_header_{put,head}
Primarily fixes the expiration header() verifier function check_lifecycle_expiration_header, but also cleans up prefix handling in setup_lifecycle_expiration(). Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This commit is contained in:
parent
ea9f07a2bf
commit
61804bcf91
1 changed files with 13 additions and 12 deletions
|
@ -9153,25 +9153,26 @@ def setup_lifecycle_expiration(client, bucket_name, rule_id, delta_days,
|
||||||
Bucket=bucket_name, LifecycleConfiguration=lifecycle)
|
Bucket=bucket_name, LifecycleConfiguration=lifecycle)
|
||||||
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
||||||
|
|
||||||
key = rule_prefix + '/foo'
|
key = rule_prefix + 'foo'
|
||||||
body = 'bar'
|
body = 'bar'
|
||||||
response = client.put_object(Bucket=bucket_name, Key=key, Body=body)
|
response = client.put_object(Bucket=bucket_name, Key=key, Body=body)
|
||||||
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
|
||||||
response = client.get_bucket_lifecycle_configuration(Bucket=bucket_name)
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def check_lifecycle_expiration_header(response, start_time, rule_id,
|
def check_lifecycle_expiration_header(response, start_time, rule_id,
|
||||||
delta_days):
|
delta_days):
|
||||||
print(response)
|
print(response)
|
||||||
#TODO: see how this can work
|
print(response['ResponseMetadata']['HTTPHeaders'])
|
||||||
#print(response['ResponseMetadata']['HTTPHeaders'])
|
|
||||||
#exp_header = response['ResponseMetadata']['HTTPHeaders']['x-amz-expiration']
|
|
||||||
#m = re.search(r'expiry-date="(.+)", rule-id="(.+)"', exp_header)
|
|
||||||
|
|
||||||
#expiration = datetime.datetime.strptime(m.group(1),
|
exp_header = response['ResponseMetadata']['HTTPHeaders']['x-amz-expiration']
|
||||||
# '%a %b %d %H:%M:%S %Y')
|
m = re.search(r'expiry-date="(.+)", rule-id="(.+)"', exp_header)
|
||||||
#eq((expiration - start_time).days, delta_days)
|
datestr = m.group(1)
|
||||||
#eq(m.group(2), rule_id)
|
exp_date = datetime.datetime.strptime(datestr, '%a, %d %b %Y %H:%M:%S %Z')
|
||||||
|
exp_diff = exp_date - start_time
|
||||||
|
rule_id = m.group(2)
|
||||||
|
|
||||||
|
eq(exp_diff.days, delta_days)
|
||||||
|
eq(m.group(2), rule_id)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -9200,9 +9201,9 @@ def test_lifecycle_expiration_header_head():
|
||||||
|
|
||||||
now = datetime.datetime.now(None)
|
now = datetime.datetime.now(None)
|
||||||
response = setup_lifecycle_expiration(
|
response = setup_lifecycle_expiration(
|
||||||
client, bucket_name, 'rule1', 1, 'days1')
|
client, bucket_name, 'rule1', 1, 'days1/')
|
||||||
|
|
||||||
key = 'days1/' + '/foo'
|
key = 'days1/' + 'foo'
|
||||||
|
|
||||||
# stat the object, check header
|
# stat the object, check header
|
||||||
response = client.head_object(Bucket=bucket_name, Key=key)
|
response = client.head_object(Bucket=bucket_name, Key=key)
|
||||||
|
|
Loading…
Reference in a new issue