quarkusio / quarkus

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

@QuarkusIntegrationTest - connection refused trying to use localstack dev services #34633

Closed ygyg70 closed 1 year ago

ygyg70 commented 1 year ago

Describe the bug

I am using localstack via Quarkus AWS extensions. All works well in dev, unit test, and integration test of a jar artifact. When testing a docker package, connection to dev services fail (both test and prod mode) I am able to interact with localstack from the integration test code. Here is the docker launch command: 2023-07-09 15:40:49,875 INFO [io.qua.tes.com.DefaultDockerContainerLauncher] (main) Executing "docker run --name quarkus-integration-test-qIfGT -i --rm -p 8083:8083 -p 8444:8444 --net=fc6caacb711394671f01c2f6fd989c022a8ced674d79d536e5301b585b6f4334 --env QUARKUS_LOG_CATEGORY__IO_QUARKUS__LEVEL=INFO --env QUARKUS_HTTP_PORT=8083 --env QUARKUS_HTTP_SSL_PORT=8444 --env TEST_URL=http://localhost:8083 --env QUARKUS_PROFILE=test --env QUARKUS_SQS_AWS_CREDENTIALS_TYPE=STATIC --env QUARKUS_S3_AWS_REGION=us-east-1 --env QUARKUS_SECRETSMANAGER_AWS_CREDENTIALS_TYPE=STATIC --env QUARKUS_SQS_AWS_REGION=us-east-1 --env QUARKUS_SECRETSMANAGER_AWS_REGION=us-east-1 --env QUARKUS_S3_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY=secretkey --env QUARKUS_SECRETSMANAGER_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID=accesskey --env QUARKUS_S3_AWS_CREDENTIALS_TYPE=STATIC --env QUARKUS_SECRETSMANAGER_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY=secretkey --env QUARKUS_S3_PATH_STYLE_ACCESS=true --env QUARKUS_SQS_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID=accesskey --env QUARKUS_SECRETSMANAGER_ENDPOINT_OVERRIDE=http://127.0.0.1:42533 --env QUARKUS_S3_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID=accesskey --env QUARKUS_SQS_ENDPOINT_OVERRIDE=http://127.0.0.1:42533 --env QUARKUS_S3_ENDPOINT_OVERRIDE=http://127.0.0.1:42533 --env QUARKUS_SQS_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY=secretkey {docker_image_name}" quarkus.log

Expected behavior

Quarkus application should be able to connect to dev services localstack when launched as a docker container by integration test

Actual behavior

Application starts but cannot connect to localstack

How to Reproduce?

No response

Output of uname -a or ver

Linux *** 6.2.0-24-generic #24-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 16 12:03:50 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "17.0.7" 2023-04-18 LTS OpenJDK Runtime Environment Corretto-17.0.7.7.1 (build 17.0.7+7-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.7.7.1 (build 17.0.7+7-LTS, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.2.0.Final

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

Maven home: ~/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 17.0.7, vendor: Amazon.com Inc., runtime: ~/.jdks/corretto-17.0.7 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "6.2.0-24-generic", arch: "amd64", family: "unix"

Additional information

No response

quarkus-bot[bot] commented 1 year ago

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

geoand commented 1 year ago

Closing as a duplicate of #34049

ygyg70 commented 1 year ago

Some more information: If I replace the override addresses (such as QUARKUS_SQS_ENDPOINT_OVERRIDE=http://127.0.0.1:42533) with the IP address of the localstack container on the bridge network and the non-mapped port (such as http://192.168.96.2:4566) it would work.

Am I missing something? Or - is this a Quarkus issue or a https://github.com/quarkiverse/quarkus-amazon-services issue? Any idea what is the correct way to get it fixed?

geoand commented 1 year ago

Unfortunately I have not worked with the Amazon services stuff so I have no answers for you

macleanpinto commented 7 months ago

This is because LocalStack is starting in Docker mode. We should be able to configure it to host mode to access it from the local machine using localhost:4566. Reference