Skip to content

Commit

Permalink
Cover new method in junit test
Browse files Browse the repository at this point in the history
  • Loading branch information
allenxwang committed Nov 26, 2024
1 parent eb899fa commit 7eb541d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,11 @@ Map<Integer, Integer> getSortedBrokerIdToInterBrokerMoveTaskCountMap() {
));
return resultMap;
}

/*
* Package private for testing.
*/
Map<Integer, SortedSet<ExecutionTask>> getInterPartMoveTasksByBrokerId() {
return _interPartMoveTasksByBrokerId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import java.util.SortedSet;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.DescribeReplicaLogDirsResult;
import org.apache.kafka.common.Cluster;
Expand Down Expand Up @@ -353,6 +354,13 @@ public void testGetInterBrokerPartitionMovementWithMinIsrTasks() {
readyBrokers.put(4, 5);
readyBrokers.put(5, 6);
prioritizeOneAboveMinIsrMovementPlanner.addExecutionProposals(proposals, strategyOptions, null);
Map<Integer, Integer> countMap = prioritizeOneAboveMinIsrMovementPlanner.getSortedBrokerIdToInterBrokerMoveTaskCountMap();
Map<Integer, SortedSet<ExecutionTask>> taskMap = prioritizeOneAboveMinIsrMovementPlanner.getInterPartMoveTasksByBrokerId();
for (Map.Entry<Integer, Integer> entry : countMap.entrySet()) {
int brokerId = entry.getKey();
int count = entry.getValue();
assertEquals(taskMap.get(brokerId).size(), count);
}
List<ExecutionTask> partitionMovementTasks
= prioritizeOneAboveMinIsrMovementPlanner.getInterBrokerReplicaMovementTasks(readyBrokers, Collections.emptySet(), _defaultPartitionsMaxCap);
assertEquals("First task", _rf4PartitionMovement2, partitionMovementTasks.get(0).proposal());
Expand Down

0 comments on commit 7eb541d

Please sign in to comment.