carp84 commented on a change in pull request #10820: 
[FLINK-15512][statebackend] Refactor the mechanism to calculate the cache 
capacity shared among RocksDB instance(s)
URL: https://github.com/apache/flink/pull/10820#discussion_r365564968
 
 

 ##########
 File path: 
flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/RocksDBResourceContainerTest.java
 ##########
 @@ -145,12 +160,34 @@ public void 
testGetColumnFamilyOptionsWithSharedResources() throws Exception {
                container.close();
        }
 
+       @Test
+       public void testCreateSharedResourcesWithExpectedCapacity() throws 
Exception {
+               PowerMockito.spy(RocksDBOperationUtils.class);
+               final AtomicLong actualCacheCapacity = new AtomicLong(0L);
+               // the `createCache` wrapper is introduced due to PowerMockito 
cannot mock on native static method easily.
+               PowerMockito.when(RocksDBOperationUtils.createCache(anyLong(), 
anyDouble()))
+                       .thenAnswer((Answer<LRUCache>) invocation -> {
+                               Object[] arguments = invocation.getArguments();
+                               actualCacheCapacity.set((long) arguments[0]);
+                               return (LRUCache) invocation.callRealMethod();
+                       });
+
+               long totalMemorySize = 2048L;
+               double writeBufferRatio = 0.5;
+               double highPriPoolRatio = 0.1;
+               createSharedResources(totalMemorySize, writeBufferRatio, 
highPriPoolRatio);
+               long expectedCacheCapacity = 
RocksDBOperationUtils.calculateActualCacheCapacity(totalMemorySize, 
writeBufferRatio);
+               assertThat(actualCacheCapacity.get(), 
is(expectedCacheCapacity));
 
 Review comment:
   I suggest to either remove this test, or also add a verification of write 
buffer manager size.

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