quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

QuarkusIntegrationTest: Access to DevServices after #18933 #19080

Closed bdevreugd-vialis closed 2 years ago

bdevreugd-vialis commented 3 years ago

Description

Issue #18854 allowed access to the dev service urls inside integration tests. However, issue #18933 causes dev services to be started inside a shared network which will return urls inside that network. The integration test however is run from the host, which has no access to that shared network.

Could you add a method for integration tests, to acces the dev services?

Implementation ideas

Expose a property with postfix .from-host that will contain the original URL (with the mapped port)?

quarkus-bot[bot] commented 3 years ago

/cc @geoand, @stuartwdouglas

geoand commented 3 years ago

Thanks for reporting!

geoand commented 3 years ago

I'll try and take a look next week

Koekebakkert commented 2 years ago

Any progress on this? It worked in 2.1.0.CR1 and Final only. It is still broken in 2.4.1.Final. Desperately needed.

geoand commented 2 years ago

What is your exact use case?

Koekebakkert commented 2 years ago

Thanks for your quick response.

I am using a WireMockServer inside an implementation of QuarkusTestResourceLifecycleManager to stub a graphql service.

During integration test phase on Linux using the application image, the application gets lauched as:

docker run --rm -p 9990:9990 -p 8444:8444 --env QUARKUS_HTTP_PORT=9990 --env QUARKUS_HTTP_SSL_PORT=8444 --env TEST_URL=http://0.0.0.0:9990 --env GRAPHQL_SERVICE_MP_GRAPHQL_URL=http://localhost:8080/graphql application:1.0.1-SNAPSHOT

and the application cannot reach localhost:8080

Everything will run fine with the '--network host' option, but that won't work on windows apparently.

With Quarkus 2.1.0.Final the application integration-test was working, it launched as:

docker, run, --rm, --net=host, --env, QUARKUS_HTTP_PORT=9990, --env, QUARKUS_HTTP_SSL_PORT=8444, --env, TEST_URL=http://0.0.0.0:9990, --env, GRAPHQL_SERVICE_MP_GRAPHQL_URL=http://localhost:8080/graphql, application:1.0.1-SNAPSHOT

Since 2.2.0.Final and up to 2.4.1.Final it is broken.

How to proceed?

geoand commented 2 years ago

This should be taken care of in 2.5.0.CR1 (likely to be released in a few days) via https://github.com/quarkusio/quarkus/pull/21316.

Essentially what that PR brings is the ability to know the network the application container (by implementing DevServicesContext.ContextAware in your implementation of QuarkusTestResourceLifecycleManager) will be launched on, thus giving you the ability to launch your service on the same network.

Koekebakkert commented 2 years ago

Looking forward to 2.5.0 ;)

geoand commented 2 years ago

If all goes well, 2.5.0.CR1 will be out today :)

Koekebakkert commented 2 years ago

Unfortunately, it still does not work with 2.5.0.Final.

I have tried it on both openSUSE Tumbleweed and LEAP where 2.1.0.Final works great.

What can I do to help troubleshoot the issue?

geoand commented 2 years ago

What does your code look like? What containers are launched when you start the test?

Koekebakkert commented 2 years ago

I have created a small project that can be used to hammer out the integration test issue. It will succeed with 2.1.0.Final but will fail with a higher version, including 2.5.0.Final. Where do I put it?

geoand commented 2 years ago

Just upload it to Github

Koekebakkert commented 2 years ago

Well here it is: https://github.com/Koekebakkert/quarkus-wiremockserver-integration-test-service

Feel free to ask any question ;)

geoand commented 2 years ago

Thanks, I'll try and have a look tomorrow

geoand commented 2 years ago

It seems from the project you uploaded that you have not updated the code according to https://github.com/quarkusio/quarkus/issues/19080#issuecomment-964269107 nevermind, I see that you are not using testcontainers.

I need to think about how this can be addressed.

geoand commented 2 years ago

Actually there is no good way to support that use case if we want to support the more common case where a supporting container is launched. You'll probably have to switch from Wiremock to https://www.testcontainers.org/modules/mockserver/