Skip to content

Commit 93c0177

Browse files
[Remote Store] Add support for Running Parameterized Remote Store Enabled Integration Tests (#12487)
* Add support for parameterized remote-store testing for Integration Tests. Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> * Rename variable names. Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> --------- Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> Signed-off-by: Rishikesh Pasham <62345295+Rishikesh1159@users.noreply.github.com> (cherry picked from commit 8ce3687) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 5bb0078 commit 93c0177

File tree

4 files changed

+150
-122
lines changed

4 files changed

+150
-122
lines changed

server/src/internalClusterTest/java/org/opensearch/indices/store/IndicesStoreIntegrationIT.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.indices.store;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
36+
3537
import org.apache.logging.log4j.Logger;
3638
import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
3739
import org.opensearch.action.admin.cluster.state.ClusterStateResponse;
@@ -60,9 +62,9 @@
6062
import org.opensearch.indices.recovery.PeerRecoveryTargetService;
6163
import org.opensearch.plugins.Plugin;
6264
import org.opensearch.test.InternalTestCluster;
63-
import org.opensearch.test.OpenSearchIntegTestCase;
6465
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope;
6566
import org.opensearch.test.OpenSearchIntegTestCase.Scope;
67+
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
6668
import org.opensearch.test.disruption.BlockClusterStateProcessing;
6769
import org.opensearch.test.transport.MockTransportService;
6870
import org.opensearch.transport.ConnectTransportException;
@@ -85,7 +87,16 @@
8587
import static org.hamcrest.Matchers.equalTo;
8688

8789
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
88-
public class IndicesStoreIntegrationIT extends OpenSearchIntegTestCase {
90+
public class IndicesStoreIntegrationIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {
91+
public IndicesStoreIntegrationIT(Settings nodeSettings) {
92+
super(nodeSettings);
93+
}
94+
95+
@ParametersFactory
96+
public static Collection<Object[]> parameters() {
97+
return remoteStoreSettings;
98+
}
99+
89100
@Override
90101
protected Settings nodeSettings(int nodeOrdinal) { // simplify this and only use a single data path
91102
return Settings.builder()

server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java

-119
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.opensearch.cluster.service.ClusterService;
2929
import org.opensearch.common.UUIDs;
3030
import org.opensearch.common.settings.Settings;
31-
import org.opensearch.core.common.unit.ByteSizeUnit;
3231
import org.opensearch.core.index.Index;
3332
import org.opensearch.index.IndexModule;
3433
import org.opensearch.index.IndexService;
@@ -57,11 +56,8 @@
5756
import java.util.concurrent.atomic.AtomicInteger;
5857
import java.util.stream.Collectors;
5958

60-
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY;
6159
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX;
6260
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT;
63-
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY;
64-
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY;
6561
import static org.opensearch.repositories.fs.ReloadableFsRepository.REPOSITORIES_FAILRATE_SETTING;
6662
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
6763

@@ -191,121 +187,6 @@ protected BulkResponse indexBulk(String indexName, int numDocs) {
191187
return client().bulk(bulkRequest).actionGet();
192188
}
193189

194-
public static Settings remoteStoreClusterSettings(String name, Path path) {
195-
return remoteStoreClusterSettings(name, path, name, path);
196-
}
197-
198-
public static Settings remoteStoreClusterSettings(
199-
String segmentRepoName,
200-
Path segmentRepoPath,
201-
String segmentRepoType,
202-
String translogRepoName,
203-
Path translogRepoPath,
204-
String translogRepoType
205-
) {
206-
Settings.Builder settingsBuilder = Settings.builder();
207-
settingsBuilder.put(
208-
buildRemoteStoreNodeAttributes(
209-
segmentRepoName,
210-
segmentRepoPath,
211-
segmentRepoType,
212-
translogRepoName,
213-
translogRepoPath,
214-
translogRepoType,
215-
false
216-
)
217-
);
218-
return settingsBuilder.build();
219-
}
220-
221-
public static Settings remoteStoreClusterSettings(
222-
String segmentRepoName,
223-
Path segmentRepoPath,
224-
String translogRepoName,
225-
Path translogRepoPath
226-
) {
227-
Settings.Builder settingsBuilder = Settings.builder();
228-
settingsBuilder.put(buildRemoteStoreNodeAttributes(segmentRepoName, segmentRepoPath, translogRepoName, translogRepoPath, false));
229-
return settingsBuilder.build();
230-
}
231-
232-
public static Settings buildRemoteStoreNodeAttributes(
233-
String segmentRepoName,
234-
Path segmentRepoPath,
235-
String translogRepoName,
236-
Path translogRepoPath,
237-
boolean withRateLimiterAttributes
238-
) {
239-
return buildRemoteStoreNodeAttributes(
240-
segmentRepoName,
241-
segmentRepoPath,
242-
ReloadableFsRepository.TYPE,
243-
translogRepoName,
244-
translogRepoPath,
245-
ReloadableFsRepository.TYPE,
246-
withRateLimiterAttributes
247-
);
248-
}
249-
250-
public static Settings buildRemoteStoreNodeAttributes(
251-
String segmentRepoName,
252-
Path segmentRepoPath,
253-
String segmentRepoType,
254-
String translogRepoName,
255-
Path translogRepoPath,
256-
String translogRepoType,
257-
boolean withRateLimiterAttributes
258-
) {
259-
String segmentRepoTypeAttributeKey = String.format(
260-
Locale.getDefault(),
261-
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
262-
segmentRepoName
263-
);
264-
String segmentRepoSettingsAttributeKeyPrefix = String.format(
265-
Locale.getDefault(),
266-
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
267-
segmentRepoName
268-
);
269-
String translogRepoTypeAttributeKey = String.format(
270-
Locale.getDefault(),
271-
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
272-
translogRepoName
273-
);
274-
String translogRepoSettingsAttributeKeyPrefix = String.format(
275-
Locale.getDefault(),
276-
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
277-
translogRepoName
278-
);
279-
String stateRepoTypeAttributeKey = String.format(
280-
Locale.getDefault(),
281-
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
282-
segmentRepoName
283-
);
284-
String stateRepoSettingsAttributeKeyPrefix = String.format(
285-
Locale.getDefault(),
286-
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
287-
segmentRepoName
288-
);
289-
290-
Settings.Builder settings = Settings.builder()
291-
.put("node.attr." + REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
292-
.put(segmentRepoTypeAttributeKey, segmentRepoType)
293-
.put(segmentRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath)
294-
.put("node.attr." + REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY, translogRepoName)
295-
.put(translogRepoTypeAttributeKey, translogRepoType)
296-
.put(translogRepoSettingsAttributeKeyPrefix + "location", translogRepoPath)
297-
.put("node.attr." + REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
298-
.put(stateRepoTypeAttributeKey, segmentRepoType)
299-
.put(stateRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath);
300-
301-
if (withRateLimiterAttributes) {
302-
settings.put(segmentRepoSettingsAttributeKeyPrefix + "compress", randomBoolean())
303-
.put(segmentRepoSettingsAttributeKeyPrefix + "chunk_size", 200, ByteSizeUnit.BYTES);
304-
}
305-
306-
return settings.build();
307-
}
308-
309190
private Settings defaultIndexSettings() {
310191
return Settings.builder()
311192
.put(super.indexSettings())

test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java

+120
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
import org.opensearch.node.NodeMocksPlugin;
154154
import org.opensearch.plugins.NetworkPlugin;
155155
import org.opensearch.plugins.Plugin;
156+
import org.opensearch.repositories.fs.ReloadableFsRepository;
156157
import org.opensearch.script.MockScriptService;
157158
import org.opensearch.script.ScriptMetadata;
158159
import org.opensearch.search.MockSearchService;
@@ -217,6 +218,11 @@
217218
import static org.opensearch.index.IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING;
218219
import static org.opensearch.index.query.QueryBuilders.matchAllQuery;
219220
import static org.opensearch.indices.IndicesService.CLUSTER_REPLICATION_TYPE_SETTING;
221+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY;
222+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX;
223+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT;
224+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY;
225+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY;
220226
import static org.opensearch.test.XContentTestUtils.convertToMap;
221227
import static org.opensearch.test.XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder;
222228
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
@@ -2520,4 +2526,118 @@ protected long getLatestSegmentInfoVersion(IndexShard shard) {
25202526
}
25212527
}
25222528

2529+
public static Settings remoteStoreClusterSettings(String name, Path path) {
2530+
return remoteStoreClusterSettings(name, path, name, path);
2531+
}
2532+
2533+
public static Settings remoteStoreClusterSettings(
2534+
String segmentRepoName,
2535+
Path segmentRepoPath,
2536+
String segmentRepoType,
2537+
String translogRepoName,
2538+
Path translogRepoPath,
2539+
String translogRepoType
2540+
) {
2541+
Settings.Builder settingsBuilder = Settings.builder();
2542+
settingsBuilder.put(
2543+
buildRemoteStoreNodeAttributes(
2544+
segmentRepoName,
2545+
segmentRepoPath,
2546+
segmentRepoType,
2547+
translogRepoName,
2548+
translogRepoPath,
2549+
translogRepoType,
2550+
false
2551+
)
2552+
);
2553+
return settingsBuilder.build();
2554+
}
2555+
2556+
public static Settings remoteStoreClusterSettings(
2557+
String segmentRepoName,
2558+
Path segmentRepoPath,
2559+
String translogRepoName,
2560+
Path translogRepoPath
2561+
) {
2562+
Settings.Builder settingsBuilder = Settings.builder();
2563+
settingsBuilder.put(buildRemoteStoreNodeAttributes(segmentRepoName, segmentRepoPath, translogRepoName, translogRepoPath, false));
2564+
return settingsBuilder.build();
2565+
}
2566+
2567+
public static Settings buildRemoteStoreNodeAttributes(
2568+
String segmentRepoName,
2569+
Path segmentRepoPath,
2570+
String translogRepoName,
2571+
Path translogRepoPath,
2572+
boolean withRateLimiterAttributes
2573+
) {
2574+
return buildRemoteStoreNodeAttributes(
2575+
segmentRepoName,
2576+
segmentRepoPath,
2577+
ReloadableFsRepository.TYPE,
2578+
translogRepoName,
2579+
translogRepoPath,
2580+
ReloadableFsRepository.TYPE,
2581+
withRateLimiterAttributes
2582+
);
2583+
}
2584+
2585+
public static Settings buildRemoteStoreNodeAttributes(
2586+
String segmentRepoName,
2587+
Path segmentRepoPath,
2588+
String segmentRepoType,
2589+
String translogRepoName,
2590+
Path translogRepoPath,
2591+
String translogRepoType,
2592+
boolean withRateLimiterAttributes
2593+
) {
2594+
String segmentRepoTypeAttributeKey = String.format(
2595+
Locale.getDefault(),
2596+
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
2597+
segmentRepoName
2598+
);
2599+
String segmentRepoSettingsAttributeKeyPrefix = String.format(
2600+
Locale.getDefault(),
2601+
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
2602+
segmentRepoName
2603+
);
2604+
String translogRepoTypeAttributeKey = String.format(
2605+
Locale.getDefault(),
2606+
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
2607+
translogRepoName
2608+
);
2609+
String translogRepoSettingsAttributeKeyPrefix = String.format(
2610+
Locale.getDefault(),
2611+
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
2612+
translogRepoName
2613+
);
2614+
String stateRepoTypeAttributeKey = String.format(
2615+
Locale.getDefault(),
2616+
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
2617+
segmentRepoName
2618+
);
2619+
String stateRepoSettingsAttributeKeyPrefix = String.format(
2620+
Locale.getDefault(),
2621+
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
2622+
segmentRepoName
2623+
);
2624+
2625+
Settings.Builder settings = Settings.builder()
2626+
.put("node.attr." + REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
2627+
.put(segmentRepoTypeAttributeKey, segmentRepoType)
2628+
.put(segmentRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath)
2629+
.put("node.attr." + REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY, translogRepoName)
2630+
.put(translogRepoTypeAttributeKey, translogRepoType)
2631+
.put(translogRepoSettingsAttributeKeyPrefix + "location", translogRepoPath)
2632+
.put("node.attr." + REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
2633+
.put(stateRepoTypeAttributeKey, segmentRepoType)
2634+
.put(stateRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath);
2635+
2636+
if (withRateLimiterAttributes) {
2637+
settings.put(segmentRepoSettingsAttributeKeyPrefix + "compress", randomBoolean())
2638+
.put(segmentRepoSettingsAttributeKeyPrefix + "chunk_size", 200, ByteSizeUnit.BYTES);
2639+
}
2640+
return settings.build();
2641+
}
2642+
25232643
}

test/framework/src/main/java/org/opensearch/test/ParameterizedStaticSettingsOpenSearchIntegTestCase.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
import org.opensearch.common.settings.Settings;
1212
import org.opensearch.indices.replication.common.ReplicationType;
1313

14+
import java.nio.file.Path;
1415
import java.util.Arrays;
1516
import java.util.List;
1617
import java.util.Objects;
1718

19+
import static org.opensearch.gateway.remote.RemoteClusterStateService.REMOTE_CLUSTER_STATE_ENABLED_SETTING;
1820
import static org.opensearch.indices.IndicesService.CLUSTER_REPLICATION_TYPE_SETTING;
1921

2022
/**
@@ -30,6 +32,8 @@
3032
*/
3133
public abstract class ParameterizedStaticSettingsOpenSearchIntegTestCase extends ParameterizedOpenSearchIntegTestCase {
3234

35+
protected static final String REMOTE_STORE_REPOSITORY_NAME = "test-remote-store-repo";
36+
private Path remoteStoreRepositoryPath;
3337
public static final List<Object[]> replicationSettings = Arrays.asList(
3438
new Object[] { Settings.builder().put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.DOCUMENT).build() },
3539
new Object[] { Settings.builder().put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT).build() }
@@ -39,9 +43,21 @@ public ParameterizedStaticSettingsOpenSearchIntegTestCase(Settings nodeSettings)
3943
super(nodeSettings);
4044
}
4145

46+
public static final List<Object[]> remoteStoreSettings = Arrays.asList(
47+
new Object[] { Settings.builder().put(REMOTE_CLUSTER_STATE_ENABLED_SETTING.getKey(), true).build() },
48+
new Object[] { Settings.builder().put(REMOTE_CLUSTER_STATE_ENABLED_SETTING.getKey(), false).build() }
49+
);
50+
4251
@Override
4352
protected Settings nodeSettings(int nodeOrdinal) {
44-
return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(settings).build();
53+
Settings.Builder builder = Settings.builder();
54+
if (REMOTE_CLUSTER_STATE_ENABLED_SETTING.get(settings)) {
55+
if (remoteStoreRepositoryPath == null) {
56+
remoteStoreRepositoryPath = randomRepoPath().toAbsolutePath();
57+
}
58+
builder.put(remoteStoreClusterSettings(REMOTE_STORE_REPOSITORY_NAME, remoteStoreRepositoryPath));
59+
}
60+
return builder.put(super.nodeSettings(nodeOrdinal)).put(settings).build();
4561
}
4662

4763
@Override

0 commit comments

Comments
 (0)