anonymouscodeholic commented on a change in pull request #13688: URL: https://github.com/apache/flink/pull/13688#discussion_r511598512
########## File path: flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/RocksDBMemoryControllerUtilsTest.java ########## @@ -91,10 +93,33 @@ public void testCreateSharedResourcesWithExpectedCapacity() { long totalMemorySize = 2048L; double writeBufferRatio = 0.5; double highPriPoolRatio = 0.1; - RocksDBMemoryControllerUtils.allocateRocksDBSharedResources(totalMemorySize, writeBufferRatio, highPriPoolRatio); + RocksDBSharedResources rocksDBSharedResources = RocksDBMemoryControllerUtils.allocateRocksDBSharedResources(totalMemorySize, writeBufferRatio, highPriPoolRatio); long expectedCacheCapacity = RocksDBMemoryControllerUtils.calculateActualCacheCapacity(totalMemorySize, writeBufferRatio); long expectedWbmCapacity = RocksDBMemoryControllerUtils.calculateWriteBufferManagerCapacity(totalMemorySize, writeBufferRatio); + assertThat(actualCacheCapacity.get(), is(expectedCacheCapacity)); assertThat(actualWbmCapacity.get(), is(expectedWbmCapacity)); + assertThat(rocksDBSharedResources.getWriteBufferManagerCapacity(), is(expectedWbmCapacity)); + } + + @Test + public void testCalculateRocksDBDefaultArenaBlockSize() { + long writeBufferSize = 64 * 1024 * 1024; + long expectArenaBlockSize = writeBufferSize / 8; + assertThat(RocksDBMemoryControllerUtils.calculateRocksDBDefaultArenaBlockSize(writeBufferSize), is(expectArenaBlockSize)); + } + + @Test + public void testCalculateRocksDBMutableLimit() { + long bufferSize = 64 * 1024 * 1024; + long limit = bufferSize * 7 / 8; + assertThat(RocksDBMemoryControllerUtils.calculateRocksDBMutableLimit(bufferSize), is(limit)); + } + + @Test + public void testValidateArenaBlockSize() { + long arenaBlockSize = 8 * 1024 * 1024; + assertFalse(RocksDBMemoryControllerUtils.validateArenaBlockSize(arenaBlockSize, (long) (arenaBlockSize * 0.5))); + assertTrue(RocksDBMemoryControllerUtils.validateArenaBlockSize(arenaBlockSize, (long) (arenaBlockSize * 1.5))); } Review comment: I added testing the alignment to `testCalculateRocksDBDefaultArenaBlockSize`. ---------------------------------------------------------------- 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