@@ -205,21 +205,75 @@ public void testValidateConflictingDataMigrationConfigurations() {
205205 }
206206
207207 public void testActionsThatCannotFollowSearchableSnapshot () {
208- assertThat (ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT .size (), is (5 ));
208+ assertThat (ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT .size (), is (4 ));
209209 assertThat (ACTIONS_CANNOT_FOLLOW_SEARCHABLE_SNAPSHOT , containsInAnyOrder (ShrinkAction .NAME , FreezeAction .NAME ,
210- ForceMergeAction .NAME , RollupILMAction .NAME , SearchableSnapshotAction . NAME ));
210+ ForceMergeAction .NAME , RollupILMAction .NAME ));
211211 }
212212
213213 public void testValidateActionsFollowingSearchableSnapshot () {
214- Phase hotPhase = new Phase ("hot" , TimeValue .ZERO , Map .of (SearchableSnapshotAction .NAME , new SearchableSnapshotAction ("repo" )));
215- Phase warmPhase = new Phase ("warm" , TimeValue .ZERO , Map .of (ShrinkAction .NAME , new ShrinkAction (1 , null )));
216- Phase coldPhase = new Phase ("cold" , TimeValue .ZERO , Map .of (FreezeAction .NAME , new FreezeAction ()));
217-
218- IllegalArgumentException e = expectThrows (IllegalArgumentException .class ,
219- () -> TimeseriesLifecycleType .validateActionsFollowingSearchableSnapshot (List .of (hotPhase , warmPhase , coldPhase )));
220- assertThat (e .getMessage (), is (
221- "phases [warm,cold] define one or more of [searchable_snapshot, forcemerge, freeze, shrink, rollup] actions" +
222- " which are not allowed after a managed index is mounted as a searchable snapshot" ));
214+ {
215+ Phase hotPhase = new Phase ("hot" , TimeValue .ZERO , Map .of (SearchableSnapshotAction .NAME , new SearchableSnapshotAction ("repo" )));
216+ Phase warmPhase = new Phase ("warm" , TimeValue .ZERO , Map .of (ShrinkAction .NAME , new ShrinkAction (1 , null )));
217+ Phase coldPhase = new Phase ("cold" , TimeValue .ZERO , Map .of (FreezeAction .NAME , new FreezeAction ()));
218+ IllegalArgumentException e = expectThrows (IllegalArgumentException .class ,
219+ () -> TimeseriesLifecycleType .validateActionsFollowingSearchableSnapshot (List .of (hotPhase , warmPhase , coldPhase )));
220+ assertThat (e .getMessage (), is (
221+ "phases [warm,cold] define one or more of [forcemerge, freeze, shrink, rollup] actions" +
222+ " which are not allowed after a managed index is mounted as a searchable snapshot" ));
223+ }
224+
225+ {
226+ Phase warmPhase = new Phase ("warm" , TimeValue .ZERO ,
227+ Map .of (ShrinkAction .NAME , new ShrinkAction (1 , null )));
228+ Phase coldPhase = new Phase ("cold" , TimeValue .ZERO ,
229+ Map .of (SearchableSnapshotAction .NAME , new SearchableSnapshotAction ("repo" )));
230+ Phase frozenPhase = new Phase ("frozen" , TimeValue .ZERO ,
231+ Map .of (FreezeAction .NAME , new FreezeAction ()));
232+ IllegalArgumentException e = expectThrows (IllegalArgumentException .class ,
233+ () -> TimeseriesLifecycleType .validateActionsFollowingSearchableSnapshot (List .of (warmPhase , coldPhase , frozenPhase )));
234+ assertThat (e .getMessage (), is (
235+ "phases [frozen] define one or more of [forcemerge, freeze, shrink, rollup] actions" +
236+ " which are not allowed after a managed index is mounted as a searchable snapshot" ));
237+ }
238+
239+ {
240+ Phase hotPhase = new Phase ("hot" , TimeValue .ZERO ,
241+ Map .of (SearchableSnapshotAction .NAME , new SearchableSnapshotAction ("repo" )));
242+ Phase warmPhase = new Phase ("warm" , TimeValue .ZERO ,
243+ Map .of (ShrinkAction .NAME , new ShrinkAction (1 , null )));
244+ Phase coldPhase = new Phase ("cold" , TimeValue .ZERO ,
245+ Map .of (SearchableSnapshotAction .NAME , new SearchableSnapshotAction ("repo" )));
246+ Phase frozenPhase = new Phase ("frozen" , TimeValue .ZERO ,
247+ Map .of (FreezeAction .NAME , new FreezeAction ()));
248+ IllegalArgumentException e = expectThrows (IllegalArgumentException .class ,
249+ () -> TimeseriesLifecycleType .validateActionsFollowingSearchableSnapshot (List .of (hotPhase , warmPhase , coldPhase ,
250+ frozenPhase )));
251+ assertThat (e .getMessage (), is (
252+ "phases [warm,frozen] define one or more of [forcemerge, freeze, shrink, rollup] actions" +
253+ " which are not allowed after a managed index is mounted as a searchable snapshot" ));
254+ }
255+
256+ {
257+ Phase hot = new Phase ("hot" , TimeValue .ZERO , Map .of (RolloverAction .NAME , new RolloverAction (null , null , 1L ),
258+ SearchableSnapshotAction .NAME , new SearchableSnapshotAction (randomAlphaOfLengthBetween (4 , 10 ))));
259+ Phase warm = new Phase ("warm" , TimeValue .ZERO , Map .of (ForceMergeAction .NAME , new ForceMergeAction (1 , null )));
260+ Phase cold = new Phase ("cold" , TimeValue .ZERO , Map .of (FreezeAction .NAME , new FreezeAction ()));
261+ IllegalArgumentException e = expectThrows (IllegalArgumentException .class ,
262+ () -> TimeseriesLifecycleType .validateActionsFollowingSearchableSnapshot (List .of (warm , hot , cold )));
263+ assertThat (e .getMessage (), is (
264+ "phases [warm,cold] define one or more of [forcemerge, freeze, shrink, rollup] actions" +
265+ " which are not allowed after a managed index is mounted as a searchable snapshot" ));
266+ }
267+
268+ {
269+ Phase frozenPhase = new Phase ("frozen" , TimeValue .ZERO , Map .of (FreezeAction .NAME , new FreezeAction (),
270+ SearchableSnapshotAction .NAME , new SearchableSnapshotAction ("repo" )));
271+ try {
272+ TimeseriesLifecycleType .validateActionsFollowingSearchableSnapshot (List .of (frozenPhase ));
273+ } catch (Exception e ) {
274+ fail ("unexpected exception while validating phase [ " + frozenPhase +" ] but got [" + e .getMessage ()+ "]" );
275+ }
276+ }
223277 }
224278
225279 public void testGetOrderedPhases () {
0 commit comments