28
28
import org .elasticsearch .xpack .core .ilm .LifecycleAction ;
29
29
import org .elasticsearch .xpack .core .ilm .LifecyclePolicy ;
30
30
import org .elasticsearch .xpack .core .ilm .LifecycleSettings ;
31
- import org .elasticsearch .xpack .core .ilm .MigrateAction ;
32
31
import org .elasticsearch .xpack .core .ilm .Phase ;
33
32
import org .elasticsearch .xpack .core .ilm .PhaseCompleteStep ;
34
33
import org .elasticsearch .xpack .core .ilm .RolloverAction ;
40
39
41
40
import java .io .IOException ;
42
41
import java .io .InputStream ;
43
- import java .time .ZonedDateTime ;
44
42
import java .util .HashMap ;
45
43
import java .util .List ;
46
44
import java .util .Locale ;
@@ -154,8 +152,8 @@ public void testSearchableSnapshotForceMergesIndexToOneSegment() throws Exceptio
154
152
TimeUnit .SECONDS );
155
153
}
156
154
157
- @ SuppressWarnings ("unchecked" )
158
- public void testDeleteActionDeletesSearchableSnapshot () throws Exception {
155
+ @ SuppressWarnings ("unchecked" )
156
+ public void testDeleteActionDeletesSearchableSnapshot () throws Exception {
159
157
createSnapshotRepo (client (), snapshotRepo , randomBoolean ());
160
158
161
159
// create policy with cold and delete phases
@@ -191,20 +189,20 @@ public void testDeleteActionDeletesSearchableSnapshot() throws Exception {
191
189
assertBusy (() -> assertFalse (indexExists (restoredIndexName )), 60 , TimeUnit .SECONDS );
192
190
193
191
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
+ }
208
206
}, 30 , TimeUnit .SECONDS ));
209
207
}
210
208
@@ -473,21 +471,15 @@ public void testSecondSearchableSnapshotUsingDifferentRepoThrows() throws Except
473
471
containsString ("policy specifies [searchable_snapshot] action multiple times with differing repositories" ));
474
472
}
475
473
476
- public void testSearchableSnapshotActionOverridesMigrateAction () throws Exception {
474
+ public void testSearchableSnapshotsInHotPhasePinnedToHotNodes () throws Exception {
477
475
createSnapshotRepo (client (), snapshotRepo , randomBoolean ());
478
476
createPolicy (client (), policy ,
479
477
new Phase ("hot" , TimeValue .ZERO , org .elasticsearch .common .collect .Map .of (RolloverAction .NAME ,
480
478
new RolloverAction (null , null , null , 1L ),
481
479
SearchableSnapshotAction .NAME , new SearchableSnapshotAction (
482
480
snapshotRepo , randomBoolean ()))
483
481
),
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
491
483
);
492
484
493
485
createComposableTemplate (client (), randomAlphaOfLengthBetween (5 , 10 ).toLowerCase (), dataStream ,
@@ -510,25 +502,12 @@ snapshotRepo, randomBoolean()))
510
502
logger .info ("--> waiting for [{}] to exist..." , restoredIndex );
511
503
assertTrue (indexExists (restoredIndex ));
512
504
}, 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 ())),
514
506
30 , TimeUnit .SECONDS );
515
507
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" ));
532
512
}
533
-
534
513
}
0 commit comments