diff --git a/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/http/netty4/Netty4IncrementalRequestHandlingIT.java b/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/http/netty4/Netty4IncrementalRequestHandlingIT.java index 3072178eaed4e..9615286c65235 100644 --- a/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/http/netty4/Netty4IncrementalRequestHandlingIT.java +++ b/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/http/netty4/Netty4IncrementalRequestHandlingIT.java @@ -61,10 +61,10 @@ import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; +import org.elasticsearch.core.TimeValue; import org.elasticsearch.features.NodeFeature; import org.elasticsearch.http.HttpBodyTracer; import org.elasticsearch.http.HttpServerTransport; -import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.index.IndexingPressure; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; @@ -107,6 +107,8 @@ import static io.netty.handler.codec.http.HttpHeaderValues.APPLICATION_JSON; import static io.netty.handler.codec.http.HttpMethod.POST; import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_CLIENT_STATS_MAX_CLOSED_CHANNEL_AGE; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_MAX_CONTENT_LENGTH; import static org.hamcrest.Matchers.anEmptyMap; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.greaterThan; @@ -120,12 +122,13 @@ public class Netty4IncrementalRequestHandlingIT extends ESNetty4IntegTestCase { @Override protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) { - Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal, otherSettings)); - builder.put( - HttpTransportSettings.SETTING_HTTP_MAX_CONTENT_LENGTH.getKey(), - ByteSizeValue.of(MAX_CONTENT_LENGTH, ByteSizeUnit.BYTES) - ); - return builder.build(); + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal, otherSettings)) + // reduce max content length just to cut down test duration + .put(SETTING_HTTP_MAX_CONTENT_LENGTH.getKey(), ByteSizeValue.of(MAX_CONTENT_LENGTH, ByteSizeUnit.BYTES)) + // disable time-based expiry of channel stats since we assert that the total request size accumulates + .put(SETTING_HTTP_CLIENT_STATS_MAX_CLOSED_CHANNEL_AGE.getKey(), TimeValue.MAX_VALUE) + .build(); } // ensure empty http content has single 0 size chunk @@ -436,7 +439,7 @@ public void testHttpClientStats() throws Exception { clientContext.channel().writeAndFlush(httpRequest(opaqueId, contentSize)); clientContext.channel().writeAndFlush(randomContent(contentSize, true)); final var handler = clientContext.awaitRestChannelAccepted(opaqueId); - handler.readAllBytes(); + assertEquals(contentSize, handler.readAllBytes()); handler.sendResponse(new RestResponse(RestStatus.OK, "")); assertEquals(totalBytesSent, clientContext.transportStatsRequestBytesSize()); }