Skip to content

Commit b9b5359

Browse files
author
Gagan Singh Saini
committed
Modified DeleteSnapshotV2IT for Warm Index
Signed-off-by: Gagan Singh Saini <gagasa@amazon.com>
1 parent f8e8a37 commit b9b5359

File tree

1 file changed

+50
-5
lines changed

1 file changed

+50
-5
lines changed

server/src/internalClusterTest/java/org/opensearch/snapshots/DeleteSnapshotV2IT.java

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@
88

99
package org.opensearch.snapshots;
1010

11+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
12+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
13+
14+
import org.apache.lucene.tests.util.LuceneTestCase;
1115
import org.opensearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
1216
import org.opensearch.action.support.clustermanager.AcknowledgedResponse;
1317
import org.opensearch.cluster.metadata.IndexMetadata;
1418
import org.opensearch.common.settings.Settings;
1519
import org.opensearch.common.unit.TimeValue;
1620
import org.opensearch.core.common.unit.ByteSizeUnit;
21+
import org.opensearch.core.common.unit.ByteSizeValue;
1722
import org.opensearch.index.remote.RemoteStoreEnums;
23+
import org.opensearch.index.store.remote.file.CleanerDaemonThreadLeakFilter;
1824
import org.opensearch.indices.RemoteStoreSettings;
25+
import org.opensearch.node.Node;
1926
import org.opensearch.node.remotestore.RemoteStorePinnedTimestampService;
2027
import org.opensearch.remotestore.RemoteStoreBaseIntegTestCase;
2128
import org.opensearch.repositories.blobstore.BlobStoreRepository;
@@ -26,18 +33,55 @@
2633
import java.nio.file.Files;
2734
import java.nio.file.NoSuchFileException;
2835
import java.nio.file.Path;
36+
import java.util.Arrays;
37+
import java.util.Collection;
2938
import java.util.List;
3039
import java.util.concurrent.TimeUnit;
3140
import java.util.stream.Collectors;
3241

42+
import static org.opensearch.cluster.routing.UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING;
43+
import static org.opensearch.common.util.FeatureFlags.WRITABLE_WARM_INDEX_SETTING;
3344
import static org.opensearch.index.IndexSettings.INDEX_REMOTE_TRANSLOG_KEEP_EXTRA_GEN_SETTING;
3445
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
3546
import static org.hamcrest.Matchers.equalTo;
3647
import static org.hamcrest.Matchers.greaterThan;
3748

49+
// TODO : Delete Index in teardown and prune cache to remove Index Files
50+
@LuceneTestCase.SuppressFileSystems("*")
51+
@ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class)
3852
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
3953
public class DeleteSnapshotV2IT extends AbstractSnapshotIntegTestCase {
4054

55+
public DeleteSnapshotV2IT(Settings nodeSettings) {
56+
super(nodeSettings);
57+
}
58+
59+
/*
60+
Disabling MockFSIndexStore plugin as the MockFSDirectoryFactory wraps the FSDirectory over a OpenSearchMockDirectoryWrapper which extends FilterDirectory (whereas FSDirectory extends BaseDirectory)
61+
As a result of this wrapping the local directory of Composite Directory does not satisfy the assertion that local directory must be of type FSDirectory
62+
*/
63+
@Override
64+
protected boolean addMockIndexStorePlugin() {
65+
return !WRITABLE_WARM_INDEX_SETTING.get(settings);
66+
}
67+
68+
@ParametersFactory
69+
public static Collection<Object[]> parameters() {
70+
return Arrays.asList(
71+
new Object[] { Settings.builder().put(WRITABLE_WARM_INDEX_SETTING.getKey(), false).build() },
72+
new Object[] { Settings.builder().put(WRITABLE_WARM_INDEX_SETTING.getKey(), true).build() }
73+
);
74+
}
75+
76+
@Override
77+
protected Settings nodeSettings(int nodeOrdinal) {
78+
ByteSizeValue cacheSize = new ByteSizeValue(16, ByteSizeUnit.GB);
79+
return Settings.builder()
80+
.put(super.nodeSettings(nodeOrdinal))
81+
.put(Node.NODE_SEARCH_CACHE_SIZE_SETTING.getKey(), cacheSize.toString())
82+
.build();
83+
}
84+
4185
private static final String REMOTE_REPO_NAME = "remote-store-repo-name";
4286

4387
private void keepPinnedTimestampSchedulerUpdated() throws InterruptedException {
@@ -55,8 +99,8 @@ public void testDeleteShallowCopyV2() throws Exception {
5599
final Path remoteStoreRepoPath = randomRepoPath();
56100
internalCluster().startClusterManagerOnlyNode(snapshotV2Settings(remoteStoreRepoPath));
57101

58-
internalCluster().startDataOnlyNode(snapshotV2Settings(remoteStoreRepoPath));
59-
internalCluster().startDataOnlyNode(snapshotV2Settings(remoteStoreRepoPath));
102+
internalCluster().startDataAndWarmNodes(1, snapshotV2Settings(remoteStoreRepoPath));
103+
internalCluster().startDataAndWarmNodes(1, snapshotV2Settings(remoteStoreRepoPath));
60104

61105
String indexName1 = "testindex1";
62106
String indexName2 = "testindex2";
@@ -139,7 +183,7 @@ public void testRemoteStoreCleanupForDeletedIndexForSnapshotV2() throws Exceptio
139183
.put(RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING.getKey(), RemoteStoreEnums.PathType.FIXED.toString())
140184
.build();
141185
String clusterManagerName = internalCluster().startClusterManagerOnlyNode(settings);
142-
internalCluster().startDataOnlyNode(settings);
186+
internalCluster().startDataAndWarmNodes(1, settings);
143187
final Client clusterManagerClient = internalCluster().clusterManagerClient();
144188
ensureStableCluster(2);
145189

@@ -222,7 +266,7 @@ public void testRemoteStoreCleanupForDeletedIndexForSnapshotV2MultipleSnapshots(
222266
.put(RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING.getKey(), RemoteStoreEnums.PathType.FIXED.toString())
223267
.build();
224268
String clusterManagerName = internalCluster().startClusterManagerOnlyNode(settings);
225-
internalCluster().startDataOnlyNode(settings);
269+
internalCluster().startDataAndWarmNodes(1, settings);
226270
final Client clusterManagerClient = internalCluster().clusterManagerClient();
227271
ensureStableCluster(2);
228272

@@ -323,7 +367,7 @@ public void testRemoteStoreCleanupMultiplePrimaryOnSnapshotDeletion() throws Exc
323367
.put(RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_TYPE_SETTING.getKey(), RemoteStoreEnums.PathType.FIXED.toString())
324368
.build();
325369
String clusterManagerName = internalCluster().startClusterManagerOnlyNode(settings);
326-
internalCluster().startDataOnlyNodes(3, settings);
370+
internalCluster().startDataAndWarmNodes(3, settings);
327371
final Client clusterManagerClient = internalCluster().clusterManagerClient();
328372
ensureStableCluster(4);
329373

@@ -341,6 +385,7 @@ public void testRemoteStoreCleanupMultiplePrimaryOnSnapshotDeletion() throws Exc
341385
final String remoteStoreEnabledIndexName = "remote-index-1";
342386
final Settings remoteStoreEnabledIndexSettings = Settings.builder()
343387
.put(getRemoteStoreBackedIndexSettings())
388+
.put(INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueSeconds(0))
344389
.put(INDEX_REMOTE_TRANSLOG_KEEP_EXTRA_GEN_SETTING.getKey(), 2)
345390
.build();
346391
createIndex(remoteStoreEnabledIndexName, remoteStoreEnabledIndexSettings);

0 commit comments

Comments
 (0)