Skip to content

Commit

Permalink
add utility to clean out resources created by tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ11teen committed May 24, 2021
1 parent 226c4c7 commit fbd5360
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/cleanup_resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This is a helper utility to remove cloud resources created by running tests.
# Azure containers are not cleaned up as they can (and should) be set to auto-delete after a week.

if __name__ == "__main__":
import boto3
from google.cloud import storage

client = boto3.client("s3")
s3 = boto3.resource("s3")

buckets = client.list_buckets()

for bucket in buckets["Buckets"]:
s3_bucket = s3.Bucket(bucket["Name"])
s3_bucket.objects.all().delete()
s3_bucket.object_versions.delete()
s3_bucket.delete()
print(f"Deleted s3 bucket {bucket['Name']}")

storage_client = storage.Client()
buckets = storage_client.list_buckets()
for bucket in buckets:
bucket.delete(force=True)
print(f"Deleted gcp bucket {bucket.name}")

print(f"Not deleting Azure containers")

0 comments on commit fbd5360

Please sign in to comment.