quarkusio / quarkus

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

Failing pulsar-devservice-containing @QuarkusIntegrationTest for container-image.build=true on MacOS #44264

Open jgardo opened 3 hours ago

jgardo commented 3 hours ago

Describe the bug

This bug is similar to #43980

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

If there is Pulsar dev services required for this integration test, those Pulsar adresses are passed with properties pulsar.client.serviceUrl and pulsar.admin.serviceUrl. 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-11-01 22:04:48,511 INFO  [io.qua.tes.com.DefaultDockerContainerLauncher] (main) Executing "docker run --name quarkus-integration-test-OCzQj -i --rm -p 8081:8081 -p 8444:8444 --net=a058ee16d4aebf6cd18e05878bdc9f12da3e93e67dd2ad3356b96b57939ddc0e --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 PULSAR_ADMIN_SERVICEURL=http://localhost:54242 --env PULSAR_CLIENT_SERVICEURL=pulsar://localhost:54241 code-with-quarkus:1.0.0-SNAPSHOT"

Expected behavior

The tested container should access Pulsar devservice via container's domain name (e.g. pulsar://pulsar-hash:6650 or http://pulsar-hash:8080) instead of localhost:<mappedPort>) in shared network.

Actual behavior

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

How to Reproduce?

  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 Pulsar devservice
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-messaging-pulsar</artifactId>
        </dependency>
  6. Use devservice in application
  7. Run ./mvnw clean install

code-with-quarkus.zip

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.8 (36645f6c9b5079805ea5009217e36f2cffd34256) Maven home: /Users/jakub.gardo/.m2/wrapper/dists/apache-maven-3.9.8-bin/337e6d14/apache-maven-3.9.8 Java version: 21, vendor: Oracle Corporation, runtime: /Users/jakub.gardo/.sdkman/candidates/java/21-open 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

quarkus-bot[bot] commented 3 hours ago

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