2828import org .elasticsearch .xpack .core .ilm .LifecycleAction ;
2929import org .elasticsearch .xpack .core .ilm .LifecyclePolicy ;
3030import org .elasticsearch .xpack .core .ilm .LifecycleSettings ;
31- import org .elasticsearch .xpack .core .ilm .MigrateAction ;
3231import org .elasticsearch .xpack .core .ilm .Phase ;
3332import org .elasticsearch .xpack .core .ilm .PhaseCompleteStep ;
3433import org .elasticsearch .xpack .core .ilm .RolloverAction ;
4039
4140import java .io .IOException ;
4241import java .io .InputStream ;
43- import java .time .ZonedDateTime ;
4442import java .util .HashMap ;
4543import java .util .List ;
4644import java .util .Locale ;
@@ -154,8 +152,8 @@ public void testSearchableSnapshotForceMergesIndexToOneSegment() throws Exceptio
154152 TimeUnit .SECONDS );
155153 }
156154
157- @ SuppressWarnings ("unchecked" )
158- public void testDeleteActionDeletesSearchableSnapshot () throws Exception {
155+ @ SuppressWarnings ("unchecked" )
156+ public void testDeleteActionDeletesSearchableSnapshot () throws Exception {
159157 createSnapshotRepo (client (), snapshotRepo , randomBoolean ());
160158
161159 // create policy with cold and delete phases
@@ -191,20 +189,20 @@ public void testDeleteActionDeletesSearchableSnapshot() throws Exception {
191189 assertBusy (() -> assertFalse (indexExists (restoredIndexName )), 60 , TimeUnit .SECONDS );
192190
193191 assertTrue ("the snapshot we generate in the cold phase should be deleted by the delete phase" , waitUntil (() -> {
194- try {
195- Request getSnapshotsRequest = new Request ("GET" , "_snapshot/" + snapshotRepo + "/_all" );
196- Response getSnapshotsResponse = client ().performRequest (getSnapshotsRequest );
197-
198- Map <String , Object > responseMap ;
199- try (InputStream is = getSnapshotsResponse .getEntity ().getContent ()) {
200- responseMap = XContentHelper .convertToMap (XContentType .JSON .xContent (), is , true );
201- }
202- List <Map <String , Object >> snapshots = (List <Map <String , Object >>) responseMap .get ("snapshots" );
203- return snapshots .size () == 0 ;
204- } catch (Exception e ) {
205- logger .error (e .getMessage (), e );
206- return false ;
207- }
192+ try {
193+ Request getSnapshotsRequest = new Request ("GET" , "_snapshot/" + snapshotRepo + "/_all" );
194+ Response getSnapshotsResponse = client ().performRequest (getSnapshotsRequest );
195+
196+ Map <String , Object > responseMap ;
197+ try (InputStream is = getSnapshotsResponse .getEntity ().getContent ()) {
198+ responseMap = XContentHelper .convertToMap (XContentType .JSON .xContent (), is , true );
199+ }
200+ List <Map <String , Object >> snapshots = (List <Map <String , Object >>) responseMap .get ("snapshots" );
201+ return snapshots .size () == 0 ;
202+ } catch (Exception e ) {
203+ logger .error (e .getMessage (), e );
204+ return false ;
205+ }
208206 }, 30 , TimeUnit .SECONDS ));
209207 }
210208
@@ -473,21 +471,15 @@ public void testSecondSearchableSnapshotUsingDifferentRepoThrows() throws Except
473471 containsString ("policy specifies [searchable_snapshot] action multiple times with differing repositories" ));
474472 }
475473
476- public void testSearchableSnapshotActionOverridesMigrateAction () throws Exception {
474+ public void testSearchableSnapshotsInHotPhasePinnedToHotNodes () throws Exception {
477475 createSnapshotRepo (client (), snapshotRepo , randomBoolean ());
478476 createPolicy (client (), policy ,
479477 new Phase ("hot" , TimeValue .ZERO , org .elasticsearch .common .collect .Map .of (RolloverAction .NAME ,
480478 new RolloverAction (null , null , null , 1L ),
481479 SearchableSnapshotAction .NAME , new SearchableSnapshotAction (
482480 snapshotRepo , randomBoolean ()))
483481 ),
484- new Phase ("warm" , TimeValue .ZERO , org .elasticsearch .common .collect .Map .of (MigrateAction .NAME , new MigrateAction (true ))),
485- // this time transition condition will make sure we catch ILM in the warm phase so we can assert the warm migrate action
486- // didn't re-configure the tier allocation settings set by the searchable_snapshot action in the hot phase
487- // we'll use the origination date to kick off ILM to complete the policy
488- new Phase ("cold" , TimeValue .timeValueDays (5L ),
489- org .elasticsearch .common .collect .Map .of (MigrateAction .NAME , new MigrateAction (true ))),
490- null , null
482+ null , null , null , null
491483 );
492484
493485 createComposableTemplate (client (), randomAlphaOfLengthBetween (5 , 10 ).toLowerCase (), dataStream ,
@@ -510,25 +502,12 @@ snapshotRepo, randomBoolean()))
510502 logger .info ("--> waiting for [{}] to exist..." , restoredIndex );
511503 assertTrue (indexExists (restoredIndex ));
512504 }, 30 , TimeUnit .SECONDS );
513- assertBusy (() -> assertThat (getStepKeyForIndex (client (), restoredIndex ), is (PhaseCompleteStep .finalStep ("warm " ).getKey ())),
505+ assertBusy (() -> assertThat (getStepKeyForIndex (client (), restoredIndex ), is (PhaseCompleteStep .finalStep ("hot " ).getKey ())),
514506 30 , TimeUnit .SECONDS );
515507
516- Map <String , Object > warmIndexSettings = getIndexSettingsAsMap (restoredIndex );
517- // the warm phase shouldn't have changed the data_cold -> data_hot configuration
518- assertThat (warmIndexSettings .get (DataTierAllocationDecider .INDEX_ROUTING_PREFER ),
519- is ("data_cold,data_warm,data_hot" ));
520-
521- // make the index 100 days old so the cold phase transition timing passes
522- updateIndexSettings (restoredIndex , Settings .builder ().put (LifecycleSettings .LIFECYCLE_ORIGINATION_DATE ,
523- ZonedDateTime .now ().toInstant ().toEpochMilli () - TimeValue .timeValueDays (100 ).getMillis ()));
524-
525- // let's wait for ILM to finish
526- assertBusy (() -> assertThat (getStepKeyForIndex (client (), restoredIndex ), is (PhaseCompleteStep .finalStep ("cold" ).getKey ())));
527-
528- Map <String , Object > coldIndexSettings = getIndexSettingsAsMap (restoredIndex );
529- // the frozen phase should've reconfigured the allocation preference
530- assertThat (coldIndexSettings .get (DataTierAllocationDecider .INDEX_ROUTING_PREFER ),
531- is ("data_cold,data_warm,data_hot" ));
508+ Map <String , Object > hotIndexSettings = getIndexSettingsAsMap (restoredIndex );
509+ // searchable snapshots mounted in the hot phase should be pinned to hot nodes
510+ assertThat (hotIndexSettings .get (DataTierAllocationDecider .INDEX_ROUTING_PREFER ),
511+ is ("data_hot" ));
532512 }
533-
534513}
0 commit comments