I start a wiremock server in a integration test.
The IT pass in my local BUT some case failed in jenkins server, the error is
localhost:8089 failed to respond; nested exception is org.apache.http.NoHttpResponseException: localhost:8089 failed to respond
I try to add sleep(3000)
in my test, that can fix the issue, But I don’t know the root cause of the issue, so the work around not a good idea
I also try to use @AutoConfigureWireMock(port=8089)
to replace WireMockServer
to start wiremock server, that could fix the problem, BUT I don't know how to do some configuration to the wiremock server using the annotation @AutoConfigureWireMock(port=8089)
.
Here my code to start a wiremock server, any suggestion to fix "NoHttpResponseException"?
@ContextConfiguration(
initializers = ConfigFileApplicationContextInitializer.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
class BaseSpec extends Specification {
@Shared
WireMockServer wireMockServer
def setupSpec() {
wireMockServer = new WireMockServer(options().port(PORT).jettyHeaderBufferSize(12345)
.notifier(new ConsoleNotifier(new Boolean(System.getenv(“IT_WIREMOCK_LOG”) ?: ‘false’)))
.extensions(new ResponseTemplateTransformer(true)))
wireMockServer.start()
}