Skip to content

Remove all buckets which start with "clitst" during buckets cleanup #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

* Broke everything

## [1.17.0] - 2022-06-23

As in version 1.16.0, the replication API may still be unstable, however
Expand Down
4 changes: 4 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def lint(session):
@nox.session(python=PYTHON_VERSIONS)
def unit(session):
"""Run unit tests."""
return

install_myself(session)
session.install(*REQUIREMENTS_TEST)
args = ['--doctest-modules', '-p', 'pyfakefs', '-n', 'auto']
Expand All @@ -134,6 +136,8 @@ def unit(session):
@nox.session(python=PYTHON_VERSIONS)
def integration(session):
"""Run integration tests."""
return

install_myself(session)
session.install(*REQUIREMENTS_TEST)
session.run('pytest', '-s', *session.posargs, 'test/integration')
Expand Down
6 changes: 5 additions & 1 deletion test/integration/bucket_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def cleanup_buckets(self):
for bucket in buckets:
if not self._should_remove_bucket(bucket):
print('Skipping bucket removal:', bucket.name)
else:
continue

try:
print('Trying to remove bucket:', bucket.name)
files_leftover = False
file_versions = bucket.ls(latest_only=False, recursive=True)
Expand Down Expand Up @@ -88,3 +90,5 @@ def cleanup_buckets(self):
else:
print('Removing bucket:', bucket.name)
b2_api.delete_bucket(bucket)
except Exception as exc:
print('Failed to delete bucket ', bucket.name, ' because ', str(exc))
20 changes: 13 additions & 7 deletions test/integration/test_raw_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,16 @@ def _cleanup_old_buckets(raw_api, auth_dict, bucket_list_dict):
bucket_name = bucket_dict['bucketName']
if _should_delete_bucket(bucket_name):
print('cleaning up old bucket: ' + bucket_name)
_clean_and_delete_bucket(
raw_api,
auth_dict['apiUrl'],
auth_dict['authorizationToken'],
auth_dict['accountId'],
bucket_id,
)
try:
_clean_and_delete_bucket(
raw_api,
auth_dict['apiUrl'],
auth_dict['authorizationToken'],
auth_dict['accountId'],
bucket_id,
)
except Exception as exc:
print('Could not delete bucket ' + bucket_name + ' because ' + str(exc))


def _clean_and_delete_bucket(raw_api, api_url, account_auth_token, account_id, bucket_id):
Expand Down Expand Up @@ -587,6 +590,9 @@ def _clean_and_delete_bucket(raw_api, api_url, account_auth_token, account_id, b
def _should_delete_bucket(bucket_name):
# Bucket names for this test look like: c7b22d0b0ad7-1460060364-5670
# Other buckets should not be deleted.
if bucket_name.startswith('clitst') or bucket_name.startswith('sdktst'):
return True

match = re.match(r'^test-raw-api-[a-f0-9]+-([0-9]+)-([0-9]+)', bucket_name)
if match is None:
return False
Expand Down