Skip to content

Commit

Permalink
Enable remote store settings
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
Sachin Kale committed Oct 5, 2023
1 parent 5100a5c commit fc67b78
Showing 1 changed file with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
import static org.opensearch.index.IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING;
import static org.opensearch.index.query.QueryBuilders.matchAllQuery;
import static org.opensearch.indices.IndicesService.CLUSTER_REPLICATION_TYPE_SETTING;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.*;
import static org.opensearch.test.XContentTestUtils.convertToMap;
import static org.opensearch.test.XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
Expand Down Expand Up @@ -1982,9 +1983,66 @@ protected Settings nodeSettings(int nodeOrdinal) {
if (useSegmentReplication()) {
builder.put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT);
}

if (useRemoteStore()) {
if(nodeAttributeSettings == null) {
nodeAttributeSettings = remoteStoreGlobalNodeAttributes(REPOSITORY_NAME, REPOSITORY_2_NAME, REPOSITORY_3_NAME);
}
builder.put(nodeAttributeSettings);
}

return builder.build();
}

protected Settings nodeAttributeSettings;
protected static final String REPOSITORY_NAME = "test-remote-store-repo";
protected static final String REPOSITORY_2_NAME = "test-remote-store-repo-2";
protected static final String REPOSITORY_3_NAME = "test-remote-store-repo-3";

public Settings remoteStoreGlobalNodeAttributes(String segmentRepoName, String translogRepoName, String stateRepoName) {
Path absolutePath = randomRepoPath().toAbsolutePath();
Path absolutePath2 = randomRepoPath().toAbsolutePath();
Path absolutePath3 = randomRepoPath().toAbsolutePath();
if (segmentRepoName.equals(translogRepoName)) {
absolutePath2 = absolutePath;
}
if (segmentRepoName.equals(stateRepoName)) {
absolutePath3 = absolutePath;
}
return Settings.builder()
.put("node.attr." + REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
.put(
String.format(Locale.getDefault(), "node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT, segmentRepoName),
"fs"
)
.put(
String.format(Locale.getDefault(), "node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX, segmentRepoName)
+ "location",
absolutePath.toString()
)
.put("node.attr." + REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY, translogRepoName)
.put(
String.format(Locale.getDefault(), "node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT, translogRepoName),
"fs"
)
.put(
String.format(Locale.getDefault(), "node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX, translogRepoName)
+ "location",
absolutePath2.toString()
)
.put("node.attr." + REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY, stateRepoName)
.put(
String.format(Locale.getDefault(), "node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT, stateRepoName),
"fs"
)
.put(
String.format(Locale.getDefault(), "node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX, stateRepoName)
+ "location",
absolutePath3.toString()
)
.build();
}

public boolean isSegRepEnabled(String index) {
return client().admin()
.indices()
Expand Down Expand Up @@ -2048,6 +2106,7 @@ protected TestCluster buildTestCluster(Scope scope, long seed) throws IOExceptio
final String nodePrefix;
switch (scope) {
case TEST:
nodeAttributeSettings = null;
nodePrefix = TEST_CLUSTER_NODE_PREFIX;
break;
case SUITE:
Expand Down Expand Up @@ -2099,6 +2158,10 @@ protected boolean useSegmentReplication() {
return true;
}

protected boolean useRemoteStore() {
return true;
}

private NodeConfigurationSource getNodeConfigSource() {
Settings.Builder initialNodeSettings = Settings.builder();
if (addMockTransportService()) {
Expand Down

0 comments on commit fc67b78

Please sign in to comment.