somandal commented on code in PR #15317:
URL: https://github.com/apache/pinot/pull/15317#discussion_r2013206560
##########
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancerClusterStatelessTest.java:
##########
@@ -669,6 +676,93 @@ public void testRebalancePreCheckerDiskUtil()
executorService.shutdown();
}
+ @Test
+ public void testRebalancePreCheckerRebalanceConfig()
+ throws Exception {
+ int numServers = 3;
+
+ for (int i = 0; i < numServers; i++) {
+ String instanceId = "preCheckerRebalanceConfig_" +
SERVER_INSTANCE_ID_PREFIX + i;
+ addFakeServerInstanceToAutoJoinHelixCluster(instanceId, true);
+ }
+
+ ExecutorService executorService = Executors.newFixedThreadPool(10);
+ DefaultRebalancePreChecker preChecker = new DefaultRebalancePreChecker();
+ preChecker.init(_helixResourceManager, executorService, 0.5);
+ TableRebalancer tableRebalancer = new TableRebalancer(_helixManager, null,
null, preChecker,
+ _helixResourceManager.getTableSizeReader());
+ TableConfig tableConfig =
+ new TableConfigBuilder(TableType.REALTIME).setTableName(RAW_TABLE_NAME)
+ .setNumReplicas(2)
+
.setStreamConfigs(FakeStreamConfigUtils.getDefaultLowLevelStreamConfigs().getStreamConfigsMap())
+ .build();
+
+ // Create the table
+ addDummySchema(RAW_TABLE_NAME);
+ _helixResourceManager.addTable(tableConfig);
+
+ // Add the segments
+ int numSegments = 10;
+ for (int i = 0; i < numSegments; i++) {
+ _helixResourceManager.addNewSegment(REALTIME_TABLE_NAME,
+ SegmentMetadataMockUtils.mockSegmentMetadata(RAW_TABLE_NAME,
SEGMENT_NAME_PREFIX + i), null);
+ }
+
+ RebalanceConfig rebalanceConfig = new RebalanceConfig();
+ rebalanceConfig.setDryRun(true);
+ rebalanceConfig.setPreChecks(true);
+
+ // dry-run with default rebalance config
+ RebalanceResult rebalanceResult = tableRebalancer.rebalance(tableConfig,
rebalanceConfig, null);
+ RebalancePreCheckerResult preCheckerResult =
+
rebalanceResult.getPreChecksResult().get(DefaultRebalancePreChecker.REBALANCE_CONFIG_OPTIONS);
+ assertNotNull(preCheckerResult);
+ assertEquals(preCheckerResult.getPreCheckStatus(),
RebalancePreCheckerResult.PreCheckStatus.WARN);
+ assertEquals(preCheckerResult.getMessage(), "includeConsuming is disabled
for a realtime table.\n");
+
+ // trigger bootstrap and bestEfforts warning
+ rebalanceConfig.setIncludeConsuming(true);
+ rebalanceConfig.setBootstrap(true);
+ rebalanceConfig.setBestEfforts(true);
+ rebalanceResult = tableRebalancer.rebalance(tableConfig, rebalanceConfig,
null);
+ preCheckerResult =
rebalanceResult.getPreChecksResult().get(DefaultRebalancePreChecker.REBALANCE_CONFIG_OPTIONS);
+ assertNotNull(preCheckerResult);
+ assertEquals(preCheckerResult.getPreCheckStatus(),
RebalancePreCheckerResult.PreCheckStatus.WARN);
+ assertEquals(preCheckerResult.getMessage(),
+ "bestEfforts is enabled, only enable it if you know what you are
doing\n"
+ + "bootstrap is enabled which can cause a large amount of data
movement, double check if this is "
+ + "intended\n");
+
+ // trigger downtime warning
+ TableConfig newTableConfig =
+ new
TableConfigBuilder(TableType.REALTIME).setTableName(RAW_TABLE_NAME).setNumReplicas(3).build();
+
+ rebalanceConfig.setBootstrap(false);
+ rebalanceConfig.setBestEfforts(false);
+ rebalanceConfig.setDowntime(true);
Review Comment:
can we have a test with `setDowntime(true)` and `numReplicas = 1` to verify
that the check passes?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]