6161import org .elasticsearch .common .util .CollectionUtils ;
6262import org .elasticsearch .core .Releasable ;
6363import org .elasticsearch .core .Releasables ;
64+ import org .elasticsearch .core .TimeValue ;
6465import org .elasticsearch .features .NodeFeature ;
6566import org .elasticsearch .http .HttpBodyTracer ;
6667import org .elasticsearch .http .HttpServerTransport ;
67- import org .elasticsearch .http .HttpTransportSettings ;
6868import org .elasticsearch .index .IndexingPressure ;
6969import org .elasticsearch .plugins .ActionPlugin ;
7070import org .elasticsearch .plugins .Plugin ;
107107import static io .netty .handler .codec .http .HttpHeaderValues .APPLICATION_JSON ;
108108import static io .netty .handler .codec .http .HttpMethod .POST ;
109109import static io .netty .handler .codec .http .HttpVersion .HTTP_1_1 ;
110+ import static org .elasticsearch .http .HttpTransportSettings .SETTING_HTTP_CLIENT_STATS_MAX_CLOSED_CHANNEL_AGE ;
111+ import static org .elasticsearch .http .HttpTransportSettings .SETTING_HTTP_MAX_CONTENT_LENGTH ;
110112import static org .hamcrest .Matchers .anEmptyMap ;
111113import static org .hamcrest .Matchers .empty ;
112114import static org .hamcrest .Matchers .greaterThan ;
@@ -120,12 +122,13 @@ public class Netty4IncrementalRequestHandlingIT extends ESNetty4IntegTestCase {
120122
121123 @ Override
122124 protected Settings nodeSettings (int nodeOrdinal , Settings otherSettings ) {
123- Settings .Builder builder = Settings .builder ().put (super .nodeSettings (nodeOrdinal , otherSettings ));
124- builder .put (
125- HttpTransportSettings .SETTING_HTTP_MAX_CONTENT_LENGTH .getKey (),
126- ByteSizeValue .of (MAX_CONTENT_LENGTH , ByteSizeUnit .BYTES )
127- );
128- return builder .build ();
125+ return Settings .builder ()
126+ .put (super .nodeSettings (nodeOrdinal , otherSettings ))
127+ // reduce max content length just to cut down test duration
128+ .put (SETTING_HTTP_MAX_CONTENT_LENGTH .getKey (), ByteSizeValue .of (MAX_CONTENT_LENGTH , ByteSizeUnit .BYTES ))
129+ // disable time-based expiry of channel stats since we assert that the total request size accumulates
130+ .put (SETTING_HTTP_CLIENT_STATS_MAX_CLOSED_CHANNEL_AGE .getKey (), TimeValue .MAX_VALUE )
131+ .build ();
129132 }
130133
131134 // ensure empty http content has single 0 size chunk
@@ -436,7 +439,7 @@ public void testHttpClientStats() throws Exception {
436439 clientContext .channel ().writeAndFlush (httpRequest (opaqueId , contentSize ));
437440 clientContext .channel ().writeAndFlush (randomContent (contentSize , true ));
438441 final var handler = clientContext .awaitRestChannelAccepted (opaqueId );
439- handler .readAllBytes ();
442+ assertEquals ( contentSize , handler .readAllBytes () );
440443 handler .sendResponse (new RestResponse (RestStatus .OK , "" ));
441444 assertEquals (totalBytesSent , clientContext .transportStatsRequestBytesSize ());
442445 }
0 commit comments