Skip to content

Commit e3e2481

Browse files
Use base class helpers in testEvacuationWithOfflineInstances
Replace inline hardcoded state filters with ACCEPTABLE_STATE_SET and TOP_STATE_SET from TestInstanceOperationBase. Add validateAssignmentInEv call after verifier for consistent assertion pattern. Remove stray FOLLOWER state that was not in ACCEPTABLE_STATE_SET. Made-with: Cursor
1 parent 9994356 commit e3e2481

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.Date;
66
import java.util.List;
77
import java.util.Map;
8-
import java.util.concurrent.atomic.AtomicInteger;
98

109
import org.apache.helix.HelixException;
1110
import org.apache.helix.constants.InstanceConstants;
@@ -146,21 +145,23 @@ public void testEvacuationWithOfflineInstancesInCluster() throws Exception {
146145
for (String resource : _allDBs) {
147146
ExternalView ev = assignment.get(resource);
148147
for (String partition : ev.getPartitionSet()) {
149-
AtomicInteger activeReplicaCount = new AtomicInteger();
150-
ev.getStateMap(partition).values().stream().filter(
151-
v -> v.equals("MASTER") || v.equals("LEADER") || v.equals("SLAVE")
152-
|| v.equals("FOLLOWER") || v.equals("STANDBY"))
153-
.forEach(v -> activeReplicaCount.getAndIncrement());
154-
if (activeReplicaCount.get() < REPLICA - 1
148+
long activeReplicaCount = ev.getStateMap(partition).values().stream()
149+
.filter(ACCEPTABLE_STATE_SET::contains).count();
150+
if (activeReplicaCount < REPLICA - 1
155151
|| (ev.getStateMap(partition).containsKey(evacuateInstanceName)
156-
&& (ev.getStateMap(partition).get(evacuateInstanceName).equals("MASTER")
157-
|| ev.getStateMap(partition).get(evacuateInstanceName).equals("LEADER")))) {
152+
&& TOP_STATE_SET.contains(
153+
ev.getStateMap(partition).get(evacuateInstanceName)))) {
158154
return false;
159155
}
160156
}
161157
}
162158
return true;
163159
}, 30000);
160+
161+
Map<String, ExternalView> assignment = getEVs();
162+
for (String resource : _allDBs) {
163+
validateAssignmentInEv(assignment.get(resource), REPLICA - 1);
164+
}
164165
}
165166

166167
@Test

0 commit comments

Comments
 (0)