Skip to content

Commit edee38e

Browse files
agoncharov-reefmjurbanski-reef
authored andcommitted
Continue if removal failed
1 parent f05df2b commit edee38e

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

test/integration/bucket_cleaner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def cleanup_buckets(self):
4848
for bucket in buckets:
4949
if not self._should_remove_bucket(bucket):
5050
print('Skipping bucket removal:', bucket.name)
51-
else:
51+
continue
52+
53+
try:
5254
print('Trying to remove bucket:', bucket.name)
5355
files_leftover = False
5456
file_versions = bucket.ls(latest_only=False, recursive=True)
@@ -88,3 +90,5 @@ def cleanup_buckets(self):
8890
else:
8991
print('Removing bucket:', bucket.name)
9092
b2_api.delete_bucket(bucket)
93+
except Exception as exc:
94+
print('Failed to delete bucket ', bucket.name, ' because ', str(exc))

test/integration/test_raw_api.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,16 @@ def _cleanup_old_buckets(raw_api, auth_dict, bucket_list_dict):
545545
bucket_name = bucket_dict['bucketName']
546546
if _should_delete_bucket(bucket_name):
547547
print('cleaning up old bucket: ' + bucket_name)
548-
_clean_and_delete_bucket(
549-
raw_api,
550-
auth_dict['apiUrl'],
551-
auth_dict['authorizationToken'],
552-
auth_dict['accountId'],
553-
bucket_id,
554-
)
548+
try:
549+
_clean_and_delete_bucket(
550+
raw_api,
551+
auth_dict['apiUrl'],
552+
auth_dict['authorizationToken'],
553+
auth_dict['accountId'],
554+
bucket_id,
555+
)
556+
except Exception as exc:
557+
print('Could not delete bucket ' + bucket_name + ' because ' + str(exc))
555558

556559

557560
def _clean_and_delete_bucket(raw_api, api_url, account_auth_token, account_id, bucket_id):
@@ -587,7 +590,7 @@ def _clean_and_delete_bucket(raw_api, api_url, account_auth_token, account_id, b
587590
def _should_delete_bucket(bucket_name):
588591
# Bucket names for this test look like: c7b22d0b0ad7-1460060364-5670
589592
# Other buckets should not be deleted.
590-
if bucket_name.startswith('clitst'):
593+
if bucket_name.startswith('clitst') or bucket_name.startswith('sdktst'):
591594
return True
592595

593596
match = re.match(r'^test-raw-api-[a-f0-9]+-([0-9]+)-([0-9]+)', bucket_name)

0 commit comments

Comments
 (0)