Fix sporadic grizzly test failure
@@ -61,19 +61,27 @@ abstract class HttpServerTest<SERVER> extends AgentTestRunner {
@Shared
OkHttpClient client = OkHttpUtils.client()
@Shared
- int port = PortUtils.randomOpenPort()
+ int port
@Shared
- URI address = buildAddress()
+ URI address
- URI buildAddress() {
- return new URI("http://localhost:$port/")
+ def setupSpec() {
+ withRetryOnBindException({
+ setupSpecUnderRetry()
+ })
}
- def setupSpec() {
+ def setupSpecUnderRetry() {
+ port = PortUtils.randomOpenPort()
+ address = buildAddress()
server = startServer(port)
println getClass().name + " http server started at: http://localhost:$port/"
}
+ URI buildAddress() {
+ return new URI("http://localhost:$port/")
+ }
+
abstract SERVER startServer(int port)
def cleanupSpec() {
