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.
Disable remote publication if remote state disabled
Signed-off-by: Shivansh Arora <[email protected]>
- Loading branch information
Showing
2 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
.../src/internalClusterTest/java/org/opensearch/gateway/remote/RemoteStatePublicationIT.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,82 @@ | ||
/* | ||
* 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.gateway.remote; | ||
|
||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.common.util.FeatureFlags; | ||
import org.opensearch.remotestore.RemoteStoreBaseIntegTestCase; | ||
import org.opensearch.repositories.fs.ReloadableFsRepository; | ||
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope; | ||
import org.opensearch.test.OpenSearchIntegTestCase.Scope; | ||
import org.junit.Before; | ||
|
||
import java.util.Locale; | ||
|
||
import static org.opensearch.gateway.remote.RemoteClusterStateService.REMOTE_CLUSTER_STATE_ENABLED_SETTING; | ||
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; | ||
|
||
@ClusterScope(scope = Scope.TEST, numDataNodes = 0) | ||
public class RemoteStatePublicationIT extends RemoteStoreBaseIntegTestCase { | ||
|
||
private static String INDEX_NAME = "test-index"; | ||
|
||
private boolean isRemoteStateEnabled = true; | ||
private String isRemotePublicationEnabled = "true"; | ||
|
||
@Before | ||
public void setup() { | ||
asyncUploadMockFsRepo = false; | ||
} | ||
|
||
@Override | ||
protected Settings featureFlagSettings() { | ||
return Settings.builder() | ||
.put(super.featureFlagSettings()) | ||
.put(FeatureFlags.REMOTE_PUBLICATION_EXPERIMENTAL, isRemotePublicationEnabled) | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected Settings nodeSettings(int nodeOrdinal) { | ||
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 | ||
); | ||
return Settings.builder() | ||
.put(super.nodeSettings(nodeOrdinal)) | ||
.put(REMOTE_CLUSTER_STATE_ENABLED_SETTING.getKey(), isRemoteStateEnabled) | ||
.put("node.attr." + REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY, routingTableRepoName) | ||
.put(routingTableRepoTypeAttributeKey, ReloadableFsRepository.TYPE) | ||
.put(routingTableRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath) | ||
.build(); | ||
} | ||
|
||
public void testRemotePublicationDisableIfRemoteStateDisabled() { | ||
isRemoteStateEnabled = false; | ||
isRemotePublicationEnabled = "true"; | ||
// create cluster with multi node with in-consistent settings | ||
prepareCluster(3, 2, INDEX_NAME, 1, 2); | ||
// assert cluster is stable, ensuring publication falls back to legacy transport with inconsistent settings | ||
ensureStableCluster(5); | ||
ensureGreen(INDEX_NAME); | ||
|
||
assertNull(internalCluster().getCurrentClusterManagerNodeInstance(RemoteClusterStateService.class)); | ||
// revert the setting back to true for other tests | ||
isRemoteStateEnabled = true; | ||
} | ||
} |
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