Skip to content
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

test: Add test proxy implementation for ExecuteQuery api #2360

Merged
merged 3 commits into from
Oct 15, 2024

Conversation

jackdingilian
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)
  • Rollback plan is reviewed and LGTMed
  • All new data plane features have a completed end to end testing plan

Fixes #<issue_number_goes_here> ☕️

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

@jackdingilian jackdingilian requested review from a team as code owners September 27, 2024 17:29
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigtable Issues related to the googleapis/java-bigtable API. labels Sep 27, 2024
Patrick Wrobel and others added 2 commits September 27, 2024 13:32
Change-Id: I39f81dcf098b93eff79973648c57515e8908fde3
Change-Id: I53122fdf0301fb41d4f24881dc8de65d174dee35
@jackdingilian jackdingilian changed the title Add test proxy implementation for ExecuteQuery api test: Add test proxy implementation for ExecuteQuery api Sep 27, 2024
// CBT backend with the right options, however, the proxy itself is insecure
// so it is not recommended to use it with real credentials or outside testing
// contexts.
SecurityOptions security_options = 8;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these changes be in a separate PR? able to connect to production also sounds scary. Is there a way to avoid that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked to Patrick and removed this for now. We do want to use this for some internal tests, so we will put it in a separate PR

import java.util.concurrent.ExecutionException;
import org.threeten.bp.Instant;

public class ResultSetSerializer {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there existing client code for serialization and deserialization? This is a lot of code to maintain and test proxy should just be a thin layer that calls into the client

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is client code (within ResultSet) that handles deserializing protobuf Value messages to the corresponding java types. I agree this feels too 'heavy' for the testproxy but I think with the introduction of types it is somewhat unavoidable.

We want to validate that each client is converting to the relevant types correctly, to do so we need to do some form of roundtripping back to a shared format we can validate against. We reuse Value from the api here. I think no matter how we do it we need to do some conversion from java type back to some protobuf format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For existing java type -> Value serialization theres some existing code that does a subset of what we're doing here but it's not sufficient to cover what we need and Im not sure either is a great fit for replacing this.

  1. https://github.com/googleapis/java-bigtable/blob/main/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Value.java#L112 - This serializes some Values to proto but is only used for the types supported by aggregates right now. We would have no use for the additional SQL types there and we would need to have the aggregates apis reject those value types (https://github.com/googleapis/java-bigtable/blob/main/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/RowMutation.java#L231)

  2. https://github.com/googleapis/java-bigtable/blob/main/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/Statement.java#L194

Statement does this for the types of query params we support but it doesn't support all the types we need (no map or struct) and sets the Value.type field which we don't expect here (though I guess it would be ok)

Change-Id: Ibe2fb899f83744d4e38debc58379e9942350a83f
@jackdingilian jackdingilian merged commit be62968 into googleapis:main Oct 15, 2024
21 checks passed
@jackdingilian jackdingilian deleted the test-proxy-rebase branch October 15, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/java-bigtable API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants