-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Remote Store] Introducing mixed mode support for remote store migrat…
…ion (#11986) (#12751) * Introducing mixed mode support for remote store migration --------- Signed-off-by: Gaurav Bafna <[email protected]>
- Loading branch information
Showing
10 changed files
with
341 additions
and
25 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
38 changes: 38 additions & 0 deletions
38
.../src/internalClusterTest/java/org/opensearch/remotemigration/DocRepMigrationTestCase.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,38 @@ | ||
/* | ||
* 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.client.Client; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import java.util.List; | ||
|
||
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, autoManageMasterNodes = false) | ||
public class DocRepMigrationTestCase extends MigrationBaseTestCase { | ||
|
||
public void testMixedModeAddDocRep() throws Exception { | ||
internalCluster().setBootstrapClusterManagerNodeIndex(0); | ||
List<String> cmNodes = internalCluster().startNodes(1); | ||
|
||
Client client = internalCluster().client(cmNodes.get(0)); | ||
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); | ||
updateSettingsRequest.persistentSettings(Settings.builder().put(REMOTE_STORE_COMPATIBILITY_MODE_SETTING.getKey(), "mixed")); | ||
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); | ||
addRemote = false; | ||
internalCluster().startNode(); | ||
String[] allNodes = internalCluster().getNodeNames(); | ||
assertBusy(() -> { assertEquals(client.admin().cluster().prepareClusterStats().get().getNodes().size(), allNodes.length); }); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
...er/src/internalClusterTest/java/org/opensearch/remotemigration/MigrationBaseTestCase.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,50 @@ | ||
/* | ||
* 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.common.settings.Settings; | ||
import org.opensearch.common.util.FeatureFlags; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import java.nio.file.Path; | ||
|
||
import static org.opensearch.remotestore.RemoteStoreBaseIntegTestCase.remoteStoreClusterSettings; | ||
|
||
public class MigrationBaseTestCase extends OpenSearchIntegTestCase { | ||
protected static final String REPOSITORY_NAME = "test-remote-store-repo"; | ||
protected static final String REPOSITORY_2_NAME = "test-remote-store-repo-2"; | ||
|
||
protected Path segmentRepoPath; | ||
protected Path translogRepoPath; | ||
|
||
boolean addRemote = false; | ||
|
||
protected Settings nodeSettings(int nodeOrdinal) { | ||
if (segmentRepoPath == null || translogRepoPath == null) { | ||
segmentRepoPath = randomRepoPath().toAbsolutePath(); | ||
translogRepoPath = randomRepoPath().toAbsolutePath(); | ||
} | ||
if (addRemote) { | ||
logger.info("Adding remote store node"); | ||
return Settings.builder() | ||
.put(super.nodeSettings(nodeOrdinal)) | ||
.put(remoteStoreClusterSettings(REPOSITORY_NAME, segmentRepoPath, REPOSITORY_2_NAME, translogRepoPath)) | ||
.put("discovery.initial_state_timeout", "500ms") | ||
.build(); | ||
} else { | ||
logger.info("Adding docrep node"); | ||
return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put("discovery.initial_state_timeout", "500ms").build(); | ||
} | ||
} | ||
|
||
@Override | ||
protected Settings featureFlagSettings() { | ||
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.REMOTE_STORE_MIGRATION_EXPERIMENTAL, "true").build(); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...internalClusterTest/java/org/opensearch/remotemigration/RemoteStoreMigrationTestCase.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,74 @@ | ||
/* | ||
* 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.repositories.get.GetRepositoriesRequest; | ||
import org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse; | ||
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; | ||
import org.opensearch.client.Client; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import java.util.List; | ||
|
||
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.remotestore.RemoteStoreBaseIntegTestCase.remoteStoreClusterSettings; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
|
||
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0, autoManageMasterNodes = false) | ||
public class RemoteStoreMigrationTestCase extends MigrationBaseTestCase { | ||
public void testMixedModeAddRemoteNodes() throws Exception { | ||
internalCluster().setBootstrapClusterManagerNodeIndex(0); | ||
List<String> cmNodes = internalCluster().startNodes(1); | ||
Client client = internalCluster().client(cmNodes.get(0)); | ||
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; | ||
internalCluster().startNode(); | ||
internalCluster().startNode(); | ||
internalCluster().validateClusterFormed(); | ||
|
||
// assert repo gets registered | ||
GetRepositoriesRequest gr = new GetRepositoriesRequest(new String[] { REPOSITORY_NAME }); | ||
GetRepositoriesResponse getRepositoriesResponse = client.admin().cluster().getRepositories(gr).actionGet(); | ||
assertEquals(1, getRepositoriesResponse.repositories().size()); | ||
|
||
// add docrep mode in mixed mode cluster | ||
addRemote = true; | ||
internalCluster().startNode(); | ||
assertBusy(() -> { | ||
assertEquals(client.admin().cluster().prepareClusterStats().get().getNodes().size(), internalCluster().getNodeNames().length); | ||
}); | ||
|
||
// add incompatible remote node in remote mixed cluster | ||
Settings.Builder badSettings = Settings.builder() | ||
.put(remoteStoreClusterSettings(REPOSITORY_NAME, segmentRepoPath, "REPOSITORY_2_NAME", translogRepoPath)) | ||
.put("discovery.initial_state_timeout", "500ms"); | ||
String badNode = internalCluster().startNode(badSettings); | ||
assertTrue(client.admin().cluster().prepareClusterStats().get().getNodes().size() < internalCluster().getNodeNames().length); | ||
internalCluster().stopRandomNode(settings -> settings.get("node.name").equals(badNode)); | ||
} | ||
|
||
public void testMigrationDirections() { | ||
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); | ||
// add remote node in docrep cluster | ||
updateSettingsRequest.persistentSettings(Settings.builder().put(MIGRATION_DIRECTION_SETTING.getKey(), "docrep")); | ||
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); | ||
|
||
updateSettingsRequest.persistentSettings(Settings.builder().put(MIGRATION_DIRECTION_SETTING.getKey(), "remote_store")); | ||
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); | ||
|
||
updateSettingsRequest.persistentSettings(Settings.builder().put(MIGRATION_DIRECTION_SETTING.getKey(), "random")); | ||
assertThrows(IllegalArgumentException.class, () -> client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); | ||
} | ||
} |
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
Oops, something went wrong.