Skip to content

Commit

Permalink
Enable read timeout tests in OkHTTP instrumentation (#4422)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek committed Oct 19, 2021
1 parent 538f2a7 commit 13f28dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand All @@ -79,4 +81,9 @@ class OkHttp2Test extends HttpClientTest<Request> implements AgentTestTrait {
boolean testRedirects() {
false
}

@Override
boolean testReadTimeout() {
true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -73,6 +74,11 @@ abstract class AbstractOkHttp3Test extends HttpClientTest<Request> {
false
}

@Override
boolean testReadTimeout() {
true
}

@Override
Set<AttributeKey<?>> httpAttributes(URI uri) {
Set<AttributeKey<?>> extra = [
Expand All @@ -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)
}

Expand Down

0 comments on commit 13f28dc

Please sign in to comment.