Skip to content

Commit c0169c2

Browse files
committed
Rename replication test case method
This commit renames a method that is used in replication test cases to add a replica using existing shard data.
1 parent 1929c03 commit c0169c2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

core/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.elasticsearch.index.shard.IndexShard;
5151
import org.elasticsearch.index.shard.IndexShardTestCase;
5252
import org.elasticsearch.index.shard.ShardId;
53+
import org.elasticsearch.index.shard.ShardPath;
5354
import org.elasticsearch.indices.recovery.RecoveryState;
5455
import org.elasticsearch.indices.recovery.RecoveryTarget;
5556

@@ -185,16 +186,14 @@ public synchronized IndexShard addReplica() throws IOException {
185186
return replica;
186187
}
187188

188-
public synchronized IndexShard addReplica(IndexShard replica) throws IOException {
189-
replica.close("add", false);
190-
IOUtils.close(replica.store());
191-
ShardRouting shardRouting = TestShardRouting.newShardRouting(
189+
public synchronized IndexShard addReplicaWithExistingPath(final ShardPath shardPath, final String nodeId) throws IOException {
190+
final ShardRouting shardRouting = TestShardRouting.newShardRouting(
192191
shardId,
193-
replica.routingEntry().currentNodeId(),
192+
nodeId,
194193
false, ShardRoutingState.INITIALIZING,
195194
RecoverySource.PeerRecoverySource.INSTANCE);
196195

197-
IndexShard newReplica = newShard(shardRouting, replica.shardPath(), indexMetaData, null, replicaGlobalCheckpointSyncer);
196+
final IndexShard newReplica = newShard(shardRouting, shardPath, indexMetaData, null, replicaGlobalCheckpointSyncer);
198197
replicas.add(newReplica);
199198
updateAllocationIDsOnPrimary();
200199
return newReplica;

core/src/test/java/org/elasticsearch/index/replication/RecoveryDuringReplicationTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.index.replication;
2121

2222
import org.apache.logging.log4j.Logger;
23+
import org.apache.lucene.util.IOUtils;
2324
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
2425
import org.elasticsearch.cluster.node.DiscoveryNode;
2526
import org.elasticsearch.index.shard.IndexShard;
@@ -106,7 +107,10 @@ public void testRecoveryOfDisconnectedReplica() throws Exception {
106107
shards.flush();
107108
}
108109

109-
final IndexShard recoveredReplica = shards.addReplica(originalReplica);
110+
originalReplica.close("disconnected", false);
111+
IOUtils.close(originalReplica.store());
112+
final IndexShard recoveredReplica =
113+
shards.addReplicaWithExistingPath(originalReplica.shardPath(), originalReplica.routingEntry().currentNodeId());
110114
shards.recoverReplica(recoveredReplica);
111115
if (flushPrimary && replicaHasDocsSinceLastFlushedCheckpoint) {
112116
// replica has something to catch up with, but since we flushed the primary, we should fall back to full recovery

0 commit comments

Comments
 (0)