stressTest() — netty Function Reference
Architecture documentation for the stressTest() function in Http2ConnectionRoundtripTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 198b8cfc_7eb9_7e37_448a_86f7aee9ac76["stressTest()"] 0d6189e8_c033_39ff_d087_9019351440fe["Http2ConnectionRoundtripTest"] 198b8cfc_7eb9_7e37_448a_86f7aee9ac76 -->|defined in| 0d6189e8_c033_39ff_d087_9019351440fe 1dd685b8_9b56_5b35_70ca_7f2bf9016254["bootstrapEnv()"] 198b8cfc_7eb9_7e37_448a_86f7aee9ac76 -->|calls| 1dd685b8_9b56_5b35_70ca_7f2bf9016254 f8a98f5a_5b4f_5e46_24a0_b03b1f68c64a["setClientGracefulShutdownTime()"] 198b8cfc_7eb9_7e37_448a_86f7aee9ac76 -->|calls| f8a98f5a_5b4f_5e46_24a0_b03b1f68c64a style 198b8cfc_7eb9_7e37_448a_86f7aee9ac76 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java lines 1057–1143
@Test
public void stressTest() throws Exception {
final Http2Headers headers = dummyHeaders();
final Http2Headers trailers = dummyTrailers();
int length = 10;
final ByteBuf data = randomBytes(length);
final String dataAsHex = ByteBufUtil.hexDump(data);
final long pingData = 8;
final int numStreams = 2000;
// Collect all the ping buffers as we receive them at the server.
final long[] receivedPings = new long[numStreams];
doAnswer(new Answer<Void>() {
int nextIndex;
@Override
public Void answer(InvocationOnMock in) throws Throwable {
receivedPings[nextIndex++] = (Long) in.getArguments()[1];
return null;
}
}).when(serverListener).onPingRead(any(ChannelHandlerContext.class), any(Long.class));
// Collect all the data buffers as we receive them at the server.
final StringBuilder[] receivedData = new StringBuilder[numStreams];
doAnswer(new Answer<Integer>() {
@Override
public Integer answer(InvocationOnMock in) throws Throwable {
int streamId = (Integer) in.getArguments()[1];
ByteBuf buf = (ByteBuf) in.getArguments()[2];
int padding = (Integer) in.getArguments()[3];
int processedBytes = buf.readableBytes() + padding;
int streamIndex = (streamId - 3) / 2;
StringBuilder builder = receivedData[streamIndex];
if (builder == null) {
builder = new StringBuilder(dataAsHex.length());
receivedData[streamIndex] = builder;
}
builder.append(ByteBufUtil.hexDump(buf));
return processedBytes;
}
}).when(serverListener).onDataRead(any(ChannelHandlerContext.class), anyInt(),
any(ByteBuf.class), anyInt(), anyBoolean());
try {
bootstrapEnv(numStreams * length, 1, numStreams * 4 + 1 , numStreams);
runInChannel(clientChannel, new Http2Runnable() {
@Override
public void run() throws Http2Exception {
int upperLimit = 3 + 2 * numStreams;
for (int streamId = 3; streamId < upperLimit; streamId += 2) {
// Send a bunch of data on each stream.
http2Client.encoder().writeHeaders(ctx(), streamId, headers, 0, (short) 16,
false, 0, false, newPromise());
http2Client.encoder().writePing(ctx(), false, pingData,
newPromise());
http2Client.encoder().writeData(ctx(), streamId, data.retainedSlice(), 0,
false, newPromise());
// Write trailers.
http2Client.encoder().writeHeaders(ctx(), streamId, trailers, 0, (short) 16,
false, 0, true, newPromise());
http2Client.flush(ctx());
}
}
});
// Wait for all frames to be received.
assertTrue(serverSettingsAckLatch.await(60, SECONDS));
assertTrue(trailersLatch.await(60, SECONDS));
verify(serverListener, times(numStreams)).onHeadersRead(any(ChannelHandlerContext.class), anyInt(),
eq(headers), eq(0), eq((short) 16), eq(false), eq(0), eq(false));
verify(serverListener, times(numStreams)).onHeadersRead(any(ChannelHandlerContext.class), anyInt(),
eq(trailers), eq(0), eq((short) 16), eq(false), eq(0), eq(true));
verify(serverListener, times(numStreams)).onPingRead(any(ChannelHandlerContext.class),
any(long.class));
verify(serverListener, never()).onDataRead(any(ChannelHandlerContext.class),
anyInt(), any(ByteBuf.class), eq(0), eq(true));
for (StringBuilder builder : receivedData) {
assertEquals(dataAsHex, builder.toString());
}
for (long receivedPing : receivedPings) {
assertEquals(pingData, receivedPing);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does stressTest() do?
stressTest() is a function in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java.
Where is stressTest() defined?
stressTest() is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java at line 1057.
What does stressTest() call?
stressTest() calls 2 function(s): bootstrapEnv, setClientGracefulShutdownTime.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free