how to setup Wiremock dynamic port

Viewed 214

I am working on integration test written in Spring boot 5 and I am trying to stub downstream services. I have several clients and 3 integration test classes. In my resources folder I have .yml file with following configs:

downstream:
    service
        getSomeData:
            url: http://localhost:666
        getAuthToken:
            url: http://localhost:666
        someOtherClientMethod:
            url: http://localhost:666

And I am using Junit 5 with @WiremockTest annotation.

@WireMockTest(httpPort=666)
class TestSomething {

On my local machine clean build and test commands are working fine, but have fails in Jenkins with error:

com.github.tomakehurst.wiremock.common.FatalStartupException at WireMockServer.java.149 Caused by: java.lang.RunTimeException at JettyServer.java:198 Caused by: java.net.SocketException at Net.java:-2

As I understand the problem is that I have fixed port and I have to use dynamic port. Any suggestions how can I implement that?

1 Answers

Lower port ranges are sometimes not allowed. Can you try higher port ranges ?

Related