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

Adds new conformance/client module #182

Merged
merged 3 commits into from
Jan 3, 2024
Merged

Adds new conformance/client module #182

merged 3 commits into from
Jan 3, 2024

Conversation

jhump
Copy link
Member

@jhump jhump commented Dec 20, 2023

This PR is purely additive. It does not make any changes to the existing container/crosstest-based conformance test targets. It's just starting to add code to eventually replace all of that.

So the old conformance tests are in these modules:

  • conformance/common
  • conformance/google-java
  • conformance/google-javalite

The new ones are in these:

  • conformance/client
  • conformance/client/google-java
  • conformance/client/google-javalite

This doesn't include any actual logic yet. This was a rather substantial PR already, so I figured it would be good to get this approach reviewed before fleshing out the conformance client handler logic (which are all stubbed out in Client.kt with TODOs).

To avoid the redundant implementations of the current conformance tests, I'm doing the following:

  1. Generate all conformance protos, using lite runtime, into the conformance/client module. So the shared logic deals with the lite generated message types, since that's the lowest common denominator. (The full runtime should be able to correctly support lite generate code.)
  2. This means that the conformance/client/google-javalite module doesn't need any add'l generated code.
  3. The conformance/client/google-java module, on the other hand, does. So the shared code will convert from generated lite messages to normal/non-lite messages. This uses a buf.gen.lite.yaml which has a different package prefix, so both sets of generated messages can co-exist. The dependencies of the non-lite module exclude the javalite protobuf runtime, swapping in the full runtime instead.

This also provides a glimpse of what I'm thinking about for an overhaul of the stream interfaces. In particular, see BidiStreamClient.BidiStream, ServerStreamClient.ServerStream, and ClientStreamClient.ClientStream. Currently, these contain adapters from the existing actual stream interfaces to these newer ones. But I'd like to overhaul the main stream interfaces to look more-or-less like these in the future, so let me know what you think.

- This contains the new conformance client, for the new conformance tests
- The base module has all of the logic and uses the Java Lite runtime (since
  it is lowest common denominator)
- There are google-java and google-javalite modules which have the main
  functions for running the clients. The google-java module swaps out the
  javalite runtime for the java runtime. The client module (with shared logic)
  can convert from javalite generated messages to java generated messages by
  serializing and deserializing
- The adapt package in the client module provides a glimpse of what I think
  better stream APIs would look like. I'd like to update the actual stream
  interfaces to more closely match this in the future. For now, the code just
  adapts exising interfaces to these.
- To test the different unary invocation styles, there is an enum for each
  style and a method in UnaryClient that is an adapter: a single interface for
  the actual conformance client to use (that looks like the Callback style), but
  under the hood it will call the suspend, callback, or blocking methods based
  on the desired invocation style.
- The actual client logic is TODO, in various handle* methods of the Client
  class. This felt like a big enough chunk already, so I figured it would be
  good to get this reviewed before plowing through the rest.
Copy link
Contributor

@pkwarren pkwarren left a comment

Choose a reason for hiding this comment

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

Looks really nice - the new interfaces look good to me and it will be nice to not have duplicated code.

Makefile Outdated Show resolved Hide resolved
conformance/client/build.gradle.kts Outdated Show resolved Hide resolved
conformance/client/google-java/build.gradle.kts Outdated Show resolved Hide resolved
Copy link
Contributor

@pkwarren pkwarren left a comment

Choose a reason for hiding this comment

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

Looks good - just a conflict to resolve in versions toml file after some dependabot updates from yesterday.

@jhump jhump merged commit 2198d2d into main Jan 3, 2024
7 checks passed
@jhump jhump deleted the jh/conformance-revamp branch January 3, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants