@@ -948,7 +948,8 @@ public void testMigrateToDataTiersRouting() {
948
948
"catch-all" ,
949
949
REGISTRY ,
950
950
client ,
951
- null
951
+ null ,
952
+ false
952
953
);
953
954
954
955
MigratedEntities migratedEntities = migratedEntitiesTuple .v2 ();
@@ -972,7 +973,8 @@ public void testMigrateToDataTiersRouting() {
972
973
null ,
973
974
REGISTRY ,
974
975
client ,
975
- null
976
+ null ,
977
+ false
976
978
);
977
979
978
980
MigratedEntities migratedEntities = migratedEntitiesTuple .v2 ();
@@ -996,7 +998,8 @@ public void testMigrateToDataTiersRouting() {
996
998
null ,
997
999
REGISTRY ,
998
1000
client ,
999
- null
1001
+ null ,
1002
+ false
1000
1003
);
1001
1004
1002
1005
MigratedEntities migratedEntities = migratedEntitiesTuple .v2 ();
@@ -1022,7 +1025,7 @@ public void testMigrateToDataTiersRoutingRequiresILMStopped() {
1022
1025
.build ();
1023
1026
IllegalStateException illegalStateException = expectThrows (
1024
1027
IllegalStateException .class ,
1025
- () -> migrateToDataTiersRouting (ilmRunningState , "data" , "catch-all" , REGISTRY , client , null )
1028
+ () -> migrateToDataTiersRouting (ilmRunningState , "data" , "catch-all" , REGISTRY , client , null , false )
1026
1029
);
1027
1030
assertThat (illegalStateException .getMessage (), is ("stop ILM before migrating to data tiers, current state is [RUNNING]" ));
1028
1031
}
@@ -1035,7 +1038,7 @@ public void testMigrateToDataTiersRoutingRequiresILMStopped() {
1035
1038
.build ();
1036
1039
IllegalStateException illegalStateException = expectThrows (
1037
1040
IllegalStateException .class ,
1038
- () -> migrateToDataTiersRouting (ilmStoppingState , "data" , "catch-all" , REGISTRY , client , null )
1041
+ () -> migrateToDataTiersRouting (ilmStoppingState , "data" , "catch-all" , REGISTRY , client , null , false )
1039
1042
);
1040
1043
assertThat (illegalStateException .getMessage (), is ("stop ILM before migrating to data tiers, current state is [STOPPING]" ));
1041
1044
}
@@ -1052,14 +1055,37 @@ public void testMigrateToDataTiersRoutingRequiresILMStopped() {
1052
1055
"catch-all" ,
1053
1056
REGISTRY ,
1054
1057
client ,
1055
- null
1058
+ null ,
1059
+ false
1056
1060
);
1057
1061
assertThat (migratedState .v2 ().migratedIndices , empty ());
1058
1062
assertThat (migratedState .v2 ().migratedPolicies , empty ());
1059
1063
assertThat (migratedState .v2 ().removedIndexTemplateName , nullValue ());
1060
1064
}
1061
1065
}
1062
1066
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
+
1063
1089
public void testMigrationDoesNotRemoveComposableTemplates () {
1064
1090
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate .Builder ().indexPatterns (
1065
1091
Collections .singletonList ("*" )
@@ -1075,7 +1101,8 @@ public void testMigrationDoesNotRemoveComposableTemplates() {
1075
1101
composableTemplateName ,
1076
1102
REGISTRY ,
1077
1103
client ,
1078
- null
1104
+ null ,
1105
+ false
1079
1106
);
1080
1107
assertThat (migratedEntitiesTuple .v2 ().removedIndexTemplateName , nullValue ());
1081
1108
assertThat (migratedEntitiesTuple .v1 ().metadata ().templatesV2 ().get (composableTemplateName ), is (composableIndexTemplate ));
@@ -1088,7 +1115,7 @@ public void testMigrationSetsEnforceTierPreferenceToTrue() {
1088
1115
1089
1116
// if the cluster state doesn't mention the setting, it ends up true
1090
1117
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 );
1092
1119
assertTrue (DataTier .ENFORCE_DEFAULT_TIER_PREFERENCE_SETTING .get (migratedEntitiesTuple .v1 ().metadata ().persistentSettings ()));
1093
1120
assertFalse (migratedEntitiesTuple .v1 ().metadata ().transientSettings ().keySet ().contains (DataTier .ENFORCE_DEFAULT_TIER_PREFERENCE ));
1094
1121
@@ -1098,7 +1125,7 @@ public void testMigrationSetsEnforceTierPreferenceToTrue() {
1098
1125
metadata .persistentSettings (Settings .builder ().put (ENFORCE_DEFAULT_TIER_PREFERENCE , randomBoolean ()).build ());
1099
1126
metadata .transientSettings (Settings .builder ().put (ENFORCE_DEFAULT_TIER_PREFERENCE , randomBoolean ()).build ());
1100
1127
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 );
1102
1129
assertTrue (DataTier .ENFORCE_DEFAULT_TIER_PREFERENCE_SETTING .get (migratedEntitiesTuple .v1 ().metadata ().persistentSettings ()));
1103
1130
assertFalse (migratedEntitiesTuple .v1 ().metadata ().transientSettings ().keySet ().contains (DataTier .ENFORCE_DEFAULT_TIER_PREFERENCE ));
1104
1131
}
0 commit comments