red-hat-storage / noobaa-sa-ci

CI for noobaa standalone product
MIT License
0 stars 4 forks source link

The `bucket_manager` fixture teardown deletes buckets that weren't created in the testing session #9

Open sagihirshfeld opened 9 months ago

sagihirshfeld commented 9 months ago
@pytest.fixture
def bucket_manager(request):
    bucket_manager = BucketManager()

    def bucket_cleanup():
        for bucket in bucket_manager.list():
            bucket_manager.delete(bucket)

    request.addfinalizer(bucket_cleanup)
    return bucket_manager

Since bucket_manager.list() lists all the buckets on the NSFS server, this fixture deletes all of them on teardown. This is somewhat of an unexpected result of running the CI.

From from QE perspective, it's merely inconvenient since we can lose buckets that we might rely on for manual testing, but if users outside of QE use this CI they might accidentally lose data after using the CI.

This can be easily fixed by keeping track of the created and deleted buckets in BucketManager in a list or a dict.