pnowojski 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_r403471073
 
 

 ##########
 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:
   Yes, we are discouraging using mockito for various of reasons:
   
https://flink.apache.org/contributing/code-style-and-quality-common.html#design-for-testability
 (avoid mockito section)
   
https://docs.google.com/presentation/d/1fZlTjOJscwmzYadPGl23aui6zopl94Mn5smG-rB0qT8/edit?usp=sharing

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to