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

QuarkusIntegrationTest: Access to DevServices after #18933 #19080

Closed
bdevreugd-vialis opened this issue Jul 29, 2021 · 17 comments · Fixed by #21316
Closed

QuarkusIntegrationTest: Access to DevServices after #18933 #19080

bdevreugd-vialis opened this issue Jul 29, 2021 · 17 comments · Fixed by #21316

Comments

@bdevreugd-vialis
Copy link
Contributor

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
Copy link

quarkus-bot bot commented Jul 29, 2021

/cc @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jul 29, 2021

Thanks for reporting!

@geoand
Copy link
Contributor

geoand commented Jul 30, 2021

I'll try and take a look next week

@Koekebakkert
Copy link

Koekebakkert commented Nov 9, 2021

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
Copy link
Contributor

geoand commented Nov 9, 2021

What is your exact use case?

@Koekebakkert
Copy link

Koekebakkert commented Nov 9, 2021

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 added a commit to geoand/quarkus that referenced this issue Nov 9, 2021
…vailable

This is pretty much the same as we did in 21287, but it now works
regardless of the presence of DevServices.
The difference with containers launched by DevServices, is that in this
case we now need to manage the creation and deletion of the network,
whereas in the case of DevServices we got that for free
by utilizing testcontainers

Resolves: quarkusio#19080
@geoand
Copy link
Contributor

geoand commented Nov 9, 2021

This should be taken care of in 2.5.0.CR1 (likely to be released in a few days) via #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.

geoand added a commit that referenced this issue Nov 10, 2021
When launching a container via @QuarkusIntegrationTest make network available
@quarkus-bot quarkus-bot bot added this to the 2.5 - main milestone Nov 10, 2021
@Koekebakkert
Copy link

Looking forward to 2.5.0 ;)

@geoand
Copy link
Contributor

geoand commented Nov 10, 2021

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

@Koekebakkert
Copy link

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
Copy link
Contributor

geoand commented Nov 24, 2021

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

@Koekebakkert
Copy link

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
Copy link
Contributor

geoand commented Nov 24, 2021

Just upload it to Github

@Koekebakkert
Copy link

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

Feel free to ask any question ;)

@geoand
Copy link
Contributor

geoand commented Nov 24, 2021

Thanks, I'll try and have a look tomorrow

@geoand
Copy link
Contributor

geoand commented Nov 24, 2021

It seems from the project you uploaded that you have not updated the code according to #19080 (comment) nevermind, I see that you are not using testcontainers.

I need to think about how this can be addressed.

@geoand
Copy link
Contributor

geoand commented Nov 24, 2021

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants