From fc67b7835bcf94e0b2d6939ee0731db2475d8976 Mon Sep 17 00:00:00 2001 From: Sachin Kale Date: Thu, 5 Oct 2023 12:25:04 +0530 Subject: [PATCH] Enable remote store settings Signed-off-by: Sachin Kale --- .../test/OpenSearchIntegTestCase.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java index 32f3a6b3ebad5..4b3932f0b5cd3 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java @@ -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; @@ -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() @@ -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: @@ -2099,6 +2158,10 @@ protected boolean useSegmentReplication() { return true; } + protected boolean useRemoteStore() { + return true; + } + private NodeConfigurationSource getNodeConfigSource() { Settings.Builder initialNodeSettings = Settings.builder(); if (addMockTransportService()) {