Enable read timeout tests in OkHTTP instrumentation (#4422)

This commit is contained in:
Mateusz Rzeszutek 2021-10-19 22:38:36 +02:00 committed by GitHub
parent 538f2a7cd7
commit 13f28dca2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -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
}
}

View File

@ -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)
}