Skip to content

Commit

Permalink
Defer nodeSettings to clusterSettings change
Browse files Browse the repository at this point in the history
Signed-off-by: Lakshya Taragi <[email protected]>
  • Loading branch information
ltaragi committed Apr 11, 2024
1 parent 3bf5eb5 commit b1c049e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected Settings nodeSettings(int nodeOriginal) {
return builder.build();
}

@Override
public void testDefaultRemoteStoreNoUserOverride() throws Exception {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@

package org.opensearch.remotestore;

import org.opensearch.action.admin.indices.get.GetIndexRequest;
import org.opensearch.action.admin.indices.get.GetIndexResponse;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.index.IndexSettings;
import org.opensearch.indices.replication.common.ReplicationType;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.junit.Before;
Expand All @@ -22,6 +25,7 @@
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_REPOSITORY;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REPLICATION_TYPE;
import static org.opensearch.index.IndexSettings.INDEX_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.hamcrest.Matchers.containsString;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST)
Expand All @@ -32,6 +36,27 @@ public void setup() throws Exception {
internalCluster().startNodes(2);
}

public void testDefaultRemoteStoreNoUserOverride() throws Exception {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
.build();
assertAcked(client().admin().indices().prepareCreate("test-idx-1").setSettings(settings).get());
GetIndexResponse getIndexResponse = client().admin()
.indices()
.getIndex(new GetIndexRequest().indices("test-idx-1").includeDefaults(true))
.get();
Settings indexSettings = getIndexResponse.settings().get("test-idx-1");
verifyRemoteStoreIndexSettings(
indexSettings,
"true",
REPOSITORY_NAME,
REPOSITORY_2_NAME,
ReplicationType.SEGMENT.toString(),
IndexSettings.DEFAULT_REMOTE_TRANSLOG_BUFFER_INTERVAL
);
}

public void testRemoteStoreDisabledByUser() throws Exception {
Settings settings = Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,8 @@ public static void updateReplicationStrategy(
indexReplicationType = INDEX_REPLICATION_TYPE_SETTING.get(requestSettings);
} else if (combinedTemplateSettings != null && INDEX_REPLICATION_TYPE_SETTING.exists(combinedTemplateSettings)) {
indexReplicationType = INDEX_REPLICATION_TYPE_SETTING.get(combinedTemplateSettings);
} else if (clusterSettings.get(CLUSTER_REPLICATION_TYPE_SETTING) != null) {
indexReplicationType = clusterSettings.get(CLUSTER_REPLICATION_TYPE_SETTING);
} else if (CLUSTER_REPLICATION_TYPE_SETTING.exists(nodeSettings)) {
indexReplicationType = CLUSTER_REPLICATION_TYPE_SETTING.get(nodeSettings);
} else if (isRemoteDataAttributePresent(nodeSettings)) {
indexReplicationType = ReplicationType.SEGMENT;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1400,10 +1400,6 @@ public void testRemoteStoreImplicitOverrideReplicationTypeToSegmentForRemoteStor
.put(segmentRepositoryNameAttributeKey, SEGMENT_REPO)
.put(translogRepositoryNameAttributeKey, TRANSLOG_REPO)
.build();
clusterSettings = new ClusterSettings(
Settings.builder().put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT).build(),
ClusterSettings.BUILT_IN_CLUSTER_SETTINGS
);
request = new CreateIndexClusterStateUpdateRequest("create index", "test", "test");
final Settings.Builder requestSettings = Settings.builder();
request.settings(requestSettings.build());
Expand Down Expand Up @@ -1437,10 +1433,6 @@ public void testRemoteStoreNoUserOverrideIndexSettings() {
.put(segmentRepositoryNameAttributeKey, SEGMENT_REPO)
.put(translogRepositoryNameAttributeKey, TRANSLOG_REPO)
.build();
clusterSettings = new ClusterSettings(
Settings.builder().put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT).build(),
ClusterSettings.BUILT_IN_CLUSTER_SETTINGS
);
request = new CreateIndexClusterStateUpdateRequest("create index", "test", "test");
Settings indexSettings = aggregateIndexSettings(
clusterState,
Expand Down Expand Up @@ -1936,7 +1928,6 @@ public void testDeprecatedSimpleFSStoreSettings() {

public void testClusterReplicationSetting() {
Settings settings = Settings.builder().put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT).build();
clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
request = new CreateIndexClusterStateUpdateRequest("create index", "test", "test");
Settings indexSettings = aggregateIndexSettings(
ClusterState.EMPTY_STATE,
Expand Down

0 comments on commit b1c049e

Please sign in to comment.