Skip to content

Commit da94e3e

Browse files
committed
completely delete s3 bucket
1 parent 9490b37 commit da94e3e

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

Diff for: load_tests/load_test.py

+8-24
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def publish_fluent_config_s3(input_logger):
456456
# We set retention/expiration policies so that tests do not interfere with each other, and so that
457457
# we can debug and run validation manually if necessary.
458458
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")
460460
retention_days = 5
461461

462462
logs_client = session.client('logs')
@@ -470,29 +470,13 @@ def delete_testing_data(session):
470470
except Exception as e:
471471
print(f"Error setting retention policy: {e}")
472472

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()
496480

497481
def generate_daemonset_config(throughput):
498482
daemonset_config_dict = {

0 commit comments

Comments
 (0)