Enable lifecycle tests

Add an option to configure lc debug interval and adjust lifecycle
tests sleep as per the value set.

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
(cherry picked from commit 0f3f35ef01)
This commit is contained in:
Soumya Koduri 2021-12-17 16:55:49 +05:30 committed by Ali Maredia
parent 0f4f722f25
commit eb1717ff17
3 changed files with 63 additions and 19 deletions

View file

@ -41,6 +41,12 @@ secret_key = h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==
## replace with key id obtained when secret is created, or delete if KMS not tested ## replace with key id obtained when secret is created, or delete if KMS not tested
#kms_keyid = 01234567-89ab-cdef-0123-456789abcdef #kms_keyid = 01234567-89ab-cdef-0123-456789abcdef
## Storage classes
#storage_classes = "LUKEWARM, FROZEN"
## Lifecycle debug interval (default: 10)
#lc_debug_interval = 20
[s3 alt] [s3 alt]
# alt display_name set in vstart.sh # alt display_name set in vstart.sh
display_name = john.doe display_name = john.doe

View file

@ -198,6 +198,11 @@ def setup():
config.main_api_name = "" config.main_api_name = ""
pass pass
try:
config.lc_debug_interval = int(cfg.get('s3 main',"lc_debug_interval"))
except (configparser.NoSectionError, configparser.NoOptionError):
config.lc_debug_interval = 10
config.alt_access_key = cfg.get('s3 alt',"access_key") config.alt_access_key = cfg.get('s3 alt',"access_key")
config.alt_secret_key = cfg.get('s3 alt',"secret_key") config.alt_secret_key = cfg.get('s3 alt',"secret_key")
config.alt_display_name = cfg.get('s3 alt',"display_name") config.alt_display_name = cfg.get('s3 alt',"display_name")
@ -534,3 +539,6 @@ def get_token():
def get_realm_name(): def get_realm_name():
return config.webidentity_realm return config.webidentity_realm
def get_lc_debug_interval():
return config.lc_debug_interval

View file

