Skip to content

Commit a02e13a

Browse files
DaveCTurnerjfreden
authored andcommitted
Improve Netty4IncrementalRequestHandlingIT (elastic#127768)
* Avoid time-based expiry of channel stats or else `testHttpClientStats` will fail if running multiple iterations for more than 5m. * Assert all bytes received in `testHttpClientStats`.
1 parent 79f8f65 commit a02e13a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/http/netty4/Netty4IncrementalRequestHandlingIT.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@
6161
import org.elasticsearch.common.util.CollectionUtils;
6262
import org.elasticsearch.core.Releasable;
6363
import org.elasticsearch.core.Releasables;
64+
import org.elasticsearch.core.TimeValue;
6465
import org.elasticsearch.features.NodeFeature;
6566
import org.elasticsearch.http.HttpBodyTracer;
6667
import org.elasticsearch.http.HttpServerTransport;
67-
import org.elasticsearch.http.HttpTransportSettings;
6868
import org.elasticsearch.index.IndexingPressure;
6969
import org.elasticsearch.plugins.ActionPlugin;
7070
import org.elasticsearch.plugins.Plugin;
@@ -107,6 +107,8 @@
107107
import static io.netty.handler.codec.http.HttpHeaderValues.APPLICATION_JSON;
108108
import static io.netty.handler.codec.http.HttpMethod.POST;
109109
import 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;
110112
import static org.hamcrest.Matchers.anEmptyMap;
111113
import static org.hamcrest.Matchers.empty;
112114
import 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

Comments
 (0)