Enable read timeout tests in OkHTTP instrumentation
MODIFY
instrumentation/okhttp/okhttp-2.2/javaagent/src/test/groovy/OkHttp2Test.groovy
instrumentation/okhttp/okhttp-2.2/javaagent/src/test/groovy/OkHttp2Test.groovy
@@ -25,6 +25,7 @@ class OkHttp2Test extends HttpClientTest<Request> implements AgentTestTrait {
def setupSpec() {
client.setConnectTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
+ client.setReadTimeout(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)
}
@Override
@@ -69,6 +70,7 @@ class OkHttp2Test extends HttpClientTest<Request> implements AgentTestTrait {
switch (uri.toString()) {
case "http://localhost:61/":
case "https://192.0.2.1/":
+ case resolveAddress("/read-timeout").toString():
attributes.remove(SemanticAttributes.HTTP_FLAVOR)
}
@@ -79,4 +81,9 @@ class OkHttp2Test extends HttpClientTest<Request> implements AgentTestTrait {
boolean testRedirects() {
false
}
+
+ @Override
+ boolean testReadTimeout() {
+ true
+ }
}

MODIFY
instrumentation/okhttp/okhttp-3.0/testing/src/main/groovy/io/opentelemetry/instrumentation/okhttp/v3_0/AbstractOkHttp3Test.groovy
instrumentation/okhttp/okhttp-3.0/testing/src/main/groovy/io/opentelemetry/instrumentation/okhttp/v3_0/AbstractOkHttp3Test.groovy
@@ -31,6 +31,7 @@ abstract class AbstractOkHttp3Test extends HttpClientTest<Request> {
Call.Factory client = createCallFactory(
new OkHttpClient.Builder()
.connectTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
+ .readTimeout(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)
.protocols(Arrays.asList(Protocol.HTTP_1_1))
.retryOnConnectionFailure(false))
@@ -73,6 +74,11 @@ abstract class AbstractOkHttp3Test extends HttpClientTest<Request> {
false
}
+ @Override
+ boolean testReadTimeout() {
+ true
+ }
+
@Override
Set<AttributeKey<?>> httpAttributes(URI uri) {
Set<AttributeKey<?>> extra = [
@@ -85,6 +91,7 @@ abstract class AbstractOkHttp3Test extends HttpClientTest<Request> {
switch (uri.toString()) {
case "http://localhost:61/":
case "https://192.0.2.1/":
+ case resolveAddress("/read-timeout").toString():
attributes.remove(SemanticAttributes.HTTP_FLAVOR)
}

Enable read timeout tests in OkHTTP instrumentation (#4422)