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:
mvn verify -Pnative worksquarkus.http.test-port=0to the application.properties filemvn verify -Pnative FAILSConfiguration
quarkus.http.test-port=0
Environment (please complete the following information):
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_64java -version: java version "11.0.6" 2020-01-14 LTSmvnw --version or gradlew --version): 3.6.3_1Additional context
(Add any other context about the problem here.)
/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.
https://github.com/quarkusio/quarkus/pull/11912 should fix this
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!