dcapwell commented on code in PR #4087: URL: https://github.com/apache/cassandra/pull/4087#discussion_r2047823892
########## test/unit/org/apache/cassandra/db/compaction/unified/ControllerTest.java: ########## @@ -121,6 +121,50 @@ public void testValidateOptionsIntegers() testValidateOptions(true); } + @Test + public void testValidateOptionsInvalidTargetSSTableSize() + { + //Test 1: TARGET_SSTABLE_SIZE_OPTION = 12E899, the value reported in CASSANDRA-20398 + try { + Map<String, String> options = new HashMap<>(); + options.putIfAbsent(Controller.TARGET_SSTABLE_SIZE_OPTION, "12E899"); + Controller.validateOptions(options); + fail("TARGET_SSTABLE_SIZE_OPTION = 12E899 should have caused exception"); + } catch(ConfigurationException e) { + } + + //TEST 2: TARGET_SSTABLE_SIZE_OPTION > LONG.MAX_VALUE + try { + Map<String, String> options = new HashMap<>(); + options.putIfAbsent(Controller.TARGET_SSTABLE_SIZE_OPTION, "9223372036854775907"); + Controller.validateOptions(options); + fail("Passing TARGET_SSTABLE_SIZE_OPTION > LONG.MAX_VALUE should have caused exception"); + } catch(ConfigurationException e) { + } + + //TEST 3: TARGET_SSTABLE_SIZE_OPTION < Default MIN_TARGET_SSTABLE_SIZE (1048576) + try { + Map<String, String> options = new HashMap<>(); + options.putIfAbsent(Controller.TARGET_SSTABLE_SIZE_OPTION, "1048000"); + Controller.validateOptions(options); + fail("Passing TARGET_SSTABLE_SIZE_OPTION < MIN_TARGET_SSTABLE_SIZE should have caused exception"); + } catch(ConfigurationException e) { + } + + //TEST 4: Verifying if TARGET_SSTABLE_SIZE_OPTION (3650722199) < MIN_TARGET_SSTABLE_SIZE (2581450423) + // Previously, TARGET_SSTABLE_SIZE_OPTION * 0.7 was stored as Integer which would 3650722199 * 0.7 = 2147483647 + // By storing it in a Long, 3650722199 * 0.7 = 2581450424. If TARGET_SSTABLE_SIZE_OPTION * 0.7 is truncated, + //this test case will fail + try { + Map<String, String> options = new HashMap<>(); + options.putIfAbsent(Controller.TARGET_SSTABLE_SIZE_OPTION, "3650722199 B"); + options.putIfAbsent(Controller.MIN_SSTABLE_SIZE_OPTION, "2581450423 B"); + Controller.validateOptions(options); + } catch(ConfigurationException e) { Review Comment: remove try/catch with empty catch -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org