-
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.
Integrate local recovery with remote store seeding during migration
Signed-off-by: Bhumika Saini <[email protected]>
- Loading branch information
Bhumika Saini
committed
Apr 9, 2024
1 parent
9b0f578
commit 0afcdd2
Showing
4 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
...internalClusterTest/java/org/opensearch/remotemigration/RemotePrimaryLocalRecoveryIT.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,120 @@ | ||
/* | ||
* 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.remotemigration; | ||
|
||
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; | ||
import org.opensearch.action.admin.indices.stats.ShardStats; | ||
import org.opensearch.client.Client; | ||
import org.opensearch.cluster.node.DiscoveryNodes; | ||
import org.opensearch.cluster.routing.ShardRouting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.remote.RemoteSegmentStats; | ||
import org.opensearch.test.InternalTestCluster; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import java.util.Map; | ||
|
||
import static org.opensearch.node.remotestore.RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING; | ||
import static org.opensearch.node.remotestore.RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
|
||
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0) | ||
public class RemotePrimaryLocalRecoveryIT extends MigrationBaseTestCase { | ||
|
||
/** | ||
* Tests local recovery sanity in the happy path flow | ||
* @throws Exception | ||
*/ | ||
public void testLocalRecoveryRollingRestart() throws Exception { | ||
triggerRollingRestartForRemoteMigration(); | ||
} | ||
|
||
/** | ||
* Tests local recovery sanity during remote migration with a node restart in between | ||
* @throws Exception | ||
*/ | ||
public void testLocalRecoveryRollingRestartAndNodeFailure() throws Exception { | ||
triggerRollingRestartForRemoteMigration(); | ||
|
||
DiscoveryNodes discoveryNodes = internalCluster().client().admin().cluster().prepareState().get().getState().getNodes(); | ||
String nodeToRestart = discoveryNodes.getClusterManagerNodeId(); | ||
internalCluster().restartNode(nodeToRestart); | ||
|
||
Map<ShardRouting, ShardStats> shardStatsMap = internalCluster().client().admin().indices().prepareStats("idx1").get().asMap(); | ||
shardStatsMap.forEach((shardRouting, shardStats) -> { | ||
if (nodeToRestart.equals(shardRouting.currentNodeId())) { | ||
RemoteSegmentStats remoteSegmentStats = shardStats.getStats().getSegments().getRemoteSegmentStats(); | ||
assertTrue(remoteSegmentStats.getTotalUploadTime() > 0); | ||
assertTrue(remoteSegmentStats.getUploadBytesSucceeded() > 0); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Helper method to run a rolling restart for migration to remote backed cluster | ||
* @throws Exception | ||
*/ | ||
private void triggerRollingRestartForRemoteMigration() throws Exception { | ||
String docRepNode = internalCluster().startNode(); | ||
Client client = internalCluster().client(docRepNode); | ||
|
||
// create index | ||
client().admin().indices().prepareCreate("idx1").setSettings(indexSettings()).setMapping("field", "type=text").get(); | ||
ensureGreen("idx1"); | ||
|
||
indexBulk("idx1", randomIntBetween(10, 100)); | ||
refresh("idx1"); | ||
|
||
// Index some more docs | ||
indexBulk("idx1", randomIntBetween(10, 100)); | ||
|
||
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); | ||
updateSettingsRequest.persistentSettings(Settings.builder().put(REMOTE_STORE_COMPATIBILITY_MODE_SETTING.getKey(), "mixed")); | ||
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); | ||
|
||
// add remote node in mixed mode cluster | ||
addRemote = true; | ||
String remoteNode = internalCluster().startNode(); | ||
internalCluster().validateClusterFormed(); | ||
|
||
updateSettingsRequest = new ClusterUpdateSettingsRequest(); | ||
updateSettingsRequest.persistentSettings(Settings.builder().put(MIGRATION_DIRECTION_SETTING.getKey(), "remote_store")); | ||
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); | ||
|
||
// rolling restart | ||
final Settings remoteNodeAttributes = remoteStoreClusterSettings( | ||
REPOSITORY_NAME, | ||
segmentRepoPath, | ||
REPOSITORY_2_NAME, | ||
translogRepoPath | ||
); | ||
internalCluster().rollingRestart(new InternalTestCluster.RestartCallback() { | ||
// Update remote attributes | ||
@Override | ||
public Settings onNodeStopped(String nodeName) throws Exception { | ||
return remoteNodeAttributes; | ||
} | ||
}); | ||
|
||
ensureStableCluster(2); | ||
ensureGreen("idx1"); | ||
assertEquals(internalCluster().size(), 2); | ||
|
||
// Assert on remote uploads | ||
Map<ShardRouting, ShardStats> shardStatsMap = internalCluster().client().admin().indices().prepareStats("idx1").get().asMap(); | ||
DiscoveryNodes discoveryNodes = internalCluster().client().admin().cluster().prepareState().get().getState().getNodes(); | ||
shardStatsMap.forEach((shardRouting, shardStats) -> { | ||
if (discoveryNodes.get(shardRouting.currentNodeId()).isRemoteStoreNode()) { | ||
RemoteSegmentStats remoteSegmentStats = shardStats.getStats().getSegments().getRemoteSegmentStats(); | ||
assertTrue(remoteSegmentStats.getTotalUploadTime() > 0); | ||
assertTrue(remoteSegmentStats.getUploadBytesSucceeded() > 0); | ||
} | ||
}); | ||
} | ||
} |
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