forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Remote Store] Add support to remote restore IndexMetadata (opensearc…
…h-project#9086) * Add support to restore remote cluster state in RemoteStoreRestoreService Signed-off-by: Varun Bansal <[email protected]> Signed-off-by: Kaushal Kumar <[email protected]>
- Loading branch information
1 parent
3c2bd43
commit 011ac4d
Showing
9 changed files
with
712 additions
and
169 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
server/src/internalClusterTest/java/org/opensearch/remotestore/BaseRemoteStoreRestoreIT.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,107 @@ | ||
/* | ||
* 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.remotestore; | ||
|
||
import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreRequest; | ||
import org.opensearch.action.index.IndexResponse; | ||
import org.opensearch.action.support.PlainActionFuture; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.plugins.Plugin; | ||
import org.opensearch.test.transport.MockTransportService; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; | ||
|
||
public class BaseRemoteStoreRestoreIT extends RemoteStoreBaseIntegTestCase { | ||
static final String INDEX_NAME = "remote-store-test-idx-1"; | ||
static final String INDEX_NAMES = "test-remote-store-1,test-remote-store-2,remote-store-test-index-1,remote-store-test-index-2"; | ||
static final String INDEX_NAMES_WILDCARD = "test-remote-store-*,remote-store-test-index-*"; | ||
static final String TOTAL_OPERATIONS = "total-operations"; | ||
static final String REFRESHED_OR_FLUSHED_OPERATIONS = "refreshed-or-flushed-operations"; | ||
static final String MAX_SEQ_NO_TOTAL = "max-seq-no-total"; | ||
|
||
@Override | ||
public Settings indexSettings() { | ||
return remoteStoreIndexSettings(0); | ||
} | ||
|
||
public Settings indexSettings(int shards, int replicas) { | ||
return remoteStoreIndexSettings(replicas, shards); | ||
} | ||
|
||
@Override | ||
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
return Arrays.asList(MockTransportService.TestPlugin.class); | ||
} | ||
|
||
protected void restore(String... indices) { | ||
boolean restoreAllShards = randomBoolean(); | ||
if (restoreAllShards) { | ||
assertAcked(client().admin().indices().prepareClose(indices)); | ||
} | ||
client().admin() | ||
.cluster() | ||
.restoreRemoteStore( | ||
new RestoreRemoteStoreRequest().indices(indices).restoreAllShards(restoreAllShards), | ||
PlainActionFuture.newFuture() | ||
); | ||
} | ||
|
||
protected void verifyRestoredData(Map<String, Long> indexStats, String indexName) throws Exception { | ||
ensureYellowAndNoInitializingShards(indexName); | ||
ensureGreen(indexName); | ||
// This is to ensure that shards that were already assigned will get latest count | ||
refresh(indexName); | ||
assertBusy( | ||
() -> assertHitCount(client().prepareSearch(indexName).setSize(0).get(), indexStats.get(TOTAL_OPERATIONS)), | ||
30, | ||
TimeUnit.SECONDS | ||
); | ||
IndexResponse response = indexSingleDoc(indexName); | ||
if (indexStats.containsKey(MAX_SEQ_NO_TOTAL + "-shard-" + response.getShardId().id())) { | ||
assertEquals(indexStats.get(MAX_SEQ_NO_TOTAL + "-shard-" + response.getShardId().id()) + 1, response.getSeqNo()); | ||
} | ||
refresh(indexName); | ||
assertBusy( | ||
() -> assertHitCount(client().prepareSearch(indexName).setSize(0).get(), indexStats.get(TOTAL_OPERATIONS) + 1), | ||
30, | ||
TimeUnit.SECONDS | ||
); | ||
} | ||
|
||
public void prepareCluster(int numClusterManagerNodes, int numDataOnlyNodes, String indices, int replicaCount, int shardCount) { | ||
prepareCluster(numClusterManagerNodes, numDataOnlyNodes, indices, replicaCount, shardCount, Settings.EMPTY); | ||
} | ||
|
||
public void prepareCluster( | ||
int numClusterManagerNodes, | ||
int numDataOnlyNodes, | ||
String indices, | ||
int replicaCount, | ||
int shardCount, | ||
Settings settings | ||
) { | ||
prepareCluster(numClusterManagerNodes, numDataOnlyNodes, settings); | ||
for (String index : indices.split(",")) { | ||
createIndex(index, remoteStoreIndexSettings(replicaCount, shardCount)); | ||
ensureYellowAndNoInitializingShards(index); | ||
ensureGreen(index); | ||
} | ||
} | ||
|
||
public void prepareCluster(int numClusterManagerNodes, int numDataOnlyNodes, Settings settings) { | ||
internalCluster().startClusterManagerOnlyNodes(numClusterManagerNodes, settings); | ||
internalCluster().startDataOnlyNodes(numDataOnlyNodes, settings); | ||
} | ||
} |
Oops, something went wrong.