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

Failing devservices-containing @QuarkusIntegrationTest for container-image.build=true on MacOS #43980

Closed
jgardo opened this issue Oct 19, 2024 · 3 comments · Fixed by #44120
Closed

Comments

@jgardo
Copy link
Contributor

jgardo commented Oct 19, 2024

Describe the bug

The @QuarkusIntegrationTest in the project, whose final artefact is Jib-built docker image, tests this built image.

If there are dev services required for this integration test, those dependency adresses are passed with properties, e.g. quarkus.elasticsearch.hosts. The hosts of these addresses are defined as localhost, which is correct for jar testing.

Problem occurs for MacOS. In the MacOS, Docker container localhost refers only to "this-container-localhost", which causes failure of reaching devservices via localhost.

We can observe this behaviour in the logs:
2024-10-19 23:38:45,069 INFO [io.qua.tes.com.DefaultDockerContainerLauncher] (main) Executing "docker run --name quarkus-integration-test-SfkPp -i --rm -p 8081:8081 -p 8444:8444 --net=834f31302c23d79e9deb7a0f691fad3f15d419301763337c2901b96d269c2ce2 --env QUARKUS_LOG_CATEGORY__IO_QUARKUS__LEVEL=INFO --env QUARKUS_HTTP_PORT=8081 --env QUARKUS_HTTP_SSL_PORT=8444 --env TEST_URL=http://localhost:8081 --env QUARKUS_ELASTICSEARCH_HOSTS=localhost:50383 code-with-quarkus:1.0.0-SNAPSHOT"

Expected behavior

The tested container should access devservices via container's domain name (e.g. elasticsearch:9200 instead of localhost:<mappedPort>) in shared network.

Other workaround specific for MacOS could be replacing localhost:<mappedPort> with host.docker.internal:<mappedPort>.

Actual behavior

Accessing devservices on MacOS within Docker container via localhost causes java.net.ConnectException: Connection refused.

How to Reproduce?

Reproducing project: code-with-quarkus.zip

Steps to create such project:

  1. Create example project quarkus create app
  2. Add docker image building extension - quarkus extension add container-image-jib
  3. Require building docker image by specifying Maven property <quarkus.container-image.build>true</quarkus.container-image.build>
  4. Require running IT tests by specifying Maven property <skipITs>false</skipITs>
  5. Add example required devservice e.g.
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-elasticsearch-rest-client</artifactId>
        </dependency>
  1. Use devservice in application
  2. Run mvn clean install

Output of uname -a or ver

Darwin MacBook-Pro.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:09:52 PDT 2024; root:xnu-10063.121.3~5/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "21" 2023-09-19 OpenJDK Runtime Environment (build 21+35-2513) OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)

Quarkus version or git rev

3.15.1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.4 (dfbb324ad4a7c8fb0bf182e6d91b0ae20e3d2dd9) Java version: 21, vendor: Oracle Corporation Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "14.5", arch: "x86_64", family: "mac"

Additional information

No response

Copy link

quarkus-bot bot commented Oct 19, 2024

/cc @geoand (devservices,jib,testing), @stuartwdouglas (devservices)

@jgardo
Copy link
Contributor Author

jgardo commented Oct 19, 2024

I think I could try to resolve this issue.
However I will appreciate some suggestions about preferred way of solving this bug.

@geoand
Copy link
Contributor

geoand commented Oct 21, 2024

I am pretty sure that this exact problem has been solved by other dev-services - for example if you use PostgreSQL things should work OOTB.
If you would like to contribute, I propose checking how PostgresqlDevServicesProcessor compares to DevServicesElasticsearchProcessor with regards to the handling of DevServicesSharedNetworkBuildItem

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