14
14
import org .opensearch .action .admin .cluster .snapshots .delete .DeleteSnapshotRequest ;
15
15
import org .opensearch .action .admin .cluster .snapshots .get .GetSnapshotsResponse ;
16
16
import org .opensearch .action .admin .cluster .snapshots .restore .RestoreSnapshotRequest ;
17
+ import org .opensearch .action .admin .indices .settings .get .GetSettingsRequest ;
18
+ import org .opensearch .action .admin .indices .settings .get .GetSettingsResponse ;
17
19
import org .opensearch .action .admin .indices .settings .put .UpdateSettingsRequestBuilder ;
18
20
import org .opensearch .action .index .IndexRequestBuilder ;
19
21
import org .opensearch .action .support .master .AcknowledgedResponse ;
28
30
import org .opensearch .common .settings .Settings ;
29
31
import org .opensearch .common .unit .ByteSizeUnit ;
30
32
import org .opensearch .index .Index ;
33
+ import org .opensearch .index .IndexModule ;
31
34
import org .opensearch .index .IndexNotFoundException ;
32
35
import org .opensearch .index .store .remote .file .CleanerDaemonThreadLeakFilter ;
33
36
import org .opensearch .index .store .remote .filecache .FileCacheStats ;
@@ -101,6 +104,7 @@ public void testCreateSearchableSnapshot() throws Exception {
101
104
102
105
internalCluster ().ensureAtLeastNumSearchNodes (Math .max (numReplicasIndex1 , numReplicasIndex2 ) + 1 );
103
106
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
107
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName1 , restoredIndexName2 );
104
108
105
109
assertDocCount (restoredIndexName1 , 100L );
106
110
assertDocCount (restoredIndexName2 , 100L );
@@ -196,6 +200,7 @@ public void testCreateSearchableSnapshotWithChunks() throws Exception {
196
200
197
201
deleteIndicesAndEnsureGreen (client , indexName );
198
202
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
203
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName );
199
204
200
205
assertDocCount (restoredIndexName , 1000L );
201
206
}
@@ -219,6 +224,7 @@ public void testSearchableSnapshotAllocationForLocalAndRemoteShardsOnSameNode()
219
224
takeSnapshot (client , snapshotName , repoName , indexName );
220
225
221
226
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
227
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName );
222
228
223
229
assertDocCount (restoredIndexName , 100L );
224
230
assertDocCount (indexName , 100L );
@@ -246,6 +252,7 @@ public void testSearchableSnapshotAllocationForFailoverAndRecovery() throws Exce
246
252
247
253
internalCluster ().ensureAtLeastNumSearchNodes (numReplicasIndex + 1 );
248
254
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
255
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName );
249
256
assertDocCount (restoredIndexName , 100L );
250
257
251
258
logger .info ("--> stop a random search node" );
@@ -285,6 +292,7 @@ public void testSearchableSnapshotIndexIsReadOnly() throws Exception {
285
292
286
293
internalCluster ().ensureAtLeastNumSearchNodes (1 );
287
294
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
295
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName );
288
296
289
297
assertIndexingBlocked (restoredIndexName );
290
298
assertTrue (client .admin ().indices ().prepareDelete (restoredIndexName ).get ().isAcknowledged ());
@@ -334,6 +342,7 @@ private void createIndexWithDocsAndEnsureGreen(int numReplicasIndex, int numOfDo
334
342
Settings .builder ()
335
343
.put (IndexMetadata .SETTING_NUMBER_OF_REPLICAS , Integer .toString (numReplicasIndex ))
336
344
.put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , "1" )
345
+ .put (IndexModule .INDEX_STORE_TYPE_SETTING .getKey (), IndexModule .Type .FS .getSettingsKey ())
337
346
.build ()
338
347
);
339
348
ensureGreen ();
@@ -386,6 +395,20 @@ private void restoreSnapshotAndEnsureGreen(Client client, String snapshotName, S
386
395
ensureGreen ();
387
396
}
388
397
398
+ private void assertRemoteSnapshotIndexSettings (Client client , String ... snapshotIndexNames ) {
399
+ GetSettingsResponse settingsResponse = client .admin ()
400
+ .indices ()
401
+ .getSettings (new GetSettingsRequest ().indices (snapshotIndexNames ))
402
+ .actionGet ();
403
+ assertEquals (snapshotIndexNames .length , settingsResponse .getIndexToSettings ().keys ().size ());
404
+ for (String snapshotIndexName : snapshotIndexNames ) {
405
+ assertEquals (
406
+ IndexModule .Type .REMOTE_SNAPSHOT .getSettingsKey (),
407
+ settingsResponse .getSetting (snapshotIndexName , IndexModule .INDEX_STORE_TYPE_SETTING .getKey ())
408
+ );
409
+ }
410
+ }
411
+
389
412
private void assertIndexingBlocked (String index ) {
390
413
try {
391
414
final IndexRequestBuilder builder = client ().prepareIndex (index );
@@ -411,6 +434,7 @@ public void testUpdateIndexSettings() throws InterruptedException {
411
434
412
435
internalCluster ().ensureAtLeastNumSearchNodes (1 );
413
436
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
437
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName );
414
438
415
439
testUpdateIndexSettingsOnlyNotAllowedSettings (restoredIndexName );
416
440
testUpdateIndexSettingsOnlyAllowedSettings (restoredIndexName );
@@ -491,6 +515,8 @@ public void testFileCacheRestore() throws Exception {
491
515
492
516
internalCluster ().ensureAtLeastNumSearchNodes (numReplicasIndex + 1 );
493
517
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
518
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName );
519
+
494
520
assertDocCount (restoredIndexName , 100L );
495
521
assertIndexDirectoryDoesNotExist (restoredIndexName );
496
522
@@ -598,6 +624,7 @@ public void testPruneFileCacheOnIndexDeletion() throws Exception {
598
624
deleteIndicesAndEnsureGreen (client , indexName1 );
599
625
600
626
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
627
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName1 );
601
628
assertNodesFileCacheNonEmpty (numNodes );
602
629
603
630
deleteIndicesAndEnsureGreen (client , restoredIndexName1 );
@@ -623,6 +650,7 @@ public void testCacheIndexFilesClearedOnDelete() throws Exception {
623
650
takeSnapshot (client , snapshotName , repoName , indexName );
624
651
restoreSnapshotAndEnsureGreen (client , snapshotName , repoName );
625
652
assertDocCount (restoredIndexName , 100L );
653
+ assertRemoteSnapshotIndexSettings (client , restoredIndexName );
626
654
627
655
// The index count will be 1 since there is only a single restored index "test-idx-copy"
628
656
assertCacheDirectoryReplicaAndIndexCount (numShards , 1 );
0 commit comments