I am currently testing my new demo, and it looks like the port is not so random with Gradle Quarkus Plugin when both normal and integration tests are being run. Disabling Integration tests resolves the issues https://github.com/oleg-nenashev/gradle-quarkus-plugin-demo
Expected behavior
Port allocations between common and integration tests do not clash
Actual Behavior
Config (supposedly random ports):
# Service destination
%prod.quarkus.rest-client.hackernews-api-server.url=https://hacker-news.firebaseio.com/v0
# WireMock Dev Service (%dev and %test scope)
%dev.quarkus.wiremock.devservices.enabled=true
%dev.quarkus.wiremock.devservices.reload=true
%dev.quarkus.wiremock.devservices.files-mapping=src/test/resources
%dev.quarkus.wiremock.devservices.global-response-templating=false
%test.quarkus.wiremock.devservices.enabled=true
%test.quarkus.wiremock.devservices.reload=false
%test.quarkus.wiremock.devservices.files-mapping=src/test/resources
%test.quarkus.wiremock.devservices.global-response-templating=false
# For tests and demos
%dev.quarkus.log.level=INFO
%test.quarkus.log.level=INFO
%dev.quarkus.log.category."io.quarkiverse".level=DEBUG
%test.quarkus.log.category."io.quarkiverse".level=DEBUG
Output:
> Task :test FAILED
WireMockDevServiceResourceTest > testBestStories() FAILED
java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkiverse.wiremock.devservice.WireMockServerProcessor#setup threw an exception: com.github.tomakehurst.wiremock.common.FatalStartupException: com.github.tomakehurst.wiremock.common.FatalStartupException: java.io.IOException: Failed to bind to /0.0.0.0:52776
at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:166)
at io.quarkiverse.wiremock.devservice.WireMockServerProcessor.startWireMockDevService(WireMockServerProcessor.java:103)
at io.quarkiverse.wiremock.devservice.WireMockServerProcessor.setup(WireMockServerProcessor.java:76)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at java.base/java.lang.Thread.run(Thread.java:840)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: com.github.tomakehurst.wiremock.common.FatalStartupException: java.io.IOException: Failed to bind to /0.0.0.0:52776
at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.start(JettyHttpServer.java:206)
at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:164)
... 13 more
Caused by: java.io.IOException: Failed to bind to /0.0.0.0:52776
at wiremock.org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
at wiremock.org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:304)
at wiremock.org.eclipse.jetty.server.Server.lambda$doStart$0(Server.java:402)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at wiremock.org.eclipse.jetty.server.Server.doStart(Server.java:398)
at wiremock.org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.start(JettyHttpServer.java:201)
... 14 more
Caused by: java.net.BindException: Address already in use
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:555)
at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)
at wiremock.org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
... 29 more
at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:638)
at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:722)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkiverse.wiremock.devservice.WireMockServerProcessor#setup threw an exception: com.github.tomakehurst.wiremock.common.FatalStartupException: com.github.tomakehurst.wiremock.common.FatalStartupException: java.io.IOException: Failed to bind to /0.0.0.0:52776
at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:166)
I am currently testing my new demo, and it looks like the port is not so random with Gradle Quarkus Plugin when both normal and integration tests are being run. Disabling Integration tests resolves the issues https://github.com/oleg-nenashev/gradle-quarkus-plugin-demo
Expected behavior
Port allocations between common and integration tests do not clash
Actual Behavior
Config (supposedly random ports):
Output: