Skip to content

Commit

Permalink
completely delete s3 bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Dec 22, 2024
1 parent 9490b37 commit 848fe13
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions load_tests/load_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,29 +470,12 @@ def delete_testing_data(session):
except Exception as e:
print(f"Error setting retention policy: {e}")

# Set retention period for s3 bucket
s3_client = session.client('s3')

# Configure the lifecycle rule
lifecycle_configuration = {
'Rules': [
{
'ID': "Delete after {} days".format(retention_days),
'Status': 'Enabled',
'Expiration': {'Days': retention_days},
'Prefix': ''
}
]
}
try:
# Apply the lifecycle configuration to the bucket
response = s3_client.put_bucket_lifecycle_configuration(
Bucket=S3_BUCKET_NAME,
LifecycleConfiguration=lifecycle_configuration
)
print(f"Lifecycle rule set successfully for S3 bucket. bucketName={S3_BUCKET_NAME} retentionDays={retention_days}", flush=True)
except Exception as e:
print(f"Error setting lifecycle rule: {e}")
# Empty s3 bucket
# lifecycle config cannot currently be used because the bucket name
# is reused between tests, so it must be completely deleted after each test.
s3 = session.resource('s3')
bucket = s3.Bucket(S3_BUCKET_NAME)
bucket.objects.all().delete()

def generate_daemonset_config(throughput):
daemonset_config_dict = {
Expand Down

0 comments on commit 848fe13

Please sign in to comment.