wsry commented on a change in pull request #11567: [FLINK-16645] Limit the 
maximum backlogs in subpartitions
URL: https://github.com/apache/flink/pull/11567#discussion_r402934181
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/ResultPartitionTest.java
 ##########
 @@ -351,6 +352,94 @@ private void testReleaseMemory(final ResultPartitionType 
resultPartitionType) th
                }
        }
 
+       /**
+        * Tests {@link ResultPartition#getAvailableFuture()}.
+        */
+       @Test
+       public void testIsAvailableOrNot() throws IOException, 
InterruptedException {
+               final int numAllBuffers = 10;
+               final NettyShuffleEnvironment network = new 
NettyShuffleEnvironmentBuilder()
+                               .setNumNetworkBuffers(numAllBuffers).build();
+               final ResultPartition resultPartition = 
createPartition(network, ResultPartitionType.PIPELINED, 1);
+
+               try {
+                       resultPartition.setup();
+
+                       resultPartition.getBufferPool().setNumBuffers(2);
+
+                       
assertTrue(resultPartition.getAvailableFuture().isDone());
+
+                       resultPartition.getBufferBuilder();
+                       resultPartition.getBufferBuilder();
+                       
assertFalse(resultPartition.getAvailableFuture().isDone());
+               } finally {
+                       resultPartition.release();
+                       network.close();
+               }
+       }
+
+       /**
+        * Tests {@link ResultPartition#getAvailableFuture()} with configured 
max backlogs.
+        */
+       @Test
+       public void testMaxBuffersPerChannelAndAvailability() throws 
IOException, InterruptedException {
+               final int numAllBuffers = 10;
+               final NettyShuffleEnvironment network = new 
NettyShuffleEnvironmentBuilder()
+                               .setNumNetworkBuffers(numAllBuffers).build();
+               final ResultPartition resultPartition = new 
ResultPartitionBuilder()
+                               
.setResultPartitionManager(network.getResultPartitionManager())
+                               
.setupBufferPoolFactoryFromNettyShuffleEnvironment(network)
+                               
.setResultPartitionType(ResultPartitionType.PIPELINED)
+                               .setNumberOfSubpartitions(2)
+                               .setMaxBuffersPerChannel(1)
+                               .build();
+
+               try {
+                       resultPartition.setup();
+
+                       
assertTrue(resultPartition.getAvailableFuture().isDone());
+
+                       BufferAvailabilityListener listener0 = 
mock(BufferAvailabilityListener.class);
 
 Review comment:
   I heard from other guys that the community is trying to avoid using 
```mock```, it's not a problem for me if there is no concern from other people.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to