Quarkus: Native Tests fail when quarkus.http.test-port is set to 0

Created on 4 Sep 2020  路  8Comments  路  Source: quarkusio/quarkus

Describe the bug

When running a native test with quarkus.http.test-port=0 you get the following :

[INFO] Running org.acme.NativeExampleResourceIT
Executing target/code-with-quarkus-1.0.0-SNAPSHOT-runner, -Dquarkus.http.port=0, -Dquarkus.http.ssl-port=8444, -Dtest.url=http://localhost:0

The runner is executed with localhost:0 (instead of a random port). So it hangs, and then the test fails with:

Caused by: java.lang.RuntimeException: Unable to start native image in 60s

Expected behavior

The test should pass using a random port (like JVM mode tests).

Actual behavior

To Reproduce
Steps to reproduce the behavior:

  1. Go to code.quarkus.io and generate a new project
  2. mvn verify -Pnative works
  3. Add the property quarkus.http.test-port=0to the application.properties file
  4. mvn verify -Pnative FAILS

Configuration

quarkus.http.test-port=0

Environment (please complete the following information):

  • Output of uname -a or ver: Darwin iMac-Pro-de-Antonio.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
  • Output of java -version: java version "11.0.6" 2020-01-14 LTS
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.7.1-FINAL
  • Build tool (ie. output of mvnw --version or gradlew --version): 3.6.3_1

Additional context
(Add any other context about the problem here.)

aretesting kinbug

All 8 comments

/cc @geoand

As mentioned at, https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/quarkus.2Ehttp.2Etest-port.3D0.20and.20Native.20Tests, this has to do with the NativeImageLauncher not using the proper port when connecting to the application.

I'll take a look at it next week unless someone wants to be dive in sooner.

I tried this with 1.8.0.Final, but get the following exception:

application.properties:

quarkus.http.test-port=0
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running de.XXX.XXX.NativeMessageResourceEndToEndIT
Executing [/home/mheberling/workspace/XXX/target/XXX-0.0.0-SNAPSHOT-runner, -Dquarkus.http.port=0, -Dquarkus.http.ssl-port=8444, -Dtest.url=http://localhost:0, -Dquarkus.log.file.path=target/target/quarkus.log, -Dmirth.url=http://localhost:33295]
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2020-09-10 10:23:37,269 ERROR [io.qua.application] (main) Failed to start application (with profile prod): java.lang.RuntimeException: Unable to start HTTP server
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder.doServerStart(VertxHttpRecorder.java:497)
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServer(VertxHttpRecorder.java:220)
    at io.quarkus.deployment.steps.VertxHttpProcessor$openSocket-2064782366.deException in thread "Thread-3" java.lang.IllegalMonitorStateException
    at java.base/java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:149)
    at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1302)
    at java.base/java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:439)
    at io.quarkus.test.common.NativeImageLauncher$PortCapturingProcessReader.portDetermined(NativeImageLauncher.java:344)
    at io.quarkus.test.common.NativeImageLauncher$PortCapturingProcessReader.handleError(NativeImageLauncher.java:350)
    at io.quarkus.test.common.NativeImageLauncher$ProcessReader.run(NativeImageLauncher.java:285)
    at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 18.836 s <<< FAILURE! - in de.XXX.XXX.NativeMessageResourceEndToEndIT
[ERROR] de.XXX.XXX.NativeMessageResourceEndToEndIT  Time elapsed: 18.836 s  <<< ERROR!
org.junit.platform.commons.JUnitException: Quarkus native image start failed, original cause: java.lang.RuntimeException: Unable to determine actual running port as dynamic port was used
Caused by: java.lang.RuntimeException: Unable to determine actual running port as dynamic port was used

Is there anything else I need to configure?

@tisoft how were you able to reproduce that?

It fails everytime with my real test, but I haven't been able to extract a minimal reproducer yet. Might be caused by extensions I'm using, or something funny in my test case. Will report back as soon as I have a reproducer, I can share.

Could reproduce it. it is caused by @TestHTTPResource annotated field not correctly set. I have created a new issue to track it: https://github.com/quarkusio/quarkus/issues/12237

Thanks, that is very useful!

Was this page helpful?
0 / 5 - 0 ratings