Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4533#discussion_r153456919
  
    --- Diff: 
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/netty/PartitionRequestClientHandlerTest.java
 ---
    @@ -122,21 +136,33 @@ public void testReceiveEmptyBuffer() throws Exception 
{
         */
        @Test
        public void testReceiveBuffer() throws Exception {
    -           final Buffer buffer = TestBufferFactory.createBuffer();
    -           final RemoteInputChannel inputChannel = 
mock(RemoteInputChannel.class);
    -           when(inputChannel.getInputChannelId()).thenReturn(new 
InputChannelID());
    -           when(inputChannel.requestBuffer()).thenReturn(buffer);
    -
    -           final int backlog = 2;
    -           final BufferResponse bufferResponse = createBufferResponse(
    -                   TestBufferFactory.createBuffer(), 0, 
inputChannel.getInputChannelId(), backlog);
    -
    -           final CreditBasedClientHandler client = new 
CreditBasedClientHandler();
    -           client.addInputChannel(inputChannel);
    -
    -           client.channelRead(mock(ChannelHandlerContext.class), 
bufferResponse);
    -
    -           verify(inputChannel, times(1)).onBuffer(buffer, 0, backlog);
    +           final NetworkBufferPool networkBufferPool = new 
NetworkBufferPool(10, 32, MemoryType.HEAP);
    +           final SingleInputGate inputGate = createSingleInputGate();
    +           final RemoteInputChannel inputChannel = 
spy(createRemoteInputChannel(inputGate));
    +           
inputGate.setInputChannel(inputChannel.getPartitionId().getPartitionId(), 
inputChannel);
    +           try {
    +                   final BufferPool bufferPool = 
networkBufferPool.createBufferPool(8, 8);
    +                   inputGate.setBufferPool(bufferPool);
    +                   inputGate.assignExclusiveSegments(networkBufferPool, 2);
    +
    +                   final int backlog = 2;
    +                   final BufferResponse bufferResponse = 
createBufferResponse(
    +                           inputChannel.requestBuffer(), 0, 
inputChannel.getInputChannelId(), backlog);
    +
    +                   final CreditBasedClientHandler handler = new 
CreditBasedClientHandler();
    +                   handler.addInputChannel(inputChannel);
    +
    +                   handler.channelRead(mock(ChannelHandlerContext.class), 
bufferResponse);
    +
    +                   verify(inputChannel, 
times(1)).onBuffer(any(Buffer.class), anyInt(), anyInt());
    +                   verify(inputChannel, times(1)).onSenderBacklog(backlog);
    +           } finally {
    +                   // Release all the buffer resources
    +                   inputChannel.releaseAllResources();
    --- End diff --
    
    call `inputGate.releaseAllResources();` instead


---

Reply via email to