akalash commented on a change in pull request #17737: URL: https://github.com/apache/flink/pull/17737#discussion_r746493764
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/throughput/BufferDebloaterTest.java ########## @@ -163,6 +164,54 @@ public void testAnnouncedMinBufferSizeEvenDespiteLastDiffLessThanThreshold() { bufferDebloater.recalculateBufferSize(40, numberOfBuffersInUse); } + @Test + public void testSkipUpdate() { + int maxBufferSize = 32768; + int minBufferSize = 256; + double threshold = 0.3; + BufferDebloater bufferDebloater = + testBufferDebloater() + .withDebloatTarget(1000) + .withBufferSize(minBufferSize, maxBufferSize) + // 30 % Threshold. + .withThresholdPercentages((int) (threshold * 100)) + .getBufferDebloater(); + + int currentBufferSize = maxBufferSize / 2; + + OptionalInt optionalInt = bufferDebloater.recalculateBufferSize(currentBufferSize, 1); + assertTrue(optionalInt.isPresent()); + assertEquals(currentBufferSize, optionalInt.getAsInt()); + + // It is true because less than threshold. + assertTrue(bufferDebloater.skipUpdate(currentBufferSize)); + assertTrue(bufferDebloater.skipUpdate(currentBufferSize - 1)); + assertTrue(bufferDebloater.skipUpdate(currentBufferSize + 1)); + + assertTrue( + bufferDebloater.skipUpdate( + currentBufferSize - (int) (currentBufferSize * threshold) + 1)); + assertTrue( + bufferDebloater.skipUpdate( + currentBufferSize + (int) (currentBufferSize * threshold) - 1)); + + // It is false because it reaches threshold. + assertFalse( + bufferDebloater.skipUpdate( + currentBufferSize - (int) (currentBufferSize * threshold))); + assertFalse( + bufferDebloater.skipUpdate( + currentBufferSize + (int) (currentBufferSize * threshold))); + assertFalse(bufferDebloater.skipUpdate(minBufferSize + 1)); Review comment: Yes, it still tests line 95. My target here is to check that border values work as expected. I mean I want to check that for new value which less than current, the range for applying the value between `minBufferSize` and `currentBufferSize - (int) (currentBufferSize * threshold)` but since the `minBufferSize` is checked by other conditions I also checked the `minBufferSize + 1`. The same idea for the maximum. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org