siddharthteotia commented on a change in pull request #4446: Add support in the
rebalancer for the user to provide minimum number of serving replicas
URL: https://github.com/apache/incubator-pinot/pull/4446#discussion_r307190018
##########
File path:
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/util/TableRebalancerTest.java
##########
@@ -117,4 +119,332 @@ public void downtimeUpdateWithNoCommonElements() {
Map<String, String> tempMap = current.getRecord().getMapField(segmentId);
Assert.assertTrue(EqualityUtils.isEqual(tempMap, targetMap));
}
+
+ /**
+ * Test for now downtime rebalance with no common hosts between
+ * current and target ideal state and a request to keep minimum
+ * 2 replicas up while rebalancing
+ */
+ @Test
+ public void noDowntimeUpdateWithNoCommonHostsAndTwoMinReplicas() {
+ IdealState currentIdealState = new IdealState("rebalance");
+ currentIdealState.setPartitionState(segmentId, "host1", "ONLINE");
+ currentIdealState.setPartitionState(segmentId, "host2", "ONLINE");
+ currentIdealState.setPartitionState(segmentId, "host3", "ONLINE");
+
+ IdealState targetIdealState = new IdealState("rebalance");
+ targetIdealState.setPartitionState(segmentId, "host4", "ONLINE");
+ targetIdealState.setPartitionState(segmentId, "host5", "ONLINE");
+ targetIdealState.setPartitionState(segmentId, "host6", "ONLINE");
+
+ // copying the current ideal state here to mimic how
+ // TableRebalancer.rebalance() works between multiple invocations to
+ // updateSegmentIfNeeded. In other words, the latter function updates the
+ // passed in copy of current ideal state, returns and the updated state is
+ // then written into ZK as the latest current ideal state. Before
+ // updateSegmentIfNeeded() again, the rebalance() method gets
+ // the current ideal state from ZK
+ IdealState toUpdateIdealState =
HelixHelper.cloneIdealState(currentIdealState);
+
+ // test for no-downtime rebalance with minimum 2 replicas of each segment
to be kept up
+
noDowntime.setProperty(RebalanceUserConfigConstants.MIN_REPLICAS_TO_KEEPUP_FOR_NODOWNTIME,
2);
+
+ final TableRebalancer rebalancer = new TableRebalancer(null, null, null);
+ final Map<String, String> targetSegmentInstancesMap =
targetIdealState.getInstanceStateMap(segmentId);
+
+ // STEP 1
+ rebalancer.updateSegmentIfNeeded(segmentId,
currentIdealState.getRecord().getMapField(segmentId),
+ targetSegmentInstancesMap, toUpdateIdealState, noDowntime);
+ // After step 1, let's assume that
+ // toUpdateIdealState : { SEGMENT1 : { host4 : online, host2 : online,
host3 : online } }
+ // Essentially, host1 from current state got replaced with host4 from
target state
+ // Now, what we are checking is that between toUpdate and target ideal
state,
+ // there is exactly 1 host in common
+ verifyStateForMinReplicaConstraint(toUpdateIdealState, targetIdealState,
1, true);
Review comment:
stats are verified further in the test
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]