reswqa commented on code in PR #23957:
URL: https://github.com/apache/flink/pull/23957#discussion_r1446971558


##########
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/storage/TieredStorageMemoryManagerImplTest.java:
##########
@@ -242,19 +173,49 @@ void testCanNotTransferOwnershipForEvent() throws 
IOException {
                 .isInstanceOf(IllegalStateException.class);
     }
 
+    @Test
+    void testEnsureCapacity() throws IOException {
+        final int numBuffers = 5;
+        final int guaranteedReclaimableBuffers = 3;
+
+        BufferPool bufferPool = globalPool.createBufferPool(numBuffers, 
numBuffers);
+        TieredStorageMemoryManagerImpl storageMemoryManager =
+                createStorageMemoryManager(
+                        bufferPool,
+                        Arrays.asList(
+                                new TieredStorageMemorySpec(
+                                        new Object(), 
guaranteedReclaimableBuffers, true),
+                                new TieredStorageMemorySpec(this, 0, false)));
+        assertThat(storageMemoryManager.ensureCapacity(0)).isTrue();
+        assertThat(bufferPool.bestEffortGetNumOfUsedBuffers())
+                .isEqualTo(guaranteedReclaimableBuffers);
+
+        assertThat(storageMemoryManager.ensureCapacity(numBuffers - 
guaranteedReclaimableBuffers))
+                .isTrue();
+        
assertThat(bufferPool.bestEffortGetNumOfUsedBuffers()).isEqualTo(numBuffers);
+
+        assertThat(
+                        storageMemoryManager.ensureCapacity(
+                                numBuffers - guaranteedReclaimableBuffers + 1))

Review Comment:
   Ah, make sense.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to