Enable read timeout test for armeria
MODIFY
instrumentation/armeria-1.3/testing/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/AbstractArmeriaHttpClientTest.java
instrumentation/armeria-1.3/testing/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/AbstractArmeriaHttpClientTest.java
@@ -34,6 +34,7 @@ public abstract class AbstractArmeriaHttpClientTest extends AbstractHttpClientTe
private AtomicBoolean decoratorCalled;
private WebClient client;
+ private WebClient clientWithReadTimeout;
@BeforeEach
void setupClient() {
@@ -48,6 +49,12 @@ public abstract class AbstractArmeriaHttpClientTest extends AbstractHttpClientTe
})
.factory(ClientFactory.builder().connectTimeout(connectTimeout()).build()))
.build();
+ clientWithReadTimeout =
+ configureClient(
+ WebClient.builder()
+ .responseTimeout(READ_TIMEOUT)
+ .factory(ClientFactory.builder().connectTimeout(connectTimeout()).build()))
+ .build();
}
@Override
@@ -62,7 +69,7 @@ public abstract class AbstractArmeriaHttpClientTest extends AbstractHttpClientTe
protected final int sendRequest(
HttpRequest request, String method, URI uri, Map<String, String> headers) {
try {
- return client.execute(request).aggregate().join().status().code();
+ return getClient(uri).execute(request).aggregate().join().status().code();
} catch (CompletionException e) {
return Exceptions.throwUnsafely(e.getCause());
}
@@ -75,7 +82,7 @@ public abstract class AbstractArmeriaHttpClientTest extends AbstractHttpClientTe
URI uri,
Map<String, String> headers,
RequestResult requestResult) {
- client
+ getClient(uri)
.execute(request)
.aggregate()
.whenComplete(
@@ -83,12 +90,20 @@ public abstract class AbstractArmeriaHttpClientTest extends AbstractHttpClientTe
requestResult.complete(() -> response.status().code(), throwable));
}
+ private WebClient getClient(URI uri) {
+ if (uri.toString().contains("/read-timeout")) {
+ return clientWithReadTimeout;
+ }
+ return client;
+ }
+
@Override
protected void configure(HttpClientTestOptions options) {
// Not supported yet: https://github.com/line/armeria/issues/2489
options.disableTestRedirects();
// armeria requests can't be reused
options.disableTestReusedRequest();
+ options.enableTestReadTimeout();
Set<AttributeKey<?>> extra = new HashSet<>();
extra.add(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH);

Enable read timeout test for armeria (#6155)