@@ -214,62 +214,6 @@ public void testBlobStoreCache() throws Exception {
214214 );
215215 }
216216
217- logger .info ("--> verifying number of documents in index [{}]" , restoredIndex );
218- assertHitCount (client ().prepareSearch (restoredIndex ).setSize (0 ).setTrackTotalHits (true ).get (), numberOfDocs );
219- assertAcked (client ().admin ().indices ().prepareDelete (restoredIndex ));
220-
221- assertBusy (() -> {
222- refreshSystemIndex ();
223- assertThat (
224- systemClient ().prepareSearch (SNAPSHOT_BLOB_CACHE_INDEX ).setSize (0 ).get ().getHits ().getTotalHits ().value ,
225- greaterThan (0L )
226- );
227- });
228-
229- logger .info ("--> mount snapshot [{}] as an index for the second time [storage={}]" , snapshot , storage );
230- final String restoredIndexSecondTime = randomBoolean () ? indexName : randomAlphaOfLength (10 ).toLowerCase (Locale .ROOT );
231- mountSnapshot (
232- repositoryName ,
233- snapshot .getName (),
234- indexName ,
235- restoredIndexSecondTime ,
236- Settings .builder ()
237- .put (SearchableSnapshots .SNAPSHOT_CACHE_ENABLED_SETTING .getKey (), true )
238- .put (SearchableSnapshots .SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING .getKey (), false )
239- .put (SearchableSnapshots .SNAPSHOT_BLOB_CACHE_METADATA_FILES_MAX_LENGTH , blobCacheMaxLength )
240- .build (),
241- storage
242- );
243- ensureGreen (restoredIndexSecondTime );
244-
245- // wait for all async cache fills to complete
246- assertBusy (() -> {
247- for (final SearchableSnapshotShardStats shardStats : client ().execute (
248- SearchableSnapshotsStatsAction .INSTANCE ,
249- new SearchableSnapshotsStatsRequest ()
250- ).actionGet ().getStats ()) {
251- for (final SearchableSnapshotShardStats .CacheIndexInputStats indexInputStats : shardStats .getStats ()) {
252- assertThat (Strings .toString (indexInputStats ), indexInputStats .getCurrentIndexCacheFills (), equalTo (0L ));
253- }
254- }
255- });
256-
257- logger .info ("--> verifying cached documents in system index [{}]" , SNAPSHOT_BLOB_CACHE_INDEX );
258- if (numberOfDocs > 0 ) {
259- ensureYellow (SNAPSHOT_BLOB_CACHE_INDEX );
260- refreshSystemIndex ();
261-
262- logger .info ("--> verifying system index [{}] data tiers preference" , SNAPSHOT_BLOB_CACHE_INDEX );
263- assertThat (
264- systemClient ().admin ()
265- .indices ()
266- .prepareGetSettings (SNAPSHOT_BLOB_CACHE_INDEX )
267- .get ()
268- .getSetting (SNAPSHOT_BLOB_CACHE_INDEX , DataTierAllocationDecider .INDEX_ROUTING_PREFER ),
269- equalTo (DATA_TIERS_CACHE_INDEX_PREFERENCE )
270- );
271- }
272-
273217 final long numberOfCachedBlobs = systemClient ().prepareSearch (SNAPSHOT_BLOB_CACHE_INDEX )
274218 .setIndicesOptions (IndicesOptions .LENIENT_EXPAND_OPEN )
275219 .get ()
@@ -286,25 +230,35 @@ public void testBlobStoreCache() throws Exception {
286230 .getIndexing ();
287231 final long numberOfCacheWrites = indexingStats != null ? indexingStats .getTotal ().getIndexCount () : 0L ;
288232
289- assertAcked (client ().admin ().indices ().prepareDelete (restoredIndexSecondTime ));
233+ logger .info ("--> verifying number of documents in index [{}]" , restoredIndex );
234+ assertHitCount (client ().prepareSearch (restoredIndex ).setSize (0 ).setTrackTotalHits (true ).get (), numberOfDocs );
235+ assertAcked (client ().admin ().indices ().prepareDelete (restoredIndex ));
236+
237+ assertBusy (() -> {
238+ refreshSystemIndex ();
239+ assertThat (
240+ systemClient ().prepareSearch (SNAPSHOT_BLOB_CACHE_INDEX ).setSize (0 ).get ().getHits ().getTotalHits ().value ,
241+ greaterThan (0L )
242+ );
243+ });
290244
291- logger .info ("--> mount snapshot [{}] as an index for the third time [storage={}]" , snapshot , storage );
292- final String restoredIndexThirdTime = randomAlphaOfLength (10 ).toLowerCase (Locale .ROOT );
245+ logger .info ("--> mount snapshot [{}] as an index for the second time [storage={}]" , snapshot , storage );
246+ final String restoredAgainIndex = randomBoolean () ? indexName : randomAlphaOfLength (10 ).toLowerCase (Locale .ROOT );
293247 mountSnapshot (
294248 repositoryName ,
295249 snapshot .getName (),
296250 indexName ,
297- restoredIndexThirdTime ,
251+ restoredAgainIndex ,
298252 Settings .builder ()
299253 .put (SearchableSnapshots .SNAPSHOT_CACHE_ENABLED_SETTING .getKey (), true )
300254 .put (SearchableSnapshots .SNAPSHOT_CACHE_PREWARM_ENABLED_SETTING .getKey (), false )
301255 .put (SearchableSnapshots .SNAPSHOT_BLOB_CACHE_METADATA_FILES_MAX_LENGTH , blobCacheMaxLength )
302256 .build (),
303257 storage
304258 );
305- ensureGreen (restoredIndexThirdTime );
259+ ensureGreen (restoredAgainIndex );
306260
307- logger .info ("--> verifying shards of [{}] were started without using the blob store more than necessary" , restoredIndexThirdTime );
261+ logger .info ("--> verifying shards of [{}] were started without using the blob store more than necessary" , restoredAgainIndex );
308262 for (final SearchableSnapshotShardStats shardStats : client ().execute (
309263 SearchableSnapshotsStatsAction .INSTANCE ,
310264 new SearchableSnapshotsStatsRequest ()
@@ -314,14 +268,13 @@ public void testBlobStoreCache() throws Exception {
314268 }
315269 }
316270
317- logger .info ("--> verifying number of documents in index [{}]" , restoredIndexThirdTime );
318- assertHitCount (client ().prepareSearch (restoredIndexThirdTime ).setSize (0 ).setTrackTotalHits (true ).get (), numberOfDocs );
271+ logger .info ("--> verifying number of documents in index [{}]" , restoredAgainIndex );
272+ assertHitCount (client ().prepareSearch (restoredAgainIndex ).setSize (0 ).setTrackTotalHits (true ).get (), numberOfDocs );
319273
320274 logger .info ("--> verifying that no extra cached blobs were indexed [{}]" , SNAPSHOT_BLOB_CACHE_INDEX );
321275 if (numberOfDocs > 0 ) {
322276 refreshSystemIndex ();
323277 }
324-
325278 assertHitCount (
326279 systemClient ().prepareSearch (SNAPSHOT_BLOB_CACHE_INDEX ).setIndicesOptions (IndicesOptions .LENIENT_EXPAND_OPEN ).setSize (0 ).get (),
327280 numberOfCachedBlobs
@@ -347,9 +300,9 @@ public Settings onNodeStopped(String nodeName) throws Exception {
347300 .build ();
348301 }
349302 });
350- ensureGreen (restoredIndexThirdTime );
303+ ensureGreen (restoredAgainIndex );
351304
352- logger .info ("--> shards of [{}] should start without downloading bytes from the blob store" , restoredIndexThirdTime );
305+ logger .info ("--> shards of [{}] should start without downloading bytes from the blob store" , restoredAgainIndex );
353306 for (final SearchableSnapshotShardStats shardStats : client ().execute (
354307 SearchableSnapshotsStatsAction .INSTANCE ,
355308 new SearchableSnapshotsStatsRequest ()
@@ -375,8 +328,8 @@ public Settings onNodeStopped(String nodeName) throws Exception {
375328 .getIndexing ();
376329 assertThat (indexingStats != null ? indexingStats .getTotal ().getIndexCount () : 0L , equalTo (0L ));
377330
378- logger .info ("--> verifying number of documents in index [{}]" , restoredIndexThirdTime );
379- assertHitCount (client ().prepareSearch (restoredIndexThirdTime ).setSize (0 ).setTrackTotalHits (true ).get (), numberOfDocs );
331+ logger .info ("--> verifying number of documents in index [{}]" , restoredAgainIndex );
332+ assertHitCount (client ().prepareSearch (restoredAgainIndex ).setSize (0 ).setTrackTotalHits (true ).get (), numberOfDocs );
380333
381334 // TODO also test when the index is frozen
382335 // TODO also test when prewarming is enabled
0 commit comments