anonymouscodeholic commented on a change in pull request #13688:
URL: https://github.com/apache/flink/pull/13688#discussion_r511598641



##########
File path: 
flink-state-backends/flink-statebackend-rocksdb/src/test/java/org/apache/flink/contrib/streaming/state/RocksDBOperationsUtilsTest.java
##########
@@ -78,6 +81,60 @@ public void testPathExceptionOnWindows() throws Exception {
                }
        }
 
+       @Test
+       public void testSanityCheckArenaBlockSize() {
+               long testWriteBufferSize = 56 * 1024 * 1024L;
+               long testDefaultArenaSize = testWriteBufferSize / 8;
+               long testValidArenaSize = testWriteBufferSize / 7;
+               long testInvalidArenaSize = testWriteBufferSize / 7 - 8L;
+               List<TestData> tests = Arrays.asList(
+                               new TestData(testWriteBufferSize, 0, 
testInvalidArenaSize, false),
+                               new TestData(testWriteBufferSize, 
testDefaultArenaSize, testInvalidArenaSize, false),
+                               new TestData(testWriteBufferSize, 0, 
testValidArenaSize, true),
+                               new TestData(testWriteBufferSize, 
testDefaultArenaSize, testValidArenaSize, true)
+               );
+
+               for (TestData test : tests) {
+                       long writeBufferSize = test.getWriteBufferSize();
+                       long arenaBlockSizeConfigured = 
test.getArenaBlockSizeConfigured();
+                       long writeBufferManagerCapacity = 
test.getWriteBufferManagerCapacity();
+                       boolean expected = test.getExpectedResult();
+
+                       boolean sanityCheckResult = 
RocksDBOperationUtils.sanityCheckArenaBlockSize(writeBufferSize, 
arenaBlockSizeConfigured, writeBufferManagerCapacity);
+                       assertThat(sanityCheckResult, is(expected));
+               }
+       }
+
+       private static class TestData {
+               private final long writeBufferSize;
+               private final long arenaBlockSizeConfigured;
+               private final long writeBufferManagerCapacity;
+               private final boolean expectedResult;
+
+               public TestData(long writeBufferSize, long 
arenaBlockSizeConfigured, long writeBufferManagerCapacity, boolean 
expectedResult) {
+                       this.writeBufferSize = writeBufferSize;
+                       this.arenaBlockSizeConfigured = 
arenaBlockSizeConfigured;
+                       this.writeBufferManagerCapacity = 
writeBufferManagerCapacity;
+                       this.expectedResult = expectedResult;
+               }
+
+               public long getWriteBufferSize() {
+                       return writeBufferSize;
+               }
+
+               public long getArenaBlockSizeConfigured() {
+                       return arenaBlockSizeConfigured;
+               }
+
+               public long getWriteBufferManagerCapacity() {
+                       return writeBufferManagerCapacity;
+               }
+
+               public boolean getExpectedResult() {
+                       return expectedResult;
+               }
+       }

Review comment:
       I changed the test `testSanityCheckArenaBlockSize` to the suggested 
version and added one more `assertThat`. Also, minor tweaks in the error 
messages in asserts.




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


Reply via email to