@@ -89,7 +89,7 @@ FormatterContext newFormatter() {
89
89
Formatter formatter = new Formatter ().
90
90
setNodeId (DEFAULT_NODE_ID ).
91
91
setClusterId (DEFAULT_CLUSTER_ID .toString ());
92
- directories .forEach (d -> formatter . addDirectory ( d ) );
92
+ directories .forEach (formatter :: addDirectory );
93
93
formatter .setMetadataLogDirectory (directories .get (0 ));
94
94
return new FormatterContext (formatter );
95
95
}
@@ -170,7 +170,7 @@ public void testFormatterFailsOnUnwritableDirectory() throws Exception {
170
170
String expectedPrefix = "Error while writing meta.properties file" ;
171
171
assertEquals (expectedPrefix ,
172
172
assertThrows (FormatterException .class ,
173
- () -> formatter1 .formatter . run () ).
173
+ formatter1 .formatter :: run ).
174
174
getMessage ().substring (0 , expectedPrefix .length ()));
175
175
}
176
176
}
@@ -180,15 +180,15 @@ public void testIgnoreFormatted() throws Exception {
180
180
try (TestEnv testEnv = new TestEnv (1 )) {
181
181
FormatterContext formatter1 = testEnv .newFormatter ();
182
182
formatter1 .formatter .run ();
183
- assertEquals ("Formatting metadata directory " + testEnv .directory (0 ) +
184
- " with metadata.version " + MetadataVersion .latestProduction () + "." ,
185
- formatter1 .output ().trim ());
183
+ assertEquals ("Bootstrap metadata: " + formatter1 .formatter .bootstrapMetadata () +
184
+ "\n Formatting metadata directory " + testEnv .directory (0 ) +
185
+ " with metadata.version " + MetadataVersion .latestProduction () + "." ,
186
+ formatter1 .output ().trim ());
186
187
187
188
FormatterContext formatter2 = testEnv .newFormatter ();
188
189
formatter2 .formatter .setIgnoreFormatted (true );
189
190
formatter2 .formatter .run ();
190
- assertEquals ("All of the log directories are already formatted." ,
191
- formatter2 .output ().trim ());
191
+ assertTrue (formatter2 .output ().trim ().contains ("All of the log directories are already formatted." ));
192
192
}
193
193
}
194
194
@@ -201,7 +201,8 @@ public void testStandaloneWithIgnoreFormatted() throws Exception {
201
201
formatter1 .formatter
202
202
.setInitialControllers (DynamicVoters .parse ("1@localhost:8020:" + originalDirectoryId ))
203
203
.run ();
204
- assertEquals ("Formatting dynamic metadata voter directory " + testEnv .directory (0 ) +
204
+ assertEquals ("Bootstrap metadata: " + formatter1 .formatter .bootstrapMetadata () +
205
+ "\n Formatting dynamic metadata voter directory " + testEnv .directory (0 ) +
205
206
" with metadata.version " + MetadataVersion .latestProduction () + "." ,
206
207
formatter1 .output ().trim ());
207
208
assertMetadataDirectoryId (testEnv , Uuid .fromString (originalDirectoryId ));
@@ -244,9 +245,10 @@ public void testOneDirectoryFormattedAndOthersNotFormattedWithIgnoreFormatted()
244
245
FormatterContext formatter2 = testEnv .newFormatter ();
245
246
formatter2 .formatter .setIgnoreFormatted (true );
246
247
formatter2 .formatter .run ();
247
- assertEquals ("Formatting data directory " + testEnv .directory (1 ) + " with metadata.version " +
248
- MetadataVersion .latestProduction () + "." ,
249
- formatter2 .output ().trim ());
248
+ assertEquals ("Bootstrap metadata: " + formatter2 .formatter .bootstrapMetadata () +
249
+ "\n Formatting data directory " + testEnv .directory (1 ) + " with metadata.version " +
250
+ MetadataVersion .latestProduction () + "." ,
251
+ formatter2 .output ().trim ());
250
252
}
251
253
}
252
254
@@ -256,9 +258,10 @@ public void testFormatWithOlderReleaseVersion() throws Exception {
256
258
FormatterContext formatter1 = testEnv .newFormatter ();
257
259
formatter1 .formatter .setReleaseVersion (MetadataVersion .IBP_3_5_IV0 );
258
260
formatter1 .formatter .run ();
259
- assertEquals ("Formatting metadata directory " + testEnv .directory (0 ) +
260
- " with metadata.version " + MetadataVersion .IBP_3_5_IV0 + "." ,
261
- formatter1 .output ().trim ());
261
+ assertEquals ("Bootstrap metadata: " + formatter1 .formatter .bootstrapMetadata () +
262
+ "\n Formatting metadata directory " + testEnv .directory (0 ) +
263
+ " with metadata.version " + MetadataVersion .IBP_3_5_IV0 + "." ,
264
+ formatter1 .output ().trim ());
262
265
BootstrapMetadata bootstrapMetadata =
263
266
new BootstrapDirectory (testEnv .directory (0 )).read ();
264
267
assertEquals (MetadataVersion .IBP_3_5_IV0 , bootstrapMetadata .metadataVersion ());
@@ -272,7 +275,7 @@ public void testFormatWithUnstableReleaseVersionFailsWithoutEnableUnstable() thr
272
275
FormatterContext formatter1 = testEnv .newFormatter ();
273
276
formatter1 .formatter .setReleaseVersion (MetadataVersion .latestTesting ());
274
277
assertEquals ("metadata.version " + MetadataVersion .latestTesting () + " is not yet stable." ,
275
- assertThrows (FormatterException .class , () -> formatter1 .formatter . run () ).getMessage ());
278
+ assertThrows (FormatterException .class , formatter1 .formatter :: run ).getMessage ());
276
279
}
277
280
}
278
281
@@ -283,9 +286,10 @@ public void testFormatWithUnstableReleaseVersion() throws Exception {
283
286
formatter1 .formatter .setReleaseVersion (MetadataVersion .latestTesting ());
284
287
formatter1 .formatter .setUnstableFeatureVersionsEnabled (true );
285
288
formatter1 .formatter .run ();
286
- assertEquals ("Formatting metadata directory " + testEnv .directory (0 ) +
287
- " with metadata.version " + MetadataVersion .latestTesting () + "." ,
288
- formatter1 .output ().trim ());
289
+ assertEquals ("Bootstrap metadata: " + formatter1 .formatter .bootstrapMetadata () +
290
+ "\n Formatting metadata directory " + testEnv .directory (0 ) +
291
+ " with metadata.version " + MetadataVersion .latestTesting () + "." ,
292
+ formatter1 .output ().trim ());
289
293
BootstrapMetadata bootstrapMetadata =
290
294
new BootstrapDirectory (testEnv .directory (0 )).read ();
291
295
assertEquals (MetadataVersion .latestTesting (), bootstrapMetadata .metadataVersion ());
@@ -318,7 +322,7 @@ public void testFormatWithScramFailsOnUnsupportedReleaseVersions() throws Except
318
322
"saltedpassword=\" mT0yyUUxnlJaC99HXgRTSYlbuqa4FSGtJCJfTMvjYCE=\" ]" ));
319
323
assertEquals ("SCRAM is only supported in metadata.version 3.5-IV2 or later." ,
320
324
assertThrows (FormatterException .class ,
321
- () -> formatter1 .formatter . run () ).getMessage ());
325
+ formatter1 .formatter :: run ).getMessage ());
322
326
}
323
327
}
324
328
@@ -333,9 +337,10 @@ public void testFormatWithScram() throws Exception {
333
337
"SCRAM-SHA-512=[name=alice,salt=\" MWx2NHBkbnc0ZndxN25vdGN4bTB5eTFrN3E=\" ," +
334
338
"saltedpassword=\" mT0yyUUxnlJaC99HXgRTSYlbuqa4FSGtJCJfTMvjYCE=\" ]" ));
335
339
formatter1 .formatter .run ();
336
- assertEquals ("Formatting metadata directory " + testEnv .directory (0 ) +
337
- " with metadata.version " + MetadataVersion .IBP_3_8_IV0 + "." ,
338
- formatter1 .output ().trim ());
340
+ assertEquals ("Bootstrap metadata: " + formatter1 .formatter .bootstrapMetadata () +
341
+ "\n Formatting metadata directory " + testEnv .directory (0 ) +
342
+ " with metadata.version " + MetadataVersion .IBP_3_8_IV0 + "." ,
343
+ formatter1 .output ().trim ());
339
344
BootstrapMetadata bootstrapMetadata =
340
345
new BootstrapDirectory (testEnv .directory (0 )).read ();
341
346
assertEquals (MetadataVersion .IBP_3_8_IV0 , bootstrapMetadata .metadataVersion ());
@@ -406,7 +411,7 @@ public void testInvalidFeatureFlag() throws Exception {
406
411
"are: eligible.leader.replicas.version, group.version, kraft.version, " +
407
412
"share.version, streams.version, test.feature.version, transaction.version" ,
408
413
assertThrows (FormatterException .class ,
409
- () -> formatter1 .formatter . run () ).
414
+ formatter1 .formatter :: run ).
410
415
getMessage ());
411
416
}
412
417
}
@@ -425,6 +430,7 @@ public void testFormatWithInitialVoters(boolean specifyKRaftVersion) throws Exce
425
430
formatter1 .formatter .run ();
426
431
assertEquals ((short ) 1 , formatter1 .formatter .featureLevels .getOrDefault ("kraft.version" , (short ) 0 ));
427
432
assertEquals (List .of (
433
+ "Bootstrap metadata: " + formatter1 .formatter .bootstrapMetadata (),
428
434
String .format ("Formatting data directory %s with %s %s." ,
429
435
testEnv .directory (1 ),
430
436
MetadataVersion .FEATURE_NAME ,
@@ -459,7 +465,7 @@ public void testFormatWithInitialVotersFailsWithOlderKraftVersion() throws Excep
459
465
"Cannot set kraft.version to 0 if one of the flags --standalone, --initial-controllers, or " +
460
466
"--no-initial-controllers is used. For dynamic controllers support, try removing the " +
461
467
"--feature flag for kraft.version." ,
462
- assertThrows (FormatterException .class , () -> formatter1 .formatter . run () ).getMessage ()
468
+ assertThrows (FormatterException .class , formatter1 .formatter :: run ).getMessage ()
463
469
);
464
470
}
465
471
}
@@ -475,7 +481,7 @@ public void testFormatWithoutInitialVotersFailsWithNewerKraftVersion() throws Ex
475
481
"Cannot set kraft.version to 1 unless one of the flags --standalone, --initial-controllers, or " +
476
482
"--no-initial-controllers is used. For dynamic controllers support, try using one of " +
477
483
"--standalone, --initial-controllers, or --no-initial-controllers." ,
478
- assertThrows (FormatterException .class , () -> formatter1 .formatter . run () ).getMessage ()
484
+ assertThrows (FormatterException .class , formatter1 .formatter :: run ).getMessage ()
479
485
);
480
486
}
481
487
}
@@ -492,7 +498,7 @@ public void testFormatWithInitialVotersFailsWithOlderMetadataVersion() throws Ex
492
498
assertEquals ("kraft.version could not be set to 1 because it depends on " +
493
499
"metadata.version level 21" ,
494
500
assertThrows (IllegalArgumentException .class ,
495
- () -> formatter1 .formatter . run () ).getMessage ());
501
+ formatter1 .formatter :: run ).getMessage ());
496
502
}
497
503
}
498
504
@@ -514,12 +520,12 @@ public void testFormatElrEnabledWithMetadataVersions(MetadataVersion metadataVer
514
520
formatter1 .formatter .setInitialControllers (DynamicVoters .
515
521
parse ("1@localhost:8020:4znU-ou9Taa06bmEJxsjnw" ));
516
522
if (metadataVersion .isAtLeast (MetadataVersion .IBP_4_0_IV1 )) {
517
- assertDoesNotThrow (() -> formatter1 .formatter . run () );
523
+ assertDoesNotThrow (formatter1 .formatter :: run );
518
524
} else {
519
525
assertEquals ("eligible.leader.replicas.version could not be set to 1 because it depends on " +
520
526
"metadata.version level 23" ,
521
527
assertThrows (IllegalArgumentException .class ,
522
- () -> formatter1 .formatter . run () ).getMessage ());
528
+ formatter1 .formatter :: run ).getMessage ());
523
529
}
524
530
}
525
531
}
@@ -539,6 +545,7 @@ public void testFormatWithNoInitialControllers(boolean specifyKRaftVersion) thro
539
545
formatter1 .formatter .run ();
540
546
assertEquals ((short ) 1 , formatter1 .formatter .featureLevels .getOrDefault ("kraft.version" , (short ) 0 ));
541
547
assertEquals (List .of (
548
+ "Bootstrap metadata: " + formatter1 .formatter .bootstrapMetadata (),
542
549
String .format ("Formatting data directory %s with %s %s." ,
543
550
testEnv .directory (1 ),
544
551
MetadataVersion .FEATURE_NAME ,
0 commit comments