From 0256d0a5e5341dcc82784cb22a6bb1f6deea560e Mon Sep 17 00:00:00 2001 From: sricharanvuppu <113983630+sricharanvuppu@users.noreply.github.com> Date: Tue, 29 Nov 2022 10:35:25 +0530 Subject: [PATCH] resolved merge conflicts got from cherry-picking commit ad8e8de Signed-off-by: sricharanvuppu --- .../org/opensearch/replication/BasicReplicationIT.kt | 1 - .../replication/MultiClusterRestTestCase.kt | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/test/kotlin/org/opensearch/replication/BasicReplicationIT.kt b/src/test/kotlin/org/opensearch/replication/BasicReplicationIT.kt index 304f88f6..ff3bfa83 100644 --- a/src/test/kotlin/org/opensearch/replication/BasicReplicationIT.kt +++ b/src/test/kotlin/org/opensearch/replication/BasicReplicationIT.kt @@ -49,7 +49,6 @@ class BasicReplicationIT : MultiClusterRestTestCase() { // Create an empty index on the leader and trigger replication on it val createIndexResponse = leader.indices().create(CreateIndexRequest(leaderIndex), RequestOptions.DEFAULT) assertThat(createIndexResponse.isAcknowledged).isTrue() - follower.startReplication(StartReplicationRequest("source", leaderIndex, followerIndex), waitForRestore=true) val source = mapOf("name" to randomAlphaOfLength(20), "age" to randomInt().toString()) var response = leader.index(IndexRequest(leaderIndex).id("1").source(source), RequestOptions.DEFAULT) diff --git a/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt b/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt index 36fbd3fd..982cc6dc 100644 --- a/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt +++ b/src/test/kotlin/org/opensearch/replication/MultiClusterRestTestCase.kt @@ -57,6 +57,7 @@ import org.junit.After import org.junit.AfterClass import org.junit.Before import org.junit.BeforeClass +import org.opensearch.index.mapper.ObjectMapper import java.nio.file.Files import java.security.KeyManagementException import java.security.KeyStore @@ -420,9 +421,7 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() { testCluster.lowLevelClient.performRequest(request) } } - - protected fun wipeIndicesFromCluster(testCluster: TestCluster) { - + private fun stopAllReplicationJobs(testCluster: TestCluster) { val indicesResponse = testCluster.lowLevelClient.performRequest((Request("GET","/_cat/indices/*,-.*?format=json&pretty"))) val indicesResponseEntity = EntityUtils.toString(indicesResponse.entity) var parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, indicesResponseEntity) @@ -433,18 +432,21 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() { key to value } val ind = map.get("index") - try { + try { val stopRequest = Request("POST","/_plugins/_replication/" + ind.toString() + "/_stop") stopRequest.setJsonEntity("{}") stopRequest.setOptions(RequestOptions.DEFAULT) val response=testCluster.lowLevelClient.performRequest(stopRequest) - } + } catch (e:ResponseException){ if(e.response.statusLine.statusCode!=400) { throw e } } } + } + protected fun wipeIndicesFromCluster(testCluster: TestCluster) { + stopAllReplicationJobs(testCluster) try { val deleteRequest = Request("DELETE", "*,-.*") // All except system indices val response = testCluster.lowLevelClient.performRequest(deleteRequest)