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.
- Loading branch information
Showing
9 changed files
with
229 additions
and
16 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
149 changes: 149 additions & 0 deletions
149
server/src/internalClusterTest/java/org/opensearch/remotemigration/RemoteACMIT.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,149 @@ | ||
/* | ||
* 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.cluster.metadata.IndexMetadata; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.IndexService; | ||
import org.opensearch.plugins.Plugin; | ||
import org.opensearch.remotestore.multipart.mocks.MockFsRepositoryPlugin; | ||
import org.opensearch.repositories.blobstore.BlobStoreRepository; | ||
import org.opensearch.repositories.fs.ReloadableFsRepository; | ||
import org.opensearch.test.InternalSettingsPlugin; | ||
import org.opensearch.test.InternalTestCluster; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
import org.opensearch.test.transport.MockTransportService; | ||
|
||
import java.util.Collection; | ||
import java.util.Locale; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import static org.opensearch.gateway.remote.RemoteClusterStateService.REMOTE_CLUSTER_STATE_ENABLED_SETTING; | ||
import static org.opensearch.gateway.remote.RemoteClusterStateService.REMOTE_PUBLICATION_SETTING_KEY; | ||
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY; | ||
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX; | ||
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT; | ||
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY; | ||
|
||
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0) | ||
public class RemoteACMIT extends MigrationBaseTestCase { | ||
private final String REMOTE_PRI_DOCREP_REP = "remote-primary-docrep-replica"; | ||
|
||
@Override | ||
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
/* Adding the following mock plugins: | ||
- InternalSettingsPlugin : To override default intervals of retention lease and global ckp sync | ||
- MockFsRepositoryPlugin and MockTransportService.TestPlugin: To ensure remote interactions are not no-op and retention leases are properly propagated | ||
*/ | ||
return Stream.concat( | ||
super.nodePlugins().stream(), | ||
Stream.of(InternalSettingsPlugin.class, MockFsRepositoryPlugin.class, MockTransportService.TestPlugin.class) | ||
).collect(Collectors.toList()); | ||
} | ||
|
||
public Settings.Builder remotePublishNodeSetting() { | ||
if (segmentRepoPath == null || translogRepoPath == null) { | ||
segmentRepoPath = randomRepoPath().toAbsolutePath(); | ||
translogRepoPath = randomRepoPath().toAbsolutePath(); | ||
} | ||
String segmentRepoName = "test-remote-store-repo"; | ||
String stateRepoSettingsAttributeKeyPrefix = String.format( | ||
Locale.getDefault(), | ||
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX, | ||
segmentRepoName | ||
); | ||
String prefixModeVerificationSuffix = BlobStoreRepository.PREFIX_MODE_VERIFICATION_SETTING.getKey(); | ||
String stateRepoTypeAttributeKey = String.format( | ||
Locale.getDefault(), | ||
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT, | ||
segmentRepoName | ||
); | ||
String routingTableRepoName = "remote-routing-repo"; | ||
String routingTableRepoTypeAttributeKey = String.format( | ||
Locale.getDefault(), | ||
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT, | ||
routingTableRepoName | ||
); | ||
String routingTableRepoSettingsAttributeKeyPrefix = String.format( | ||
Locale.getDefault(), | ||
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX, | ||
routingTableRepoName | ||
); | ||
|
||
Settings.Builder builder = Settings.builder() | ||
.put("node.attr." + REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName) | ||
.put(stateRepoTypeAttributeKey, ReloadableFsRepository.TYPE) | ||
.put(stateRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath) | ||
.put(stateRepoSettingsAttributeKeyPrefix + prefixModeVerificationSuffix, true) | ||
.put(REMOTE_CLUSTER_STATE_ENABLED_SETTING.getKey(), true) | ||
.put("node.attr." + REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY, routingTableRepoName) | ||
.put(routingTableRepoTypeAttributeKey, ReloadableFsRepository.TYPE) | ||
.put(routingTableRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath); | ||
return builder; | ||
} | ||
|
||
public void testACMJoiningNonACMCluster() throws Exception { | ||
// non-acm cluster-manager | ||
String cmName = internalCluster().startClusterManagerOnlyNode(); | ||
Settings oneReplica = Settings.builder() | ||
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) | ||
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "1s") | ||
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") | ||
.build(); | ||
|
||
Settings.Builder build = remotePublishNodeSetting(); | ||
|
||
// have the node settings for repo | ||
internalCluster().startDataOnlyNodes(2, build.build()); | ||
build.put(REMOTE_PUBLICATION_SETTING_KEY, true); | ||
|
||
// acm cluster-manager | ||
String cm2 = internalCluster().startClusterManagerOnlyNode(build.build()); | ||
|
||
// stop-non-acm cluster-manager | ||
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(cmName)); | ||
|
||
// update cluster-state via remote | ||
createIndex(REMOTE_PRI_DOCREP_REP, oneReplica); | ||
ensureGreen(); | ||
} | ||
|
||
// failure modes during ORR | ||
// tms issue | ||
// flee | ||
public void testNonACMJoiningACMCluster() throws Exception { | ||
|
||
// create - repository from external call | ||
|
||
Settings.Builder build = remotePublishNodeSetting(); | ||
build.put(REMOTE_PUBLICATION_SETTING_KEY, true); | ||
|
||
// acm cluster-manager | ||
String cmName = internalCluster().startClusterManagerOnlyNode(build.build()); | ||
Settings oneReplica = Settings.builder() | ||
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) | ||
.put(IndexService.RETENTION_LEASE_SYNC_INTERVAL_SETTING.getKey(), "1s") | ||
.put(IndexService.GLOBAL_CHECKPOINT_SYNC_INTERVAL_SETTING.getKey(), "1s") | ||
.build(); | ||
|
||
// have the node settings for repo | ||
internalCluster().startDataOnlyNodes(2, build.build()); | ||
|
||
// non-acm cluster-manager | ||
String cm2 = internalCluster().startClusterManagerOnlyNode(); | ||
|
||
// stop acm cluster-manager | ||
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(cmName)); | ||
|
||
// update cluster-state via remote | ||
createIndex(REMOTE_PRI_DOCREP_REP, oneReplica); | ||
ensureGreen(); | ||
} | ||
} |
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
Oops, something went wrong.