Skip to content

Conversation

@sydney-munro
Copy link
Contributor

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the samples format.

@sydney-munro sydney-munro requested a review from a team as a code owner June 7, 2022 19:30
@sydney-munro sydney-munro marked this pull request as draft June 7, 2022 19:30
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/java-storage API. labels Jun 7, 2022
@sydney-munro sydney-munro changed the title Page impl feat: TransformPageDecorator Jun 7, 2022
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
Copy link
Collaborator

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.

Copy link
Contributor Author

@sydney-munro sydney-munro Jun 14, 2022

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.

Copy link
Contributor

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to

a project must be specified in a list buckets request.

If that is incorrect, we should request that the protos be updated.

Copy link
Contributor Author

@sydney-munro sydney-munro Jun 15, 2022

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

Copy link
Collaborator

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.

sydney-munro and others added 2 commits June 10, 2022 14:16
Co-authored-by: BenWhitehead <BenWhitehead@users.noreply.github.com>
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jun 14, 2022
@sydney-munro sydney-munro marked this pull request as ready for review June 14, 2022 23:31
Copy link
Contributor

@frankyn frankyn left a 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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Collaborator

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:

  1. Do we construct the request accurately
  2. 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to

a project must be specified in a list buckets request.

If that is incorrect, we should request that the protos be updated.

public class GrpcTransformPageDecoratorTest {

@Test
public void valueTranslationTest() {
Copy link
Collaborator

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:

  1. Do we construct the request accurately
  2. 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
Copy link
Collaborator

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.

@BenWhitehead BenWhitehead merged commit 0d564fc into feat/grpc-storage Jun 15, 2022
@BenWhitehead BenWhitehead deleted the page-impl branch June 15, 2022 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the googleapis/java-storage API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants