@@ -235,15 +235,30 @@ public static void corruptFile(Path fileToCorrupt, Logger logger) throws IOExcep
235
235
}
236
236
}
237
237
238
- public void testLoadState () throws IOException {
238
+ public void testLoadStateWithoutMissingCustoms () throws IOException {
239
+ runLoadStateTest (false , false );
240
+ }
241
+
242
+ public void testLoadStateWithoutMissingCustomsButPreserved () throws IOException {
243
+ runLoadStateTest (false , true );
244
+ }
245
+
246
+ public void testLoadStateWithMissingCustomsButPreserved () throws IOException {
247
+ runLoadStateTest (true , true );
248
+ }
249
+
250
+ public void testLoadStateWithMissingCustomsAndNotPreserved () throws IOException {
251
+ runLoadStateTest (true , false );
252
+ }
253
+
254
+ private void runLoadStateTest (boolean hasMissingCustoms , boolean preserveUnknownCustoms ) throws IOException {
239
255
final Path [] dirs = new Path [randomIntBetween (1 , 5 )];
240
256
int numStates = randomIntBetween (1 , 5 );
241
257
List <MetaData > meta = new ArrayList <>();
242
258
for (int i = 0 ; i < numStates ; i ++) {
243
259
meta .add (randomMeta ());
244
260
}
245
261
Set <Path > corruptedFiles = new HashSet <>();
246
- final boolean preserveUnknownCustoms = randomBoolean ();
247
262
MetaDataStateFormat <MetaData > format = metaDataFormat (preserveUnknownCustoms );
248
263
for (int i = 0 ; i < dirs .length ; i ++) {
249
264
dirs [i ] = createTempDir ();
@@ -261,13 +276,12 @@ public void testLoadState() throws IOException {
261
276
}
262
277
List <Path > dirList = Arrays .asList (dirs );
263
278
Collections .shuffle (dirList , random ());
264
- final boolean hasMissingCustoms = randomBoolean ();
265
279
MetaData loadedMetaData = format .loadLatestState (logger , hasMissingCustoms ?
266
280
NamedXContentRegistry .EMPTY : xContentRegistry (), dirList .toArray (new Path [0 ]));
267
281
MetaData latestMetaData = meta .get (numStates -1 );
268
282
assertThat (loadedMetaData .clusterUUID (), not (equalTo ("_na_" )));
269
283
assertThat (loadedMetaData .clusterUUID (), equalTo (latestMetaData .clusterUUID ()));
270
- ImmutableOpenMap <String ,IndexMetaData > indices = loadedMetaData .indices ();
284
+ ImmutableOpenMap <String , IndexMetaData > indices = loadedMetaData .indices ();
271
285
assertThat (indices .size (), equalTo (latestMetaData .indices ().size ()));
272
286
for (IndexMetaData original : latestMetaData ) {
273
287
IndexMetaData deserialized = indices .get (original .getIndex ().getName ());
0 commit comments