@@ -456,7 +456,7 @@ def publish_fluent_config_s3(input_logger):
456
456
# We set retention/expiration policies so that tests do not interfere with each other, and so that
457
457
# we can debug and run validation manually if necessary.
458
458
def delete_testing_data (session ):
459
- print ("Setting auto-delete policies for CW log groups and S3 buckets " )
459
+ print ("Setting auto-delete policies for CW log groups, deleting S3 bucket " )
460
460
retention_days = 5
461
461
462
462
logs_client = session .client ('logs' )
@@ -470,29 +470,13 @@ def delete_testing_data(session):
470
470
except Exception as e :
471
471
print (f"Error setting retention policy: { e } " )
472
472
473
- # Set retention period for s3 bucket
474
- s3_client = session .client ('s3' )
475
-
476
- # Configure the lifecycle rule
477
- lifecycle_configuration = {
478
- 'Rules' : [
479
- {
480
- 'ID' : "Delete after {} days" .format (retention_days ),
481
- 'Status' : 'Enabled' ,
482
- 'Expiration' : {'Days' : retention_days },
483
- 'Prefix' : ''
484
- }
485
- ]
486
- }
487
- try :
488
- # Apply the lifecycle configuration to the bucket
489
- response = s3_client .put_bucket_lifecycle_configuration (
490
- Bucket = S3_BUCKET_NAME ,
491
- LifecycleConfiguration = lifecycle_configuration
492
- )
493
- print (f"Lifecycle rule set successfully for S3 bucket. bucketName={ S3_BUCKET_NAME } retentionDays={ retention_days } " , flush = True )
494
- except Exception as e :
495
- print (f"Error setting lifecycle rule: { e } " )
473
+ # Empty s3 bucket
474
+ # lifecycle config cannot currently be used because the bucket name
475
+ # is reused between tests, so it must be completely deleted after each test.
476
+ s3 = session .resource ('s3' )
477
+ bucket = s3 .Bucket (S3_BUCKET_NAME )
478
+ print (f"Deleting all objects in s3 bucket: { S3_BUCKET_NAME } " )
479
+ bucket .objects .all ().delete ()
496
480
497
481
def generate_daemonset_config (throughput ):
498
482
daemonset_config_dict = {
0 commit comments