quarkus-qe / quarkus-test-suite

16 stars 32 forks source link

Leaking Vertx and HttpClient #1408

Closed rsvoboda closed 11 months ago

rsvoboda commented 1 year ago

As part of upstream reviews I noticed comment from Clement saying:

        Vertx vertx = Vertx.vertx();
if you create your Vert.x you MUST close it at the end of the tests. Otherwise, it will leak.

Closing http client in such case is not enough.

I did a quick check of our codebase and we do poor resources cleanup.

TS

git grep "Vertx.vertx()"
http/vertx-web-client/src/test/java/io/quarkus/ts/http/vertx/webclient/PureVertxHttpClientTest.java:        httpClient = WebClient.create(Vertx.vertx(), new WebClientOptions());
http/vertx/src/test/java/io/quarkus/ts/vertx/AbstractVertxIT.java:        HttpClient httpClient = Vertx.vertx().createHttpClient();
http/vertx/src/test/java/io/quarkus/ts/vertx/AbstractVertxIT.java:        HttpClient httpClient = Vertx.vertx().createHttpClient(httpClientOptions);
http/vertx/src/test/java/io/quarkus/ts/vertx/AbstractVertxIT.java:        HttpClient httpClient = Vertx.vertx().createHttpClient();
security/vertx-jwt/src/test/java/io/quarkus/ts/security/vertx/AbstractCommonIT.java:        this.vertx = Vertx.vertx();

FW + TS (RestService#mutiny method)

git grep "Vertx.vertx()"
quarkus-test-core/src/main/java/io/quarkus/test/bootstrap/RestService.java:            webClient = WebClient.create(Vertx.vertx(), options
git grep 'mutiny('
examples/greetings/src/test/java/io/quarkus/qe/ReactiveGreetingResourceIT.java:        String response = app.mutiny().get("/reactive-greeting")

git grep 'mutiny(
http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java:        Uni<JsonObject> content = getApp().mutiny(defaultVertxHttpClientOptions())
http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java:        Uni<Integer> statusCode = getApp().mutiny(defaultVertxHttpClientOptions())
http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java:        Uni<JsonObject> content = getApp().mutiny(defaultVertxHttpClientOptions())
http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java:        Uni<Integer> statusCode = getApp().mutiny(defaultVertxHttpClientOptions())
messaging/kafka-producer/src/test/java/io/quarkus/ts/messaging/kafka/producer/BlockingProducerIT.java:        return app.mutiny().postAbs(getAppEndpoint() + path).send()
nosql-db/mongodb-reactive/src/test/java/io/quarkus/ts/nosqldb/mongodb/reactive/AbstractMongoClientReactiveIT.java:        return getApp().mutiny().request(httpMethod, path);
security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/BaseAuthzSecurityReactiveIT.java:        return getApp().mutiny().request(method, path);

The cost of being a good citizen is a slightly uglier code as we would need to more work to the the cleanup properly.

@mjurc @michalvavrik please add your thoughts to this and set the priority label. I personally see this as moderate, but I will let you decide.

mjurc commented 1 year ago

Added good first issue + moderate

michalvavrik commented 1 year ago

+1 to both issue and @mjurc assessment

dipeshsingh253 commented 11 months ago

Hey @rsvoboda , @mjurc , @michalvavrik . I would like to work on this issue, can you please assign it to me?

michalvavrik commented 11 months ago

@dipeshsingh253 go for it

dipeshsingh253 commented 11 months ago

Hey @michalvavrik, I am unable to find any contribution or developer guides in the Quarks docs. Please suggest.

Thanks !!!

michalvavrik commented 11 months ago

Hey @michalvavrik, I am unable to find any contribution or developer guides in the Quarks docs. Please suggest.

Thanks !!!

If you want to contribute to this Quarkus QE Test Suite, you can simply read README, we have formatter plugin that does a job and validation one that reports you validation. It won't get any easier. https://github.com/quarkus-qe/quarkus-test-suite#quarkus-test-suite. But sure, there are no other contribution guides, you are correct.

If you mean Quarkus docs for contribution and you want to contribute to Quarkus, you can read this https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md and find yourself.