@ -72,6 +72,7 @@ from . import (
get_secondary_kms_keyid, get_secondary_kms_keyid,
get_svc_client, get_svc_client,
nuke_prefixed_buckets, nuke_prefixed_buckets,
get_lc_debug_interval,
) )
@ -9032,21 +9033,23 @@ def test_lifecycle_expiration():
'keep2/bar', 'expire3/foo', 'expire3/bar']) 'keep2/bar', 'expire3/foo', 'expire3/bar'])
client = get_client() client = get_client()
rules=[{'ID': 'rule1', 'Expiration': {'Days': 1}, 'Prefix': 'expire1/', 'Status':'Enabled'}, rules=[{'ID': 'rule1', 'Expiration': {'Days': 1}, 'Prefix': 'expire1/', 'Status':'Enabled'},
{'ID': 'rule2', 'Expiration': {'Days': 4}, 'Prefix': 'expire3/', 'Status':'Enabled'}] {'ID': 'rule2', 'Expiration': {'Days': 5}, 'Prefix': 'expire3/', 'Status':'Enabled'}]
lifecycle = {'Rules': rules} lifecycle = {'Rules': rules}
client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle)
response = client.list_objects(Bucket=bucket_name) response = client.list_objects(Bucket=bucket_name)
init_objects = response['Contents'] init_objects = response['Contents']
time.sleep(28) lc_interval = get_lc_debug_interval()
time.sleep(3*lc_interval)
response = client.list_objects(Bucket=bucket_name) response = client.list_objects(Bucket=bucket_name)
expire1_objects = response['Contents'] expire1_objects = response['Contents']
time.sleep(10) time.sleep(lc_interval)
response = client.list_objects(Bucket=bucket_name) response = client.list_objects(Bucket=bucket_name)
keep2_objects = response['Contents'] keep2_objects = response['Contents']
time.sleep(20) time.sleep(3*lc_interval)
response = client.list_objects(Bucket=bucket_name) response = client.list_objects(Bucket=bucket_name)
expire3_objects = response['Contents'] expire3_objects = response['Contents']
@ -9067,21 +9070,23 @@ def test_lifecyclev2_expiration():
'keep2/bar', 'expire3/foo', 'expire3/bar']) 'keep2/bar', 'expire3/foo', 'expire3/bar'])
client = get_client() client = get_client()
rules=[{'ID': 'rule1', 'Expiration': {'Days': 1}, 'Prefix': 'expire1/', 'Status':'Enabled'}, rules=[{'ID': 'rule1', 'Expiration': {'Days': 1}, 'Prefix': 'expire1/', 'Status':'Enabled'},
{'ID': 'rule2', 'Expiration': {'Days': 4}, 'Prefix': 'expire3/', 'Status':'Enabled'}] {'ID': 'rule2', 'Expiration': {'Days': 5}, 'Prefix': 'expire3/', 'Status':'Enabled'}]
lifecycle = {'Rules': rules} lifecycle = {'Rules': rules}
client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle)
response = client.list_objects_v2(Bucket=bucket_name) response = client.list_objects_v2(Bucket=bucket_name)
init_objects = response['Contents'] init_objects = response['Contents']
time.sleep(28) lc_interval = get_lc_debug_interval()
time.sleep(3*lc_interval)
response = client.list_objects_v2(Bucket=bucket_name) response = client.list_objects_v2(Bucket=bucket_name)
expire1_objects = response['Contents'] expire1_objects = response['Contents']
time.sleep(10) time.sleep(lc_interval)
response = client.list_objects_v2(Bucket=bucket_name) response = client.list_objects_v2(Bucket=bucket_name)
keep2_objects = response['Contents'] keep2_objects = response['Contents']
time.sleep(20) time.sleep(3*lc_interval)
response = client.list_objects_v2(Bucket=bucket_name) response = client.list_objects_v2(Bucket=bucket_name)
expire3_objects = response['Contents'] expire3_objects = response['Contents']
@ -9106,7 +9111,10 @@ def test_lifecycle_expiration_versioning_enabled():
rules=[{'ID': 'rule1', 'Expiration': {'Days': 1}, 'Prefix': 'test1/', 'Status':'Enabled'}] rules=[{'ID': 'rule1', 'Expiration': {'Days': 1}, 'Prefix': 'test1/', 'Status':'Enabled'}]
lifecycle = {'Rules': rules} lifecycle = {'Rules': rules}
client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle)
time.sleep(30)
lc_interval = get_lc_debug_interval()
time.sleep(3*lc_interval)
response = client.list_object_versions(Bucket=bucket_name) response = client.list_object_versions(Bucket=bucket_name)
versions = response['Versions'] versions = response['Versions']
@ -9157,7 +9165,9 @@ def test_lifecycle_expiration_tags1():
Bucket=bucket_name, LifecycleConfiguration=lifecycle_config) Bucket=bucket_name, LifecycleConfiguration=lifecycle_config)
eq(response['ResponseMetadata']['HTTPStatusCode'], 200) eq(response['ResponseMetadata']['HTTPStatusCode'], 200)
time.sleep(28) lc_interval = get_lc_debug_interval()
time.sleep(3*lc_interval)
try: try:
expire_objects = response['Contents'] expire_objects = response['Contents']
@ -9235,7 +9245,9 @@ def test_lifecycle_expiration_tags2():
response = setup_lifecycle_tags2(client, bucket_name) response = setup_lifecycle_tags2(client, bucket_name)
time.sleep(28) lc_interval = get_lc_debug_interval()
time.sleep(3*lc_interval)
response = client.list_objects(Bucket=bucket_name) response = client.list_objects(Bucket=bucket_name)
expire1_objects = response['Contents'] expire1_objects = response['Contents']
@ -9256,7 +9268,9 @@ def test_lifecycle_expiration_versioned_tags2():
response = setup_lifecycle_tags2(client, bucket_name) response = setup_lifecycle_tags2(client, bucket_name)
time.sleep(28) lc_interval = get_lc_debug_interval()
time.sleep(3*lc_interval)
response = client.list_objects(Bucket=bucket_name) response = client.list_objects(Bucket=bucket_name)
expire1_objects = response['Contents'] expire1_objects = response['Contents']
@ -9327,14 +9341,16 @@ def test_lifecycle_expiration_noncur_tags1():
# noncurrent version expiration at 4 "days" # noncurrent version expiration at 4 "days"
response = setup_lifecycle_noncur_tags(client, bucket_name, 4) response = setup_lifecycle_noncur_tags(client, bucket_name, 4)
lc_interval = get_lc_debug_interval()
num_objs = verify_lifecycle_expiration_noncur_tags( num_objs = verify_lifecycle_expiration_noncur_tags(
client, bucket_name, 20) client, bucket_name, 2*lc_interval)
# at T+20, 10 objects should exist # at T+20, 10 objects should exist
eq(num_objs, 10) eq(num_objs, 10)
num_objs = verify_lifecycle_expiration_noncur_tags( num_objs = verify_lifecycle_expiration_noncur_tags(
client, bucket_name, 40) client, bucket_name, 5*lc_interval)
# at T+60, only the current object version should exist # at T+60, only the current object version should exist
eq(num_objs, 1) eq(num_objs, 1)
@ -9448,7 +9464,10 @@ def test_lifecycle_expiration_date():
response = client.list_objects(Bucket=bucket_name) response = client.list_objects(Bucket=bucket_name)
init_objects = response['Contents'] init_objects = response['Contents']
time.sleep(20) lc_interval = get_lc_debug_interval()
# Wait for first expiration (plus fudge to handle the timer window)
time.sleep(3*lc_interval)
response = client.list_objects(Bucket=bucket_name) response = client.list_objects(Bucket=bucket_name)
expire_objects = response['Contents'] expire_objects = response['Contents']
@ -9578,7 +9597,11 @@ def test_lifecycle_noncur_expiration():
rules=[{'ID': 'rule1', 'NoncurrentVersionExpiration': {'NoncurrentDays': 2}, 'Prefix': 'test1/', 'Status':'Enabled'}] rules=[{'ID': 'rule1', 'NoncurrentVersionExpiration': {'NoncurrentDays': 2}, 'Prefix': 'test1/', 'Status':'Enabled'}]
lifecycle = {'Rules': rules} lifecycle = {'Rules': rules}
client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle)
time.sleep(50)
lc_interval = get_lc_debug_interval()
# Wait for first expiration (plus fudge to handle the timer window)
time.sleep(5*lc_interval)
response = client.list_object_versions(Bucket=bucket_name) response = client.list_object_versions(Bucket=bucket_name)
expire_versions = response['Versions'] expire_versions = response['Versions']
@ -9644,7 +9667,11 @@ def test_lifecycle_deletemarker_expiration():
rules=[{'ID': 'rule1', 'NoncurrentVersionExpiration': {'NoncurrentDays': 1}, 'Expiration': {'ExpiredObjectDeleteMarker': True}, 'Prefix': 'test1/', 'Status':'Enabled'}] rules=[{'ID': 'rule1', 'NoncurrentVersionExpiration': {'NoncurrentDays': 1}, 'Expiration': {'ExpiredObjectDeleteMarker': True}, 'Prefix': 'test1/', 'Status':'Enabled'}]
lifecycle = {'Rules': rules} lifecycle = {'Rules': rules}
client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle)
time.sleep(50)
lc_interval = get_lc_debug_interval()
# Wait for first expiration (plus fudge to handle the timer window)
time.sleep(5*lc_interval)
response = client.list_object_versions(Bucket=bucket_name) response = client.list_object_versions(Bucket=bucket_name)
init_versions = response['Versions'] init_versions = response['Versions']
@ -9697,7 +9724,11 @@ def test_lifecycle_multipart_expiration():
] ]
lifecycle = {'Rules': rules} lifecycle = {'Rules': rules}
response = client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) response = client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle)
time.sleep(50)
lc_interval = get_lc_debug_interval()
# Wait for first expiration (plus fudge to handle the timer window)
time.sleep(5*lc_interval)
response = client.list_multipart_uploads(Bucket=bucket_name) response = client.list_multipart_uploads(Bucket=bucket_name)
expired_uploads = response['Uploads'] expired_uploads = response['Uploads']
@ -9731,7 +9762,6 @@ def _test_encryption_sse_customer_write(file_size):
body = _get_body(response) body = _get_body(response)
eq(body, data) eq(body, data)
@attr(resource='object') @attr(resource='object')
@attr(method='put') @attr(method='put')
@attr(operation='Test SSE-C encrypted transfer 1 byte') @attr(operation='Test SSE-C encrypted transfer 1 byte')