|
51 | 51 | import java.util.stream.Collectors;
|
52 | 52 |
|
53 | 53 | import static org.opensearch.cluster.routing.UnassignedInfo.Reason.CLUSTER_RECOVERED;
|
| 54 | +import static org.opensearch.cluster.routing.UnassignedInfo.Reason.INDEX_CREATED; |
54 | 55 |
|
55 | 56 | public class PrimaryShardBatchAllocatorTests extends OpenSearchAllocationTestCase {
|
56 | 57 |
|
@@ -283,40 +284,16 @@ public void testAllocateUnassignedBatchOnTimeoutWithNoMatchingPrimaryShards() {
|
283 | 284 | assertEquals(0, ignoredShards.size());
|
284 | 285 | }
|
285 | 286 |
|
286 |
| - public void testAllocateUnassignedBatchOnTimeoutWithNonPrimaryShards() { |
| 287 | + public void testAllocateUnassignedBatchOnTimeoutSkipIgnoringNewPrimaryShards() { |
287 | 288 | ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
|
288 | 289 | AllocationDeciders allocationDeciders = randomAllocationDeciders(Settings.builder().build(), clusterSettings, random());
|
289 | 290 | setUpShards(1);
|
290 |
| - final RoutingAllocation routingAllocation = routingAllocationWithOnePrimary(allocationDeciders, CLUSTER_RECOVERED, "allocId-0"); |
| 291 | + final RoutingAllocation routingAllocation = routingAllocationWithOnePrimary(allocationDeciders, INDEX_CREATED); |
| 292 | + ShardRouting shardRouting = routingAllocation.routingTable().getIndicesRouting().get("test").shard(shardId.id()).primaryShard(); |
291 | 293 |
|
292 |
| - ShardRouting shardRouting = routingAllocation.routingTable() |
293 |
| - .getIndicesRouting() |
294 |
| - .get("test") |
295 |
| - .shard(shardId.id()) |
296 |
| - .replicaShards() |
297 |
| - .get(0); |
298 | 294 | Set<ShardId> shardIds = new HashSet<>();
|
299 | 295 | shardIds.add(shardRouting.shardId());
|
300 |
| - batchAllocator.allocateUnassignedBatchOnTimeout(shardIds, routingAllocation, false); |
301 |
| - |
302 |
| - List<ShardRouting> ignoredShards = routingAllocation.routingNodes().unassigned().ignored(); |
303 |
| - assertEquals(1, ignoredShards.size()); |
304 |
| - } |
305 |
| - |
306 |
| - public void testAllocateUnassignedBatchOnTimeoutWithNoShards() { |
307 |
| - ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); |
308 |
| - AllocationDeciders allocationDeciders = randomAllocationDeciders(Settings.builder().build(), clusterSettings, random()); |
309 |
| - setUpShards(1); |
310 |
| - final RoutingAllocation routingAllocation = routingAllocationWithOnePrimary(allocationDeciders, CLUSTER_RECOVERED, "allocId-0"); |
311 |
| - |
312 |
| - ShardRouting shardRouting = routingAllocation.routingTable() |
313 |
| - .getIndicesRouting() |
314 |
| - .get("test") |
315 |
| - .shard(shardId.id()) |
316 |
| - .replicaShards() |
317 |
| - .get(0); |
318 |
| - Set<ShardId> shardIds = new HashSet<>(); |
319 |
| - batchAllocator.allocateUnassignedBatchOnTimeout(shardIds, routingAllocation, false); |
| 296 | + batchAllocator.allocateUnassignedBatchOnTimeout(shardIds, routingAllocation, true); |
320 | 297 |
|
321 | 298 | List<ShardRouting> ignoredShards = routingAllocation.routingNodes().unassigned().ignored();
|
322 | 299 | assertEquals(0, ignoredShards.size());
|
|
0 commit comments