-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize the leaderCheckpoint with follower shard's localCheckpoint (…
…#904) (#951) Signed-off-by: Ankit Kala <[email protected]> (cherry picked from commit cd0a6b2)
- Loading branch information
1 parent
0ecb6b8
commit 3645c6d
Showing
6 changed files
with
144 additions
and
13 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
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
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
62 changes: 62 additions & 0 deletions
62
src/test/kotlin/org/opensearch/replication/integ/rest/ReplicationStopThenRestartIT.kt
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,62 @@ | ||
package org.opensearch.replication.integ.rest | ||
|
||
import org.opensearch.replication.MultiClusterRestTestCase | ||
import org.opensearch.replication.MultiClusterAnnotations | ||
import org.opensearch.replication.StartReplicationRequest | ||
import org.opensearch.replication.startReplication | ||
import org.opensearch.replication.stopReplication | ||
import org.assertj.core.api.Assertions | ||
import org.opensearch.client.RequestOptions | ||
import org.opensearch.client.indices.CreateIndexRequest | ||
import org.junit.Assert | ||
import java.util.concurrent.TimeUnit | ||
|
||
|
||
@MultiClusterAnnotations.ClusterConfigurations( | ||
MultiClusterAnnotations.ClusterConfiguration(clusterName = LEADER), | ||
MultiClusterAnnotations.ClusterConfiguration(clusterName = FOLLOWER) | ||
) | ||
|
||
class ReplicationStopThenRestartIT : MultiClusterRestTestCase() { | ||
private val leaderIndexName = "leader_index" | ||
private val followerIndexName = "follower_index" | ||
|
||
fun `test replication works after unclean stop and start`() { | ||
val followerClient = getClientForCluster(FOLLOWER) | ||
val leaderClient = getClientForCluster(LEADER) | ||
changeTemplate(LEADER) | ||
createConnectionBetweenClusters(FOLLOWER, LEADER) | ||
val createIndexResponse = leaderClient.indices().create(CreateIndexRequest(leaderIndexName), RequestOptions.DEFAULT) | ||
Assertions.assertThat(createIndexResponse.isAcknowledged).isTrue() | ||
followerClient.startReplication(StartReplicationRequest("source", leaderIndexName, followerIndexName)) | ||
insertDocToIndex(LEADER, "1", "dummy data 1",leaderIndexName) | ||
insertDocToIndex(LEADER, "2", "dummy data 1",leaderIndexName) | ||
|
||
assertBusy ({ | ||
try { | ||
Assert.assertEquals(2, docCount(followerClient, followerIndexName)) | ||
} catch (ex: Exception) { | ||
ex.printStackTrace(); | ||
Assert.fail("Exception while querying follower cluster. Failing to retry again {}") | ||
} | ||
}, 1, TimeUnit.MINUTES) | ||
|
||
|
||
deleteConnection(FOLLOWER) | ||
followerClient.stopReplication(followerIndexName, shouldWait = true) | ||
deleteIndex(followerClient, followerIndexName) | ||
|
||
createConnectionBetweenClusters(FOLLOWER, LEADER) | ||
insertDocToIndex(LEADER, "3", "dummy data 1",leaderIndexName) | ||
insertDocToIndex(LEADER, "4", "dummy data 1",leaderIndexName) | ||
followerClient.startReplication(StartReplicationRequest("source", leaderIndexName, followerIndexName)) | ||
|
||
assertBusy ({ | ||
try { | ||
Assert.assertEquals(4, docCount(followerClient, followerIndexName)) | ||
} catch (ex: Exception) { | ||
Assert.fail("Exception while querying follower cluster. Failing to retry again") | ||
} | ||
}, 1, TimeUnit.MINUTES) | ||
} | ||
} |