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 failing on containerized native image with quarkus.http.test-(ssl-)port set to 0 #16900

Closed
westarne opened this issue Apr 29, 2021 · 0 comments · Fixed by #16903
Assignees
Milestone

Comments

@westarne
Copy link

westarne commented Apr 29, 2021

Describe the bug

@QuarkusIntegrationTest does not start up correctly for native container images with http ports set to 0 (random). Similar to #11891.

Expected behavior

The test should start correctly and pass using a random port for HTTP and HTTPS.

Actual behavior

When running a @QuarkusIntegrationTest using a native containerized image with quarkus.http.test-port=0 and quarkus.http.test-ssl-port=0 you get the following:

Executing [docker, run, --rm, -p, 0:0, -p, 0:0, --env, QUARKUS_HTTP_PORT=0, --env, QUARKUS_HTTP_SSL_PORT=0, --env, TEST_URL=http://localhost:0, arne/code-with-quarkus:1.0.0-SNAPSHOT]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.471 s <<< FAILURE! - in org.acme.NativeGreetingResourceIT
[ERROR] org.acme.NativeGreetingResourceIT.testHelloEndpoint  Time elapsed: 0.012 s  <<< ERROR!
java.lang.RuntimeException: java.lang.IllegalStateException: Unable to determine the status of the running process. See the above logs for details
Caused by: java.lang.IllegalStateException: Unable to determine the status of the running process. See the above logs for details

Docker is asked to expose the port 0, which is not allowed. Replaying the command in the shell returns

docker: Error response from daemon: driver failed programming external connectivity on endpoint musing_villani (b113766de6c1e230923d504f0b56d4d60133a7a8af4ae72a089fe9d21db298e6):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 49232 -j DNAT --to-destination 172.17.0.2:0 ! -i docker0: iptables v1.6.1: Port `0' not valid

Additional problem:
When executing all tests in IntelliJ and the @QuarkusIntegrationTest is executed after a @QuarkusTest, it will find a correct random HTTP port (with quarkus.http.test-port=0):

2021-04-29 11:19:16,834 INFO  [io.quarkus] (main) Quarkus 1.13.2.Final on JVM started in 1.552s. Listening on: http://localhost:36011
2021-04-29 11:19:16,855 INFO  [io.quarkus] (main) Profile test activated.
2021-04-29 11:19:16,855 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy]


Executing [docker, run, --rm, -p, 36011:36011, -p, 0:0, --env, QUARKUS_HTTP_PORT=36011, --env, QUARKUS_HTTP_SSL_PORT=0, --env, TEST_URL=http://localhost:36011, arne/native-image:1.0.0-SNAPSHOT]

java.lang.RuntimeException: java.io.IOException: Cannot run program "docker": target/target/quarkus.log (No such file or directory)

First logs are from the @QuarkusTest, last blocks tarting from Executing for the @QuarkusIntegrationTest. This part I could not reproduce for a new project, because I am not sure how to control the test execution order.

To Reproduce

Steps to reproduce the behavior:

  1. Go to code.quarkus.io and generate a new project
  2. ./mvnw quarkus:add-extension -Dextensions="container-image-docker"
  3. Change the @NativeImageTest to @QuarkusIntegrationTest
  4. mvn verify -Pnative -Dquarkus.container-image.build=true -Dquarkus.native.container-build=true -Dquarkus.native.container-runtime=docker Works
  5. Add the property quarkus.http.test-port=0 and quarkus.http.test-ssl-port=0 to the application.properties file
  6. mvn verify -Pnative -Dquarkus.container-image.build=true -Dquarkus.native.container-build=true -Dquarkus.native.container-runtime=docker FAILS

Configuration

quarkus.http.test-port=0
quarkus.http.test-ssl-port=0
quarkus.container-image.build=true
quarkus.native.container-build=true
quarkus.native.container-runtime=docker

Environment

Output of uname -a or ver

Linux arne-ThinkPad-T480 4.15.0-142-generic #146-Ubuntu SMP Tue Apr 13 01:11:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.8" 2020-07-14

GraalVM version (if different from Java)

not installed

Quarkus version or git rev

1.13.2-FINAL

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

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

IDE

Intellij IDEA 2020.2.3 (Ultimate Edition)

@geoand geoand self-assigned this Apr 29, 2021
geoand added a commit to geoand/quarkus that referenced this issue Apr 29, 2021
When a user set `quarkus.http.test-port=0` or `quarkus.http.quarkus.http.test-ssl-port=0`,
there is no way to know the port number to expose when launching the container,
therefore we need to resort to selecting the random port(s) in the test
before launching the container

Fixes: quarkusio#16900
geoand added a commit that referenced this issue Apr 29, 2021
When using random ports in a docker test, resort to host networking
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone Apr 29, 2021
@gsmet gsmet modified the milestones: 2.0.0.Alpha2, 1.13.4.Final May 10, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 10, 2021
When a user set `quarkus.http.test-port=0` or `quarkus.http.quarkus.http.test-ssl-port=0`,
there is no way to know the port number to expose when launching the container,
therefore we need to resort to selecting the random port(s) in the test
before launching the container

Fixes: quarkusio#16900
(cherry picked from commit 47ee7e4)
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