-
Notifications
You must be signed in to change notification settings - Fork 89
feat: TransformPageDecorator #1439
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
Conversation
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
Outdated
Show resolved
Hide resolved
| ifNonNull((String) optionsMap.get(StorageRpc.Option.PAGE_TOKEN), builder::setPageToken); | ||
| ifNonNull((String) optionsMap.get(StorageRpc.Option.PREFIX), builder::setPrefix); | ||
| // TODO(sydmunro): StorageRpc.Option.Fields | ||
| // TODO(sydmunro): User Project |
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.
According to the protos, project is required to be able to list buckets.
We'll probably need to do a similar thing here as for listHmacKeys with the fallback to options.
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.
User project is different though because it is used for requester pays to refer to the billing project, correct? the required field that you are referring to is the projectid right?
I added the project I am just making sure this comment was for project and not user project.
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.
+1 to @sydney-munro, you're right, UserProject is meant to assign operation cost to a specified project. It's usually used with RequesterPays but may still be used even if requesterPays is not enabled.
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.
According to
java-storage/proto-google-cloud-storage-v2/src/main/proto/google/storage/v2/storage.proto
Line 336 in 8a7755c
| string parent = 1 [ |
If that is incorrect, we should request that the protos be updated.
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.
yeah, what I am referring to in this comment is that UserProject
https://github.com/googleapis/java-storage/blob/main/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java#L1015-L1017
is a BucketListOption but not supported by the proto. The project parent field for ListBucketsRequest should be fixed now with L263-L265
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.
Ahh, missed that in the diff-diffs.
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
Outdated
Show resolved
Hide resolved
Co-authored-by: BenWhitehead <BenWhitehead@users.noreply.github.com>
frankyn
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.
Overall LGTM, just have one q on property tests
| public class GrpcTransformPageDecoratorTest { | ||
|
|
||
| @Test | ||
| public void valueTranslationTest() { |
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.
Will you be adding a property based test in a follow-up PR?
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.
I can do that, I wanted to make a general test because I felt a property test would kind of just be duplicating the conversion tests, the only difference being wrapping the BlobInfo, BucketInfo etc in a Page but the translation logic is the same. Do you think there would be additional value to doing this?
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.
I was thinking you could use property based testing to generate the list of object names of different sizes (for initial Values, pageOne, pageTwo) then make then the test could do the rest that you're doing in this test. That was my only point in this 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.
This test is specifically for the PageDecorator.
As far as testing the list calls themselves is concerned, I think those can be added in a later PR once we are also testing with the testbench.
Given that pages all have the same "shape" the things we care about testing there are:
- Do we construct the request accurately
- Do we wire in the correct decoder to the constructed TransformingPageDecorator
The decoder wiring part is pretty much verified for us at compile type via type checking.
The request construction part is probably more of a unit test, given how unfriendly the *Options stuff is.
google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageImpl.java
Outdated
Show resolved
Hide resolved
| ifNonNull((String) optionsMap.get(StorageRpc.Option.PAGE_TOKEN), builder::setPageToken); | ||
| ifNonNull((String) optionsMap.get(StorageRpc.Option.PREFIX), builder::setPrefix); | ||
| // TODO(sydmunro): StorageRpc.Option.Fields | ||
| // TODO(sydmunro): User Project |
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.
According to
java-storage/proto-google-cloud-storage-v2/src/main/proto/google/storage/v2/storage.proto
Line 336 in 8a7755c
| string parent = 1 [ |
If that is incorrect, we should request that the protos be updated.
google-cloud-storage/src/test/java/com/google/cloud/storage/GrpcTransformPageDecoratorTest.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/test/java/com/google/cloud/storage/GrpcTransformPageDecoratorTest.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/test/java/com/google/cloud/storage/GrpcTransformPageDecoratorTest.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/test/java/com/google/cloud/storage/GrpcTransformPageDecoratorTest.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/test/java/com/google/cloud/storage/GrpcTransformPageDecoratorTest.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/test/java/com/google/cloud/storage/GrpcTransformPageDecoratorTest.java
Outdated
Show resolved
Hide resolved
google-cloud-storage/src/test/java/com/google/cloud/storage/GrpcTransformPageDecoratorTest.java
Outdated
Show resolved
Hide resolved
| public class GrpcTransformPageDecoratorTest { | ||
|
|
||
| @Test | ||
| public void valueTranslationTest() { |
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 specifically for the PageDecorator.
As far as testing the list calls themselves is concerned, I think those can be added in a later PR once we are also testing with the testbench.
Given that pages all have the same "shape" the things we care about testing there are:
- Do we construct the request accurately
- Do we wire in the correct decoder to the constructed TransformingPageDecorator
The decoder wiring part is pretty much verified for us at compile type via type checking.
The request construction part is probably more of a unit test, given how unfriendly the *Options stuff is.
| ifNonNull((String) optionsMap.get(StorageRpc.Option.PAGE_TOKEN), builder::setPageToken); | ||
| ifNonNull((String) optionsMap.get(StorageRpc.Option.PREFIX), builder::setPrefix); | ||
| // TODO(sydmunro): StorageRpc.Option.Fields | ||
| // TODO(sydmunro): User Project |
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.
Ahh, missed that in the diff-diffs.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> ☕️
If you write sample code, please follow the samples format.