Skip to content

Commit deb4797

Browse files
Improve readability of TestInstanceOperationEvacuationCancel
Extract duplicated resource creation into createAdditionalMasterSlaveResources() helper method. Add comments explaining _stateModelDelay sign convention (negative = slow upward transitions, positive = slow downward transitions) and why cluster convergence succeeds only because state transition cancellation is triggered by the ENABLE operation. Made-with: Cursor
1 parent 897583f commit deb4797

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

helix-core/src/test/java/org/apache/helix/integration/rebalancer/TestInstanceOperationEvacuationCancel.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,30 @@
1515

1616
public class TestInstanceOperationEvacuationCancel extends TestInstanceOperationBase {
1717

18-
@Test
19-
public void testEvacuateAndCancelBeforeBootstrapFinish() throws Exception {
20-
System.out.println(
21-
"START TestInstanceOperationEvacuationCancel.testEvacuateAndCancelBeforeBootstrapFinish() at "
22-
+ new Date(System.currentTimeMillis()));
23-
24-
enabledTopologyAwareRebalance();
25-
18+
/**
19+
* Adds two extra MasterSlave resources to increase the partition count so that
20+
* evacuation has enough work to avoid completing prematurely during cancel tests.
21+
*/
22+
private void createAdditionalMasterSlaveResources() throws InterruptedException {
2623
createResourceWithDelayedRebalance(CLUSTER_NAME, "TEST_DB3_DELAYED_CRUSHED", "MasterSlave",
2724
PARTITIONS, REPLICA, REPLICA - 1, 200000, CrushEdRebalanceStrategy.class.getName());
2825
_allDBs.add("TEST_DB3_DELAYED_CRUSHED");
2926
createResourceWithWagedRebalance(CLUSTER_NAME, "TEST_DB4_DELAYED_WAGED", "MasterSlave",
3027
PARTITIONS, REPLICA, REPLICA - 1);
3128
_allDBs.add("TEST_DB4_DELAYED_WAGED");
3229
Assert.assertTrue(_clusterVerifier.verifyByPolling());
30+
}
3331

32+
@Test
33+
public void testEvacuateAndCancelBeforeBootstrapFinish() throws Exception {
34+
System.out.println(
35+
"START TestInstanceOperationEvacuationCancel.testEvacuateAndCancelBeforeBootstrapFinish() at "
36+
+ new Date(System.currentTimeMillis()));
37+
38+
enabledTopologyAwareRebalance();
39+
createAdditionalMasterSlaveResources();
40+
41+
// Negative delay = slow upward transitions (OFFLINE→SLAVE, SLAVE→MASTER)
3442
_stateModelDelay = -10000L;
3543
String instanceToEvacuate = _participants.get(0).getInstanceName();
3644
_gSetupTool.getClusterManagementTool().setInstanceOperation(CLUSTER_NAME, instanceToEvacuate,
@@ -60,6 +68,8 @@ public void testEvacuateAndCancelBeforeBootstrapFinish() throws Exception {
6068
validateAssignmentInEv(assignment.get(resource));
6169
}
6270

71+
// ST delay exceeds verifier timeout, so convergence only succeeds because
72+
// cancelling the evacuation (ENABLE) triggers state transition cancellation.
6373
Assert.assertTrue(_clusterVerifier.verifyByPolling());
6474

6575
assignment = getEVs();
@@ -77,15 +87,9 @@ public void testEvacuateAndCancelBeforeDropFinish() throws Exception {
7787
+ new Date(System.currentTimeMillis()));
7888

7989
enabledTopologyAwareRebalance();
90+
createAdditionalMasterSlaveResources();
8091

81-
createResourceWithDelayedRebalance(CLUSTER_NAME, "TEST_DB3_DELAYED_CRUSHED", "MasterSlave",
82-
PARTITIONS, REPLICA, REPLICA - 1, 200000, CrushEdRebalanceStrategy.class.getName());
83-
_allDBs.add("TEST_DB3_DELAYED_CRUSHED");
84-
createResourceWithWagedRebalance(CLUSTER_NAME, "TEST_DB4_DELAYED_WAGED", "MasterSlave",
85-
PARTITIONS, REPLICA, REPLICA - 1);
86-
_allDBs.add("TEST_DB4_DELAYED_WAGED");
87-
Assert.assertTrue(_clusterVerifier.verifyByPolling());
88-
92+
// Positive delay = slow downward transitions (MASTER→SLAVE, SLAVE→OFFLINE, OFFLINE→DROPPED)
8993
_stateModelDelay = 10000L;
9094

9195
String instanceToEvacuate = _participants.get(0).getInstanceName();

0 commit comments

Comments
 (0)