snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

QuarkusIntegrationTest failing on containerized native image with quarkus.http.test-(ssl-)port set to 0 #329

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

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)


https://github.com/quarkusio/quarkus/issues/16900


$upstream:16900$