Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test): fix intermittent issue of port binding by using dynamic po…
…rt for WireMockServer (#4600) While running complete test as `./gradlew --no-build-cache cleanTest test`, encountered below error in orca-clouddriver module with `KatoRestServiceSpec` intermittently: ``` java.lang.RuntimeException: java.io.IOException: Failed to bind to /0.0.0.0:8080 com.github.tomakehurst.wiremock.common.FatalStartupException: java.lang.RuntimeException: java.io.IOException: Failed to bind to /0.0.0.0:8080 at app//com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:146) at app//com.netflix.spinnaker.orca.clouddriver.KatoRestServiceSpec.setup(KatoRestServiceSpec.groovy:61) Caused by: java.lang.RuntimeException: java.io.IOException: Failed to bind to /0.0.0.0:8080 at com.github.tomakehurst.wiremock.jetty9.JettyHttpServer.start(JettyHttpServer.java:137) at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:144) ... 1 more Caused by: java.io.IOException: Failed to bind to /0.0.0.0:8080 at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349) at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310) at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) at org.eclipse.jetty.server.Server.doStart(Server.java:401) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) at com.github.tomakehurst.wiremock.jetty9.JettyHttpServer.start(JettyHttpServer.java:135) ... 2 more Caused by: java.net.BindException: Address already in use at java.base/sun.nio.ch.Net.bind(Net.java:461) at java.base/sun.nio.ch.Net.bind(Net.java:453) at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227) at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80) at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344) ... 9 more ``` The root cause of the issue seems multifold: 1. depends on machine capacity to run parallel tests. 2. use of WireMockServer in multiple modules. 3. default port used by WireMockServer is 8080. https://wiremock.org/docs/standalone/java-jar/#command-line-options To fix this issue updating the default port to dynamic port. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information