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

Native Tests fail when quarkus.http.test-port is set to 0 #11891

Closed
agoncal opened this issue Sep 4, 2020 · 8 comments · Fixed by #11912
Closed

Native Tests fail when quarkus.http.test-port is set to 0 #11891

agoncal opened this issue Sep 4, 2020 · 8 comments · Fixed by #11912
Assignees
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@agoncal
Copy link
Contributor

agoncal commented Sep 4, 2020

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.)

@agoncal agoncal added the kind/bug Something isn't working label Sep 4, 2020
@famod
Copy link
Member

famod commented Sep 4, 2020

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Sep 4, 2020

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.

geoand added a commit to geoand/quarkus that referenced this issue Sep 4, 2020
@geoand geoand self-assigned this Sep 4, 2020
@geoand
Copy link
Contributor

geoand commented Sep 4, 2020

#11912 should fix this

geoand added a commit to geoand/quarkus that referenced this issue Sep 4, 2020
geoand added a commit to geoand/quarkus that referenced this issue Sep 5, 2020
stuartwdouglas added a commit that referenced this issue Sep 7, 2020
Make native tests work with random port
@gsmet gsmet added this to the 1.8.0.Final milestone Sep 8, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 8, 2020
@tisoft
Copy link
Contributor

tisoft commented Sep 10, 2020

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?

@geoand
Copy link
Contributor

geoand commented Sep 10, 2020

@tisoft how were you able to reproduce that?

@tisoft
Copy link
Contributor

tisoft commented Sep 10, 2020

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.

@tisoft
Copy link
Contributor

tisoft commented Sep 21, 2020

Could reproduce it. it is caused by @TestHTTPResource annotated field not correctly set. I have created a new issue to track it: #12237

@geoand
Copy link
Contributor

geoand commented Sep 21, 2020

Thanks, that is very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants