88
99package org .opensearch .remotestore ;
1010
11+ import com .carrotsearch .randomizedtesting .annotations .ParametersFactory ;
12+ import com .carrotsearch .randomizedtesting .annotations .ThreadLeakFilters ;
13+
1114import org .opensearch .action .DocWriteResponse ;
1215import org .opensearch .action .LatchedActionListener ;
1316import org .opensearch .action .admin .cluster .remotestore .restore .RestoreRemoteStoreRequest ;
3033import org .opensearch .common .util .io .IOUtils ;
3134import org .opensearch .core .action .ActionListener ;
3235import org .opensearch .core .common .unit .ByteSizeUnit ;
36+ import org .opensearch .core .common .unit .ByteSizeValue ;
3337import org .opensearch .core .index .Index ;
3438import org .opensearch .core .rest .RestStatus ;
3539import org .opensearch .index .IndexService ;
3640import org .opensearch .index .IndexSettings ;
3741import org .opensearch .index .remote .RemoteStoreEnums .PathHashAlgorithm ;
3842import org .opensearch .index .remote .RemoteStoreEnums .PathType ;
3943import org .opensearch .index .shard .IndexShard ;
44+ import org .opensearch .index .store .remote .file .CleanerDaemonThreadLeakFilter ;
4045import org .opensearch .indices .IndicesService ;
4146import org .opensearch .indices .RemoteStoreSettings ;
4247import org .opensearch .indices .recovery .RecoveryState ;
4348import org .opensearch .indices .replication .common .ReplicationType ;
49+ import org .opensearch .node .Node ;
4450import org .opensearch .node .remotestore .RemoteStorePinnedTimestampService ;
4551import org .opensearch .repositories .RepositoriesService ;
4652import org .opensearch .repositories .Repository ;
6066import java .nio .file .Path ;
6167import java .util .ArrayList ;
6268import java .util .Arrays ;
69+ import java .util .Collection ;
6370import java .util .Collections ;
6471import java .util .List ;
6572import java .util .Map ;
7784import static org .opensearch .cluster .metadata .IndexMetadata .SETTING_REMOTE_SEGMENT_STORE_REPOSITORY ;
7885import static org .opensearch .cluster .metadata .IndexMetadata .SETTING_REMOTE_STORE_ENABLED ;
7986import static org .opensearch .cluster .metadata .IndexMetadata .SETTING_REMOTE_TRANSLOG_STORE_REPOSITORY ;
87+ import static org .opensearch .common .util .FeatureFlags .WRITABLE_WARM_INDEX_SETTING ;
8088import static org .opensearch .index .remote .RemoteStoreEnums .DataCategory .SEGMENTS ;
8189import static org .opensearch .index .remote .RemoteStoreEnums .DataCategory .TRANSLOG ;
8290import static org .opensearch .index .remote .RemoteStoreEnums .DataType .DATA ;
8997import static org .hamcrest .Matchers .greaterThanOrEqualTo ;
9098import static org .hamcrest .Matchers .lessThanOrEqualTo ;
9199
100+ @ ThreadLeakFilters (filters = CleanerDaemonThreadLeakFilter .class )
92101@ OpenSearchIntegTestCase .ClusterScope (scope = OpenSearchIntegTestCase .Scope .TEST , numDataNodes = 0 )
93102public class RemoteRestoreSnapshotIT extends RemoteSnapshotIT {
94103
104+ public RemoteRestoreSnapshotIT (Settings nodeSettings ) {
105+ super (nodeSettings );
106+ }
107+
108+ @ ParametersFactory
109+ public static Collection <Object []> parameters () {
110+ return Arrays .asList (
111+ new Object [] { Settings .builder ().put (WRITABLE_WARM_INDEX_SETTING .getKey (), false ).build () },
112+ new Object [] { Settings .builder ().put (WRITABLE_WARM_INDEX_SETTING .getKey (), true ).build () }
113+ );
114+ }
115+
116+ @ Override
117+ protected Settings nodeSettings (int nodeOrdinal ) {
118+ ByteSizeValue cacheSize = new ByteSizeValue (16 , ByteSizeUnit .GB );
119+ return Settings .builder ()
120+ .put (super .nodeSettings (nodeOrdinal ))
121+ .put (Node .NODE_SEARCH_CACHE_SIZE_SETTING .getKey (), cacheSize .toString ())
122+ .build ();
123+ }
124+
95125 private void assertDocsPresentInIndex (Client client , String indexName , int numOfDocs ) {
96126 for (int i = 0 ; i < numOfDocs ; i ++) {
97127 String id = Integer .toString (i );
@@ -102,7 +132,7 @@ private void assertDocsPresentInIndex(Client client, String indexName, int numOf
102132
103133 public void testRestoreOperationsShallowCopyEnabled () throws Exception {
104134 String clusterManagerNode = internalCluster ().startClusterManagerOnlyNode ();
105- String primary = internalCluster ().startDataOnlyNode ( );
135+ String primary = internalCluster ().startDataAndWarmNodes ( 1 ). get ( 0 );
106136 String indexName1 = "testindex1" ;
107137 String indexName2 = "testindex2" ;
108138 String snapshotRepoName = "test-restore-snapshot-repo" ;
@@ -128,7 +158,7 @@ public void testRestoreOperationsShallowCopyEnabled() throws Exception {
128158 indexDocuments (client , indexName2 , numDocsInIndex2 );
129159 ensureGreen (indexName1 , indexName2 );
130160
131- internalCluster ().startDataOnlyNode ( );
161+ internalCluster ().startDataAndWarmNodes ( 1 );
132162 logger .info ("--> snapshot" );
133163
134164 SnapshotInfo snapshotInfo = createSnapshot (snapshotRepoName , snapshotName1 , new ArrayList <>(Arrays .asList (indexName1 , indexName2 )));
@@ -200,7 +230,7 @@ public void testRestoreOperationsShallowCopyEnabled() throws Exception {
200230 */
201231 public void testRemoteStoreCustomDataOnIndexCreationAndRestore () {
202232 String clusterManagerNode = internalCluster ().startClusterManagerOnlyNode ();
203- internalCluster ().startDataOnlyNode ( );
233+ internalCluster ().startDataAndWarmNodes ( 1 );
204234 String indexName1 = "testindex1" ;
205235 String indexName2 = "testindex2" ;
206236 String snapshotRepoName = "test-restore-snapshot-repo" ;
@@ -313,7 +343,7 @@ private void validatePathType(String index, PathType pathType, @Nullable PathHas
313343
314344 public void testRestoreInSameRemoteStoreEnabledIndex () throws IOException {
315345 String clusterManagerNode = internalCluster ().startClusterManagerOnlyNode ();
316- String primary = internalCluster ().startDataOnlyNode ( );
346+ String primary = internalCluster ().startDataAndWarmNodes ( 1 ). get ( 0 );
317347 String indexName1 = "testindex1" ;
318348 String indexName2 = "testindex2" ;
319349 String snapshotRepoName = "test-restore-snapshot-repo" ;
@@ -339,7 +369,7 @@ public void testRestoreInSameRemoteStoreEnabledIndex() throws IOException {
339369 indexDocuments (client , indexName2 , numDocsInIndex2 );
340370 ensureGreen (indexName1 , indexName2 );
341371
342- internalCluster ().startDataOnlyNode ( );
372+ internalCluster ().startDataAndWarmNodes ( 1 );
343373 logger .info ("--> snapshot" );
344374 SnapshotInfo snapshotInfo1 = createSnapshot (
345375 snapshotRepoName ,
@@ -441,7 +471,7 @@ void assertRemoteSegmentsAndTranslogUploaded(String idx) throws IOException {
441471
442472 public void testRemoteRestoreIndexRestoredFromSnapshot () throws IOException , ExecutionException , InterruptedException {
443473 internalCluster ().startClusterManagerOnlyNode ();
444- internalCluster ().startDataOnlyNodes (2 );
474+ internalCluster ().startDataAndWarmNodes (2 );
445475
446476 String indexName1 = "testindex1" ;
447477 String snapshotRepoName = "test-restore-snapshot-repo" ;
@@ -500,7 +530,7 @@ public void testRemoteRestoreIndexRestoredFromSnapshot() throws IOException, Exe
500530
501531 public void testSuccessfulIndexRestoredFromSnapshotWithUpdatedSetting () throws IOException , ExecutionException , InterruptedException {
502532 internalCluster ().startClusterManagerOnlyNode ();
503- internalCluster ().startDataOnlyNodes (2 );
533+ internalCluster ().startDataAndWarmNodes (2 );
504534
505535 String indexName1 = "testindex1" ;
506536 String snapshotRepoName = "test-restore-snapshot-repo" ;
@@ -716,7 +746,7 @@ public void testRestoreShallowSnapshotIndexAfterSnapshot() throws ExecutionExcep
716746
717747 public void testInvalidRestoreRequestScenarios () throws Exception {
718748 internalCluster ().startClusterManagerOnlyNode ();
719- internalCluster ().startDataOnlyNode ( );
749+ internalCluster ().startDataAndWarmNodes ( 1 );
720750 String index = "test-index" ;
721751 String snapshotRepo = "test-restore-snapshot-repo" ;
722752 String newRemoteStoreRepo = "test-new-rs-repo" ;
@@ -736,7 +766,7 @@ public void testInvalidRestoreRequestScenarios() throws Exception {
736766 indexDocuments (client , index , numDocsInIndex );
737767 ensureGreen (index );
738768
739- internalCluster ().startDataOnlyNode ( );
769+ internalCluster ().startDataAndWarmNodes ( 1 );
740770 logger .info ("--> snapshot" );
741771
742772 SnapshotInfo snapshotInfo = createSnapshot (snapshotRepo , snapshotName1 , new ArrayList <>(List .of (index )));
@@ -896,8 +926,8 @@ public void testInvalidRestoreRequestScenarios() throws Exception {
896926
897927 public void testCreateSnapshotV2_Orphan_Timestamp_Cleanup () throws Exception {
898928 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
899- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
900- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
929+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
930+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
901931 String indexName1 = "testindex1" ;
902932 String indexName2 = "testindex2" ;
903933 String snapshotRepoName = "test-create-snapshot-repo" ;
@@ -962,8 +992,8 @@ public void onFailure(Exception e) {}
962992 public void testMixedSnapshotCreationWithV2RepositorySetting () throws Exception {
963993
964994 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
965- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
966- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
995+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
996+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
967997 String indexName1 = "testindex1" ;
968998 String indexName2 = "testindex2" ;
969999 String indexName3 = "testindex3" ;
@@ -1034,8 +1064,8 @@ public void testMixedSnapshotCreationWithV2RepositorySetting() throws Exception
10341064
10351065 public void testConcurrentSnapshotV2CreateOperation () throws InterruptedException , ExecutionException {
10361066 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
1037- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1038- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1067+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
1068+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
10391069 String indexName1 = "testindex1" ;
10401070 String indexName2 = "testindex2" ;
10411071 String snapshotRepoName = "test-create-snapshot-repo" ;
@@ -1108,8 +1138,8 @@ public void testConcurrentSnapshotV2CreateOperation_MasterChange() throws Except
11081138 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
11091139 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
11101140 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
1111- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1112- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1141+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
1142+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
11131143 String indexName1 = "testindex1" ;
11141144 String indexName2 = "testindex2" ;
11151145 String snapshotRepoName = "test-create-snapshot-repo" ;
@@ -1184,8 +1214,8 @@ public void testConcurrentSnapshotV2CreateOperation_MasterChange() throws Except
11841214
11851215 public void testCreateSnapshotV2 () throws Exception {
11861216 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
1187- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1188- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1217+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
1218+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
11891219 String indexName1 = "testindex1" ;
11901220 String indexName2 = "testindex2" ;
11911221 String indexName3 = "testindex3" ;
@@ -1254,8 +1284,8 @@ public void forceSyncPinnedTimestamps() {
12541284
12551285 public void testCreateSnapshotV2WithRedIndex () throws Exception {
12561286 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
1257- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1258- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1287+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
1288+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
12591289 String indexName1 = "testindex1" ;
12601290 String indexName2 = "testindex2" ;
12611291 String snapshotRepoName = "test-create-snapshot-repo" ;
@@ -1302,8 +1332,8 @@ public void testCreateSnapshotV2WithRedIndex() throws Exception {
13021332
13031333 public void testCreateSnapshotV2WithIndexingLoad () throws Exception {
13041334 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
1305- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1306- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1335+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
1336+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
13071337 String indexName1 = "testindex1" ;
13081338 String indexName2 = "testindex2" ;
13091339 String snapshotRepoName = "test-create-snapshot-repo" ;
@@ -1370,8 +1400,8 @@ public void testCreateSnapshotV2WithIndexingLoad() throws Exception {
13701400
13711401 public void testCreateSnapshotV2WithShallowCopySettingDisabled () throws Exception {
13721402 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
1373- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1374- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1403+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
1404+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
13751405 String indexName1 = "testindex1" ;
13761406 String indexName2 = "testindex2" ;
13771407 String snapshotRepoName = "test-create-snapshot-repo" ;
@@ -1419,7 +1449,7 @@ public void testCreateSnapshotV2WithShallowCopySettingDisabled() throws Exceptio
14191449 public void testClusterManagerFailoverDuringSnapshotCreation () throws Exception {
14201450
14211451 internalCluster ().startClusterManagerOnlyNodes (3 , pinnedTimestampSettings ());
1422- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1452+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
14231453 String indexName1 = "testindex1" ;
14241454 String indexName2 = "testindex2" ;
14251455 String snapshotRepoName = "test-create-snapshot-repo" ;
@@ -1493,8 +1523,8 @@ public void testClusterManagerFailoverDuringSnapshotCreation() throws Exception
14931523
14941524 public void testConcurrentV1SnapshotAndV2RepoSettingUpdate () throws Exception {
14951525 internalCluster ().startClusterManagerOnlyNode (pinnedTimestampSettings ());
1496- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1497- internalCluster ().startDataOnlyNode ( pinnedTimestampSettings ());
1526+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
1527+ internalCluster ().startDataAndWarmNodes ( 1 , pinnedTimestampSettings ());
14981528 String snapshotRepoName = "test-create-snapshot-repo" ;
14991529 String snapshotName1 = "test-create-snapshot-v1" ;
15001530 Path absolutePath1 = randomRepoPath ().toAbsolutePath ();
0 commit comments