GeezerVison is showing github.com — Method listing the contents of a bucket in FakeStorageRpc does not use bucket name · Issue #2902 · googleapis/google-cloud-java
Method listing the contents of a bucket in FakeStorageRpc does not use bucket name #2902Labels api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design. DescriptionHello,
The implementation of the method list(String bucket, Map<Option, ?> options) in FakeStorageRpc does not use bucket parameter to retrieve the files inside the bucket passed as parameter (see FakeStorageRpc.java). I'm using version 0.34.0, but it seems like in previous versions the behaviour was similar. Am I missing something ?
As a consequence, when using LocalStorageHelper (using FakeStorageRpc) for local testing purposes, the following code does not retrieve only the files in the bucket passed as parameter, but all files in all created buckets :
Storage storage = LocalStorageHelper.customOptions(true).getService()
[...] // creating dummy files in two separate buckets (b1 and b2)
storage.list("b1") // returns all files in b1 and b2
I double checked in the doc, listing the contents of a bucket is however defined as a supported operation. Activitychanged the title [-]Method listing the contents of a bucket in `FakeStorageRpc` does not use bucket name[/-] [+]Method listing the contents of a bucket in FakeStorageRpc does not use bucket name[/+] on Feb 14, 2018yihanzhen commented on Feb 14, 2018 Hi @norbjd ,
I believe the behavior is on purpose but the documentation does indeed cause confusion.
This class is used to help test CloudStorageFileSystem. The cloud storage file system has similar behaviors as a file system whose root directory is a bucket. In this sense, it become much less important for the FakeStorageRpc class to support functionality across multi buckets. Also, the fact that FakeStorageRpc does not support creating, getting, deleting and listing of buckets should be due to the same reason.
If you do want to add testings to storage itself locally, unit tests in google-cloud-storage using mocks might be helpful.
@pongad Please take a look and see if I am correct. That being the case, shall we adjust the documentation? pongad commented on Feb 14, 2018 I believe @hzyi-google is right (I'm not super familiar with this class myself). The FakeStorageRpc behaves as if it is bound to one bucket.
We should definitely document this. We can treat the ability to properly handle buckets as a feature request. norbjd commented on Feb 15, 2018 Thanks for your replies @hzyi-google @pongad
It's all clear now, in fact I was just confused because the bucket parameter is not used in the implementation of list method in FakeStorageRpc.
I looked to tests in google-cloud-storage as you suggest (BucketTest.java), but I am not able to used these tests "as-is", since many classes are package-private (for instance, I can't initialize a Blob).
Storage can be mocked, and in this example, mocking also Blob works, but I think it will be a good idea to implement method to test storage locally (with LocalStorageHelper) without any mocking.
Reacted by Jostein Gogstad yihanzhen commented on Feb 15, 2018 I believe you are right. Let's treat this as a feature request. yihanzhen commented on Feb 21, 2018 The feature request is added to the backlog. Feel free to add comments here.
MetadataMetadataapi: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design. DevelopmentNo branches or pull requestsIssue actions
|