-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Improve testing gRPC services with random ports #34135
Conversation
...nsions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java
Show resolved
Hide resolved
4f416b3
to
f48d842
Compare
@nahguam Thanks ! I'm doing a pass/review. |
This comment has been minimized.
This comment has been minimized.
f48d842
to
e39b864
Compare
Where in the docs does it state if you pass 0 port to (Vert.x) gRPC server, that it randomly selects one? Plus, it would also be good/nice to fix to actual port where ever we print it out.
Otherwise it looks good + nice test coverage! |
To my limited knowledge, the only reference is https://github.com/quarkusio/quarkus/blob/main/docs/src/main/asciidoc/http-reference.adoc#7-listening-on-a-random-port Should I add similar detail to the grpc doc?
Indeed, I did have a look at this but it looked non-trivial. I'll take another look. |
e39b864
to
a060e76
Compare
I've updated this output. |
Are we sure this works for the gRPC as well? :-) |
@@ -226,7 +228,7 @@ private void prodStart(GrpcContainer grpcContainer, Vertx vertx, GrpcServerConfi | |||
|
|||
private void postStartup(GrpcServerConfiguration configuration, GrpcBuilderProvider<?> provider, boolean test) { | |||
initHealthStorage(); | |||
int port = test ? configuration.testPort : configuration.port; | |||
int port = test ? testPort(configuration) : configuration.port; |
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.
Well, this was easy. :-)
Are we sure we captured all such log outputs -- with this "new" port?
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.
There's an output in buildServer
but that's before the server is started - so before the port is chosen.
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.
LGTM!
You can retrieve the actual port from the httpServer (once bound to the socket): `server.getactualPort()).
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.
LGTM, thanks !
a060e76
to
ea149e1
Compare
Do you mean when |
Do I need to keep rebasing on main? (it moves so quickly! :D) Looks like the failure is unrelated. What needs to happen now? |
@nahguam Clément and I approved this PR, so I think we are good to go. No need to keep rebasing, we can alway rebase when merging. @cescoffier thoughts ? |
I was just waiting for 3.2 to be branched. |
@cescoffier great, thank you 😄 |
Great Thanks 👍 |
Currently, testing gRPC is not as seamless as HTTP when it comes to using random ports. If one injects a
@GrpcClient
whenquarkus.grpc.server.test-port=0
, it will attempt to connect to port0
, or if one is using the Vert.x server, it will attempt to connect to the http test port,8081
.This change aims to improve this by making it possible to inject
@GrpcClient
s into tests that have discovered the actual port that the service is running on. It shares the approach that is used for HTTP.