diff options
author | zpencer <spencerfang@google.com> | 2017-11-09 17:13:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-09 17:13:04 -0800 |
commit | 9ae5f116b5abecedb78d1ed57f3754af91c4cb5e (patch) | |
tree | 3db40f13b133c5017f8b07cc88fbc703e9d4d803 /netty | |
parent | 970785d82b7441fae6d8baa0216cbf4856c9e67e (diff) | |
download | grpc-grpc-java-9ae5f116b5abecedb78d1ed57f3754af91c4cb5e.tar.gz |
netty: TransportTracer test for local window update (#3710)
Diffstat (limited to 'netty')
-rw-r--r-- | netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java b/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java index 008ba23ef..707c4e731 100644 --- a/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java @@ -759,23 +759,37 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand } @Test - public void transportTracer_windowSize() throws Exception { + public void transportTracer_windowUpdate_remote() throws Exception { flowControlWindow = 1048576; // 1MiB manualSetUp(); - { - TransportTracer.Stats stats = transportTracer.getStats(); - assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE, stats.remoteFlowControlWindow); - assertEquals(flowControlWindow, stats.localFlowControlWindow); - } + TransportTracer.Stats before = transportTracer.getStats(); + assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE, before.remoteFlowControlWindow); + assertEquals(flowControlWindow, before.localFlowControlWindow); - { - ByteBuf serializedSettings = windowUpdate(0, 1000); - channelRead(serializedSettings); - TransportTracer.Stats stats = transportTracer.getStats(); - assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE + 1000, - stats.remoteFlowControlWindow); - assertEquals(flowControlWindow, stats.localFlowControlWindow); - } + ByteBuf serializedSettings = windowUpdate(0, 1000); + channelRead(serializedSettings); + TransportTracer.Stats after = transportTracer.getStats(); + assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE + 1000, + after.remoteFlowControlWindow); + assertEquals(flowControlWindow, after.localFlowControlWindow); + } + + @Test + public void transportTracer_windowUpdate_local() throws Exception { + manualSetUp(); + TransportTracer.Stats before = transportTracer.getStats(); + assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE, before.remoteFlowControlWindow); + assertEquals(flowControlWindow, before.localFlowControlWindow); + + // If the window size is below a certain threshold, netty will wait to apply the update. + // Use a large increment to be sure that it exceeds the threshold. + connection().local().flowController().incrementWindowSize( + connection().connectionStream(), 8 * Http2CodecUtil.DEFAULT_WINDOW_SIZE); + + TransportTracer.Stats after = transportTracer.getStats(); + assertEquals(Http2CodecUtil.DEFAULT_WINDOW_SIZE, after.remoteFlowControlWindow); + assertEquals(flowControlWindow + 8 * Http2CodecUtil.DEFAULT_WINDOW_SIZE, + after.localFlowControlWindow); } private void createStream() throws Exception { |