@@ -948,7 +948,8 @@ public void testMigrateToDataTiersRouting() {
948948 "catch-all" ,
949949 REGISTRY ,
950950 client ,
951- null
951+ null ,
952+ false
952953 );
953954
954955 MigratedEntities migratedEntities = migratedEntitiesTuple .v2 ();
@@ -972,7 +973,8 @@ public void testMigrateToDataTiersRouting() {
972973 null ,
973974 REGISTRY ,
974975 client ,
975- null
976+ null ,
977+ false
976978 );
977979
978980 MigratedEntities migratedEntities = migratedEntitiesTuple .v2 ();
@@ -996,7 +998,8 @@ public void testMigrateToDataTiersRouting() {
996998 null ,
997999 REGISTRY ,
9981000 client ,
999- null
1001+ null ,
1002+ false
10001003 );
10011004
10021005 MigratedEntities migratedEntities = migratedEntitiesTuple .v2 ();
@@ -1022,7 +1025,7 @@ public void testMigrateToDataTiersRoutingRequiresILMStopped() {
10221025 .build ();
10231026 IllegalStateException illegalStateException = expectThrows (
10241027 IllegalStateException .class ,
1025- () -> migrateToDataTiersRouting (ilmRunningState , "data" , "catch-all" , REGISTRY , client , null )
1028+ () -> migrateToDataTiersRouting (ilmRunningState , "data" , "catch-all" , REGISTRY , client , null , false )
10261029 );
10271030 assertThat (illegalStateException .getMessage (), is ("stop ILM before migrating to data tiers, current state is [RUNNING]" ));
10281031 }
@@ -1035,7 +1038,7 @@ public void testMigrateToDataTiersRoutingRequiresILMStopped() {
10351038 .build ();
10361039 IllegalStateException illegalStateException = expectThrows (
10371040 IllegalStateException .class ,
1038- () -> migrateToDataTiersRouting (ilmStoppingState , "data" , "catch-all" , REGISTRY , client , null )
1041+ () -> migrateToDataTiersRouting (ilmStoppingState , "data" , "catch-all" , REGISTRY , client , null , false )
10391042 );
10401043 assertThat (illegalStateException .getMessage (), is ("stop ILM before migrating to data tiers, current state is [STOPPING]" ));
10411044 }
@@ -1052,14 +1055,37 @@ public void testMigrateToDataTiersRoutingRequiresILMStopped() {
10521055 "catch-all" ,
10531056 REGISTRY ,
10541057 client ,
1055- null
1058+ null ,
1059+ false
10561060 );
10571061 assertThat (migratedState .v2 ().migratedIndices , empty ());
10581062 assertThat (migratedState .v2 ().migratedPolicies , empty ());
10591063 assertThat (migratedState .v2 ().removedIndexTemplateName , nullValue ());
10601064 }
10611065 }
10621066
1067+ public void testDryRunDoesntRequireILMStopped () {
1068+ {
1069+ ClusterState ilmRunningState = ClusterState .builder (ClusterName .DEFAULT )
1070+ .metadata (
1071+ Metadata .builder ().putCustom (IndexLifecycleMetadata .TYPE , new IndexLifecycleMetadata (Map .of (), OperationMode .RUNNING ))
1072+ )
1073+ .build ();
1074+ migrateToDataTiersRouting (ilmRunningState , "data" , "catch-all" , REGISTRY , client , null , true );
1075+ // no exceptions
1076+ }
1077+
1078+ {
1079+ ClusterState ilmStoppingState = ClusterState .builder (ClusterName .DEFAULT )
1080+ .metadata (
1081+ Metadata .builder ().putCustom (IndexLifecycleMetadata .TYPE , new IndexLifecycleMetadata (Map .of (), OperationMode .STOPPING ))
1082+ )
1083+ .build ();
1084+ migrateToDataTiersRouting (ilmStoppingState , "data" , "catch-all" , REGISTRY , client , null , true );
1085+ // no exceptions
1086+ }
1087+ }
1088+
10631089 public void testMigrationDoesNotRemoveComposableTemplates () {
10641090 ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate .Builder ().indexPatterns (
10651091 Collections .singletonList ("*" )
@@ -1075,7 +1101,8 @@ public void testMigrationDoesNotRemoveComposableTemplates() {
10751101 composableTemplateName ,
10761102 REGISTRY ,
10771103 client ,
1078- null
1104+ null ,
1105+ false
10791106 );
10801107 assertThat (migratedEntitiesTuple .v2 ().removedIndexTemplateName , nullValue ());
10811108 assertThat (migratedEntitiesTuple .v1 ().metadata ().templatesV2 ().get (composableTemplateName ), is (composableIndexTemplate ));
@@ -1088,7 +1115,7 @@ public void testMigrationSetsEnforceTierPreferenceToTrue() {
10881115
10891116 // if the cluster state doesn't mention the setting, it ends up true
10901117 clusterState = ClusterState .builder (ClusterName .DEFAULT ).build ();
1091- migratedEntitiesTuple = migrateToDataTiersRouting (clusterState , null , null , REGISTRY , client , null );
1118+ migratedEntitiesTuple = migrateToDataTiersRouting (clusterState , null , null , REGISTRY , client , null , false );
10921119 assertTrue (DataTier .ENFORCE_DEFAULT_TIER_PREFERENCE_SETTING .get (migratedEntitiesTuple .v1 ().metadata ().persistentSettings ()));
10931120 assertFalse (migratedEntitiesTuple .v1 ().metadata ().transientSettings ().keySet ().contains (DataTier .ENFORCE_DEFAULT_TIER_PREFERENCE ));
10941121
@@ -1098,7 +1125,7 @@ public void testMigrationSetsEnforceTierPreferenceToTrue() {
10981125 metadata .persistentSettings (Settings .builder ().put (ENFORCE_DEFAULT_TIER_PREFERENCE , randomBoolean ()).build ());
10991126 metadata .transientSettings (Settings .builder ().put (ENFORCE_DEFAULT_TIER_PREFERENCE , randomBoolean ()).build ());
11001127 clusterState = ClusterState .builder (ClusterName .DEFAULT ).metadata (metadata ).build ();
1101- migratedEntitiesTuple = migrateToDataTiersRouting (clusterState , null , null , REGISTRY , client , null );
1128+ migratedEntitiesTuple = migrateToDataTiersRouting (clusterState , null , null , REGISTRY , client , null , false );
11021129 assertTrue (DataTier .ENFORCE_DEFAULT_TIER_PREFERENCE_SETTING .get (migratedEntitiesTuple .v1 ().metadata ().persistentSettings ()));
11031130 assertFalse (migratedEntitiesTuple .v1 ().metadata ().transientSettings ().keySet ().contains (DataTier .ENFORCE_DEFAULT_TIER_PREFERENCE ));
11041131 }
0 commit comments