-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ashish Singh <[email protected]>
- Loading branch information
Showing
3 changed files
with
96 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...st/java/org/opensearch/indices/recovery/RemoteStoreReplicaRecoverySourceHandlerTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.indices.recovery; | ||
|
||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.engine.NRTReplicationEngineFactory; | ||
import org.opensearch.index.replication.OpenSearchIndexLevelReplicationTestCase; | ||
import org.opensearch.index.shard.IndexShard; | ||
import org.opensearch.indices.replication.common.ReplicationType; | ||
|
||
public class RemoteStoreReplicaRecoverySourceHandlerTests extends OpenSearchIndexLevelReplicationTestCase { | ||
|
||
private static final Settings settings = Settings.builder() | ||
.put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT) | ||
.put(IndexMetadata.SETTING_REMOTE_STORE_ENABLED, "true") | ||
.put(IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_ENABLED, "true") | ||
.build(); | ||
|
||
public void testReplicaShardRecoveryUptoLastFlushedCommit() throws Exception { | ||
try (ReplicationGroup shards = createGroup(0, settings, new NRTReplicationEngineFactory())) { | ||
|
||
// Step1 - Start primary, index docs and flush | ||
shards.startPrimary(); | ||
final IndexShard primary = shards.getPrimary(); | ||
int numDocs = shards.indexDocs(randomIntBetween(10, 100)); | ||
shards.flush(); | ||
|
||
// Step 2 - Start replica for recovery to happen, check both has same number of docs | ||
final IndexShard replica1 = shards.addReplica(); | ||
shards.startAll(); | ||
assertEquals(getDocIdAndSeqNos(primary), getDocIdAndSeqNos(replica1)); | ||
|
||
// Step 3 - Index more docs, run segment replication, check both have same number of docs | ||
int moreDocs = shards.indexDocs(randomIntBetween(10, 100)); | ||
primary.refresh("test"); | ||
replicateSegments(primary, shards.getReplicas()); | ||
assertEquals(getDocIdAndSeqNos(primary), getDocIdAndSeqNos(replica1)); | ||
|
||
// Step 4 - Check both shard has expected number of doc count | ||
assertDocCount(primary, numDocs + moreDocs); | ||
assertDocCount(replica1, numDocs + moreDocs); | ||
|
||
// Step 5 - Start new replica, recovery happens, and check that new replica has docs upto last flush | ||
final IndexShard replica2 = shards.addReplica(); | ||
shards.startAll(); | ||
assertDocCount(replica2, numDocs); | ||
|
||
// Step 6 - Segment replication, check all shards have same number of docs | ||
replicateSegments(primary, shards.getReplicas()); | ||
shards.assertAllEqual(numDocs + moreDocs); | ||
} | ||
} | ||
} |