Skip to content

Commit 8ce3687

Browse files
[Remote Store] Add support for Running Parameterized Remote Store Enabled Integration Tests (opensearch-project#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>
1 parent e1c1858 commit 8ce3687

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
@@ -147,6 +147,7 @@
147147
import org.opensearch.node.NodeMocksPlugin;
148148
import org.opensearch.plugins.NetworkPlugin;
149149
import org.opensearch.plugins.Plugin;
150+
import org.opensearch.repositories.fs.ReloadableFsRepository;
150151
import org.opensearch.script.MockScriptService;
151152
import org.opensearch.search.MockSearchService;
152153
import org.opensearch.search.SearchHit;
@@ -210,6 +211,11 @@
210211
import static org.opensearch.index.IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING;
211212
import static org.opensearch.index.query.QueryBuilders.matchAllQuery;
212213
import static org.opensearch.indices.IndicesService.CLUSTER_REPLICATION_TYPE_SETTING;
214+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY;
215+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX;
216+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT;
217+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY;
218+
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY;
213219
import static org.opensearch.test.XContentTestUtils.convertToMap;
214220
import static org.opensearch.test.XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder;
215221
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
@@ -2477,4 +2483,118 @@ protected long getLatestSegmentInfoVersion(IndexShard shard) {
24772483
}
24782484
}
24792485

2486+
public static Settings remoteStoreClusterSettings(String name, Path path) {
2487+
return remoteStoreClusterSettings(name, path, name, path);
2488+
}
2489+
2490+
public static Settings remoteStoreClusterSettings(
2491+
String segmentRepoName,
2492+
Path segmentRepoPath,
2493+
String segmentRepoType,
2494+
String translogRepoName,
2495+
Path translogRepoPath,
2496+
String translogRepoType
2497+
) {
2498+
Settings.Builder settingsBuilder = Settings.builder();
2499+
settingsBuilder.put(
2500+
buildRemoteStoreNodeAttributes(
2501+
segmentRepoName,
2502+
segmentRepoPath,
2503+
segmentRepoType,
2504+
translogRepoName,
2505+
translogRepoPath,
2506+
translogRepoType,
2507+
false
2508+
)
2509+
);
2510+
return settingsBuilder.build();
2511+
}
2512+
2513+
public static Settings remoteStoreClusterSettings(
2514+
String segmentRepoName,
2515+
Path segmentRepoPath,
2516+
String translogRepoName,
2517+
Path translogRepoPath
2518+
) {
2519+
Settings.Builder settingsBuilder = Settings.builder();
2520+
settingsBuilder.put(buildRemoteStoreNodeAttributes(segmentRepoName, segmentRepoPath, translogRepoName, translogRepoPath, false));
2521+
return settingsBuilder.build();
2522+
}
2523+
2524+
public static Settings buildRemoteStoreNodeAttributes(
2525+
String segmentRepoName,
2526+
Path segmentRepoPath,
2527+
String translogRepoName,
2528+
Path translogRepoPath,
2529+
boolean withRateLimiterAttributes
2530+
) {
2531+
return buildRemoteStoreNodeAttributes(
2532+
segmentRepoName,
2533+
segmentRepoPath,
2534+
ReloadableFsRepository.TYPE,
2535+
translogRepoName,
2536+
translogRepoPath,
2537+
ReloadableFsRepository.TYPE,
2538+
withRateLimiterAttributes
2539+
);
2540+
}
2541+
2542+
public static Settings buildRemoteStoreNodeAttributes(
2543+
String segmentRepoName,
2544+
Path segmentRepoPath,
2545+
String segmentRepoType,
2546+
String translogRepoName,
2547+
Path translogRepoPath,
2548+
String translogRepoType,
2549+
boolean withRateLimiterAttributes
2550+
) {
2551+
String segmentRepoTypeAttributeKey = String.format(
2552+
Locale.getDefault(),
2553+
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
2554+
segmentRepoName
2555+
);
2556+
String segmentRepoSettingsAttributeKeyPrefix = String.format(
2557+
Locale.getDefault(),
2558+
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
2559+
segmentRepoName
2560+
);
2561+
String translogRepoTypeAttributeKey = String.format(
2562+
Locale.getDefault(),
2563+
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
2564+
translogRepoName
2565+
);
2566+
String translogRepoSettingsAttributeKeyPrefix = String.format(
2567+
Locale.getDefault(),
2568+
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
2569+
translogRepoName
2570+
);
2571+
String stateRepoTypeAttributeKey = String.format(
2572+
Locale.getDefault(),
2573+
"node.attr." + REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT,
2574+
segmentRepoName
2575+
);
2576+
String stateRepoSettingsAttributeKeyPrefix = String.format(
2577+
Locale.getDefault(),
2578+
"node.attr." + REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX,
2579+
segmentRepoName
2580+
);
2581+
2582+
Settings.Builder settings = Settings.builder()
2583+
.put("node.attr." + REMOTE_STORE_SEGMENT_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
2584+
.put(segmentRepoTypeAttributeKey, segmentRepoType)
2585+
.put(segmentRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath)
2586+
.put("node.attr." + REMOTE_STORE_TRANSLOG_REPOSITORY_NAME_ATTRIBUTE_KEY, translogRepoName)
2587+
.put(translogRepoTypeAttributeKey, translogRepoType)
2588+
.put(translogRepoSettingsAttributeKeyPrefix + "location", translogRepoPath)
2589+
.put("node.attr." + REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY, segmentRepoName)
2590+
.put(stateRepoTypeAttributeKey, segmentRepoType)
2591+
.put(stateRepoSettingsAttributeKeyPrefix + "location", segmentRepoPath);
2592+
2593+
if (withRateLimiterAttributes) {
2594+
settings.put(segmentRepoSettingsAttributeKeyPrefix + "compress", randomBoolean())
2595+
.put(segmentRepoSettingsAttributeKeyPrefix + "chunk_size", 200, ByteSizeUnit.BYTES);
2596+
}
2597+
return settings.build();
2598+
}
2599+
24802600
}

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)