Fix more tests and extract timeout values to constant
MODIFY
dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy
dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy
@@ -25,8 +25,8 @@ class ApacheHttpClientResponseHandlerTest extends HttpClientTest {
def setupSpec() {
HttpParams httpParams = client.getParams()
- HttpConnectionParams.setConnectionTimeout(httpParams, 2000)
- HttpConnectionParams.setSoTimeout(httpParams, 2000)
+ HttpConnectionParams.setConnectionTimeout(httpParams, CONNECT_TIMEOUT_MS)
+ HttpConnectionParams.setSoTimeout(httpParams, READ_TIMEOUT_MS)
}
@Override

MODIFY
dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy
dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy
@@ -18,8 +18,8 @@ abstract class ApacheHttpClientTest<T extends HttpRequest> extends HttpClientTes
def setupSpec() {
HttpParams httpParams = client.getParams()
- HttpConnectionParams.setConnectionTimeout(httpParams, 2000)
- HttpConnectionParams.setSoTimeout(httpParams, 2000)
+ HttpConnectionParams.setConnectionTimeout(httpParams, CONNECT_TIMEOUT_MS)
+ HttpConnectionParams.setSoTimeout(httpParams, READ_TIMEOUT_MS)
}
@Override

MODIFY
dd-java-agent/instrumentation/commons-httpclient-2/src/test/groovy/CommonsHttpClientTest.groovy
dd-java-agent/instrumentation/commons-httpclient-2/src/test/groovy/CommonsHttpClientTest.groovy
@@ -18,8 +18,8 @@ class CommonsHttpClientTest extends HttpClientTest {
HttpClient client = new HttpClient()
def setupSpec() {
- client.setConnectionTimeout(2000)
- client.setTimeout(2000)
+ client.setConnectionTimeout(CONNECT_TIMEOUT_MS)
+ client.setTimeout(READ_TIMEOUT_MS)
}
@Override

MODIFY
dd-java-agent/instrumentation/google-http-client/src/test/groovy/AbstractGoogleHttpClientTest.groovy
dd-java-agent/instrumentation/google-http-client/src/test/groovy/AbstractGoogleHttpClientTest.groovy
@@ -23,8 +23,8 @@ abstract class AbstractGoogleHttpClientTest extends HttpClientTest {
GenericUrl genericUrl = new GenericUrl(uri)
HttpRequest request = requestFactory.buildRequest(method, genericUrl, null)
- request.connectTimeout = 2000
- request.readTimeout = 2000
+ request.connectTimeout = CONNECT_TIMEOUT_MS
+ request.readTimeout = READ_TIMEOUT_MS
request.getHeaders().putAll(headers)
request.setThrowExceptionOnExecuteError(throwExceptionOnError)

MODIFY
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionResponseCodeOnlyTest.groovy
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionResponseCodeOnlyTest.groovy
@@ -10,8 +10,8 @@ class HttpUrlConnectionResponseCodeOnlyTest extends HttpClientTest {
HttpURLConnection connection = uri.toURL().openConnection()
try {
connection.setRequestMethod(method)
- connection.connectTimeout = 2000
- connection.readTimeout = 2000
+ connection.connectTimeout = CONNECT_TIMEOUT_MS
+ connection.readTimeout = READ_TIMEOUT_MS
headers.each { connection.setRequestProperty(it.key, it.value) }
connection.setRequestProperty("Connection", "close")
return connection.getResponseCode()

MODIFY
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionTest.groovy
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionTest.groovy
@@ -27,8 +27,8 @@ class HttpUrlConnectionTest extends HttpClientTest {
headers.each { connection.setRequestProperty(it.key, it.value) }
connection.setRequestProperty("Connection", "close")
connection.useCaches = true
- connection.connectTimeout = 2000
- connection.readTimeout = 2000
+ connection.connectTimeout = CONNECT_TIMEOUT_MS
+ connection.readTimeout = READ_TIMEOUT_MS
def parentSpan = activeScope()
def stream = connection.inputStream
assert activeScope() == parentSpan

MODIFY
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionUseCachesFalseTest.groovy
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionUseCachesFalseTest.groovy
@@ -15,8 +15,8 @@ class HttpUrlConnectionUseCachesFalseTest extends HttpClientTest {
headers.each { connection.setRequestProperty(it.key, it.value) }
connection.setRequestProperty("Connection", "close")
connection.useCaches = false
- connection.connectTimeout = 2000
- connection.readTimeout = 2000
+ connection.connectTimeout = CONNECT_TIMEOUT_MS
+ connection.readTimeout = READ_TIMEOUT_MS
def parentSpan = activeScope()
def stream = connection.inputStream
assert activeScope() == parentSpan

MODIFY
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/SpringRestTemplateTest.groovy
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/SpringRestTemplateTest.groovy
@@ -19,8 +19,8 @@ class SpringRestTemplateTest extends HttpClientTest {
RestTemplate restTemplate = new RestTemplate(factory)
def setupSpec() {
- factory.connectTimeout = 2000
- factory.readTimeout = 2000
+ factory.connectTimeout = CONNECT_TIMEOUT_MS
+ factory.readTimeout = READ_TIMEOUT_MS
}
@Override

MODIFY
dd-java-agent/instrumentation/jax-rs-client-1.1/src/test/groovy/JaxRsClientV1Test.groovy
dd-java-agent/instrumentation/jax-rs-client-1.1/src/test/groovy/JaxRsClientV1Test.groovy
@@ -14,6 +14,8 @@ class JaxRsClientV1Test extends HttpClientTest {
Client client = Client.create()
def setupSpec() {
+ client.setConnectTimeout(CONNECT_TIMEOUT_MS)
+ client.setReadTimeout(READ_TIMEOUT_MS)
// Add filters to ensure spans aren't duplicated.
client.addFilter(new LoggingFilter())
client.addFilter(new GZIPContentEncodingFilter())

MODIFY
dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientAsyncTest.groovy
dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientAsyncTest.groovy
@@ -61,8 +61,8 @@ class JerseyClientAsyncTest extends JaxRsClientAsyncTest {
@Override
ClientBuilder builder() {
ClientConfig config = new ClientConfig()
- config.property(ClientProperties.CONNECT_TIMEOUT, 2000)
- config.property(ClientProperties.READ_TIMEOUT, 2000)
+ config.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT_MS)
+ config.property(ClientProperties.READ_TIMEOUT, READ_TIMEOUT_MS)
return new JerseyClientBuilder().withConfig(config)
}
@@ -77,8 +77,8 @@ class ResteasyClientAsyncTest extends JaxRsClientAsyncTest {
@Override
ClientBuilder builder() {
return new ResteasyClientBuilder()
- .establishConnectionTimeout(2, TimeUnit.SECONDS)
- .socketTimeout(2, TimeUnit.SECONDS)
+ .establishConnectionTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
+ .socketTimeout(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)
}
boolean testRedirects() {

MODIFY
dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientTest.groovy
dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientTest.groovy
@@ -51,8 +51,8 @@ class JerseyClientTest extends JaxRsClientTest {
@Override
ClientBuilder builder() {
ClientConfig config = new ClientConfig()
- config.property(ClientProperties.CONNECT_TIMEOUT, 2000)
- config.property(ClientProperties.READ_TIMEOUT, 2000)
+ config.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT_MS)
+ config.property(ClientProperties.READ_TIMEOUT, READ_TIMEOUT_MS)
return new JerseyClientBuilder().withConfig(config)
}
@@ -67,8 +67,8 @@ class ResteasyClientTest extends JaxRsClientTest {
@Override
ClientBuilder builder() {
return new ResteasyClientBuilder()
- .establishConnectionTimeout(2, TimeUnit.SECONDS)
- .socketTimeout(2, TimeUnit.SECONDS)
+ .establishConnectionTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
+ .socketTimeout(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)
}
boolean testRedirects() {
@@ -82,8 +82,8 @@ class CxfClientTest extends JaxRsClientTest {
@Override
ClientBuilder builder() {
return new ClientBuilderImpl()
-// .property(ClientImpl.HTTP_CONNECTION_TIMEOUT_PROP, 2000L)
-// .property(ClientImpl.HTTP_RECEIVE_TIMEOUT_PROP, 2000L)
+// .property(ClientImpl.HTTP_CONNECTION_TIMEOUT_PROP, (long) CONNECT_TIMEOUT_MS)
+// .property(ClientImpl.HTTP_RECEIVE_TIMEOUT_PROP, (long) READ_TIMEOUT_MS)
}
boolean testRedirects() {

MODIFY
dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy
dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy
@@ -14,9 +14,9 @@ import java.util.concurrent.TimeUnit
class OkHttp3Test extends HttpClientTest {
def client = new OkHttpClient.Builder()
- .connectTimeout(2, TimeUnit.SECONDS)
- .readTimeout(2, TimeUnit.SECONDS)
- .writeTimeout(2, TimeUnit.SECONDS)
+ .connectTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
+ .readTimeout(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)
+ .writeTimeout(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)
.build()
@Override

MODIFY
dd-java-agent/instrumentation/vertx/src/test/groovy/client/VertxHttpClientTest.groovy
dd-java-agent/instrumentation/vertx/src/test/groovy/client/VertxHttpClientTest.groovy
@@ -18,7 +18,7 @@ class VertxHttpClientTest extends HttpClientTest {
@Shared
def vertx = Vertx.vertx(new VertxOptions())
@Shared
- def clientOptions = new HttpClientOptions().setConnectTimeout(2000).setIdleTimeout(2000)
+ def clientOptions = new HttpClientOptions().setConnectTimeout(CONNECT_TIMEOUT_MS).setIdleTimeout(READ_TIMEOUT_MS)
@Shared
def httpClient = vertx.createHttpClient(clientOptions)

MODIFY
dd-java-agent/instrumentation/vertx/src/test/groovy/client/VertxRxCircuitBreakerWebClientTest.groovy
dd-java-agent/instrumentation/vertx/src/test/groovy/client/VertxRxCircuitBreakerWebClientTest.groovy
@@ -20,7 +20,7 @@ class VertxRxCircuitBreakerWebClientTest extends HttpClientTest {
@Shared
Vertx vertx = Vertx.vertx(new VertxOptions())
@Shared
- def clientOptions = new WebClientOptions().setConnectTimeout(2000).setIdleTimeout(2000)
+ def clientOptions = new WebClientOptions().setConnectTimeout(CONNECT_TIMEOUT_MS).setIdleTimeout(READ_TIMEOUT_MS)
@Shared
WebClient client = WebClient.create(vertx, clientOptions)
@Shared

MODIFY
dd-java-agent/instrumentation/vertx/src/test/groovy/client/VertxRxWebClientTest.groovy
dd-java-agent/instrumentation/vertx/src/test/groovy/client/VertxRxWebClientTest.groovy
@@ -16,7 +16,7 @@ class VertxRxWebClientTest extends HttpClientTest {
@Shared
Vertx vertx = Vertx.vertx(new VertxOptions())
@Shared
- def clientOptions = new WebClientOptions().setConnectTimeout(2000).setIdleTimeout(2000)
+ def clientOptions = new WebClientOptions().setConnectTimeout(CONNECT_TIMEOUT_MS).setIdleTimeout(READ_TIMEOUT_MS)
@Shared
WebClient client = WebClient.create(vertx, clientOptions)

MODIFY
dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest.groovy
dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest.groovy
@@ -23,6 +23,8 @@ import static org.junit.Assume.assumeTrue
@Unroll
abstract class HttpClientTest extends AgentTestRunner {
protected static final BODY_METHODS = ["POST", "PUT"]
+ protected static final CONNECT_TIMEOUT_MS = 1000
+ protected static final READ_TIMEOUT_MS = 2000
@AutoCleanup
@Shared

Fix more tests and extract timeout values to constant