-
Notifications
You must be signed in to change notification settings - Fork 0
samples(storage): add samples and test cases for soft delete objects #13
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
base: main
Are you sure you want to change the base?
Conversation
amrik-mahal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
|
/Gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds new samples and corresponding tests for Google Cloud Storage soft-delete features: listing soft-deleted objects, listing soft-deleted versions of an object, and restoring a soft-deleted object. The new samples and helper methods in StorageFixture are well-implemented. However, I've found critical issues in the test setup for all three new test classes. The tests create buckets without enabling the soft-delete feature (and in one case, without versioning), which is necessary for the features under test to work as expected. I've provided suggestions to correct the bucket creation in each test file.
| ListSoftDeletedObjectsSample listSoftDeletedObjects = new ListSoftDeletedObjectsSample(); | ||
| UploadObjectFromMemorySample uploadObjectFromMemory = new UploadObjectFromMemorySample(); | ||
| var bucketName = _fixture.GenerateBucketName(); | ||
| _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: false, registerForDeletion: true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is for listing soft-deleted objects, but the bucket is created with soft-delete disabled (softDelete: false). To ensure the test correctly validates the soft-delete functionality, you should enable it when creating the bucket.
_fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true, registerForDeletion: true);| RestoreSoftDeletedObjectSample restoreSoftDeletedObjectSample = new RestoreSoftDeletedObjectSample(); | ||
| GetMetadataSample getMetadataSample = new GetMetadataSample(); | ||
| var bucketName = _fixture.GenerateBucketName(); | ||
| _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: false, registerForDeletion: true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is for listing soft-deleted versions of an object. For this to work correctly, both versioning and soft-delete must be enabled on the bucket. Currently, both are disabled in the bucket creation step (multiVersion: false, softDelete: false).
_fixture.CreateBucket(bucketName, multiVersion: true, softDelete: true, registerForDeletion: true);| UploadObjectFromMemorySample uploadObjectFromMemory = new UploadObjectFromMemorySample(); | ||
| GetMetadataSample getMetadataSample = new GetMetadataSample(); | ||
| var bucketName = _fixture.GenerateBucketName(); | ||
| _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: false, registerForDeletion: true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gemini-code-assist I think soft delete object and bucket are a different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that soft-delete applies to objects, but the ability to soft-delete objects is a bucket-level configuration. If a bucket does not have soft-delete enabled, then deleting an object within that bucket will result in a permanent deletion, not a soft-delete.
For the RestoreSoftDeletedObjectTest to effectively test the restoration of a soft-deleted object, the bucket used in the test must first be configured to support soft-deletion. This ensures that when an object is 'deleted' in the test, it is indeed soft-deleted and thus available for restoration. The current softDelete: false setting would lead to permanent deletion, making the restoration step impossible to test correctly.
Therefore, the suggestion to set softDelete: true is crucial for the test's validity.
| _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: false, registerForDeletion: true); | |
| _fixture.CreateBucket(bucketName, multiVersion: false, softDelete: true, registerForDeletion: true); |
Add samples and test cases for soft delete objects as follows:-