Skip to content

Commit 820ce80

Browse files
committed
Cleanup
1 parent 6ae508a commit 820ce80

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

server/src/test/java/org/elasticsearch/cluster/routing/IndexRoutingTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,13 +801,12 @@ public void testCollectSearchShardsPartitionedWithResharding() throws IOExceptio
801801
.build()
802802
);
803803

804-
// Since we increased number of shard by two this is the adjustment logic.
804+
// Rerouting is in effect due to presence of resharding metadata.
805+
// We won't see shard 4 and above (there is a corresponding logic in index operation routing).
805806
Function<Integer, Integer> adjustForResharding = i -> i < preReshardShards
806807
? i
807808
: IndexReshardingMetadata.newSplitByMultiple(preReshardShards, 2).getSplit().sourceShard(i);
808809

809-
// Rerouting is in effect due to resharding metadata having a shard in CLONE state.
810-
// We won't see shard 4 and above.
811810
for (var shardAndRouting : shardToRouting.entrySet()) {
812811
var collectedShards = new ArrayList<Integer>();
813812
initialReshardingRouting.collectSearchShards(shardAndRouting.getValue(), collectedShards::add);
@@ -833,12 +832,12 @@ public void testCollectSearchShardsPartitionedWithResharding() throws IOExceptio
833832
.build()
834833
);
835834

835+
// Rerouting is in effect due to presence of resharding metadata.
836+
// We won't see shard 4 and above (there is a corresponding logic in index operation routing).
836837
for (var shardAndRouting : shardToRouting.entrySet()) {
837838
var collectedShards = new ArrayList<Integer>();
838839
reshardingRoutingWithShardInHandoff.collectSearchShards(shardAndRouting.getValue(), collectedShards::add);
839840
assertEquals(2, collectedShards.size());
840-
// Rerouting is in effect due to resharding metadata having a shard in CLONE state.
841-
// We won't see shard 4 and above.
842841

843842
var expected = new ArrayList<Integer>();
844843
expected.add(adjustForResharding.apply(shardAndRouting.getKey()));

server/src/test/java/org/elasticsearch/cluster/routing/OperationRoutingTests.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,13 @@ public void testOperationRoutingWithResharding() throws IOException {
482482
final ProjectId projectId = randomProjectIdOrDefault();
483483
final String indexName = "test";
484484
final int shardCount = 1;
485-
final int multiple = randomIntBetween(2, 5);
486-
final int newShardCount = multiple;
487-
final int numberOfReplicas = 1;
485+
final int newShardCount = randomIntBetween(2, 5);
488486

489487
var indexMetadata = IndexMetadata.builder(indexName)
490-
.settings(indexSettings(IndexVersion.current(), newShardCount, numberOfReplicas))
488+
.settings(indexSettings(IndexVersion.current(), newShardCount, 1))
491489
.numberOfShards(newShardCount)
492-
.numberOfReplicas(numberOfReplicas)
493-
.reshardingMetadata(IndexReshardingMetadata.newSplitByMultiple(shardCount, multiple))
490+
.numberOfReplicas(1)
491+
.reshardingMetadata(IndexReshardingMetadata.newSplitByMultiple(shardCount, newShardCount))
494492
.build();
495493

496494
ClusterState.Builder initialStateBuilder = ClusterState.builder(new ClusterName("test"));
@@ -528,7 +526,7 @@ public void testOperationRoutingWithResharding() throws IOException {
528526

529527
final Index index = clusterService.state().metadata().getProject(projectId).index(indexName).getIndex();
530528

531-
var shardChangingSplitTargetState = randomIntBetween(1, multiple - 1);
529+
var shardChangingSplitTargetState = randomIntBetween(1, newShardCount - 1);
532530

533531
var currentIndexMetadata = clusterService.state().projectState(projectId).metadata().index(indexName);
534532
var updatedReshardingMetadataOneShardInHandoff = IndexMetadata.builder(currentIndexMetadata)

0 commit comments

Comments
 (0)