mirror of https://github.com/apache/kafka.git
MINOR; Add `--standalone --ignore-formatted` formatter test (#19643)
CI / build (push) Waiting to run
Details
CI / build (push) Waiting to run
Details
This PR adds an additional test case to `FormatterTest` that checks that formatting with `--standalone` and then formatting again with `--standalone --ignore-formatted` is indeed a no-op. Reviewers: José Armando García Sancio <jsancio@apache.org>
This commit is contained in:
parent
f3a4a1b185
commit
6cb6aa2030
|
@ -192,6 +192,39 @@ public class FormatterTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStandaloneWithIgnoreFormatted() throws Exception {
|
||||
try (TestEnv testEnv = new TestEnv(1)) {
|
||||
FormatterContext formatter1 = testEnv.newFormatter();
|
||||
String originalDirectoryId = Uuid.randomUuid().toString();
|
||||
String newDirectoryId = Uuid.randomUuid().toString();
|
||||
formatter1.formatter
|
||||
.setInitialControllers(DynamicVoters.parse("1@localhost:8020:" + originalDirectoryId))
|
||||
.run();
|
||||
assertEquals("Formatting dynamic metadata voter directory " + testEnv.directory(0) +
|
||||
" with metadata.version " + MetadataVersion.latestProduction() + ".",
|
||||
formatter1.output().trim());
|
||||
assertMetadataDirectoryId(testEnv, Uuid.fromString(originalDirectoryId));
|
||||
|
||||
FormatterContext formatter2 = testEnv.newFormatter();
|
||||
formatter2.formatter
|
||||
.setIgnoreFormatted(true)
|
||||
.setInitialControllers(DynamicVoters.parse("1@localhost:8020:" + newDirectoryId))
|
||||
.run();
|
||||
assertEquals("All of the log directories are already formatted.",
|
||||
formatter2.output().trim());
|
||||
assertMetadataDirectoryId(testEnv, Uuid.fromString(originalDirectoryId));
|
||||
}
|
||||
}
|
||||
|
||||
private void assertMetadataDirectoryId(TestEnv testEnv, Uuid expectedDirectoryId) throws Exception {
|
||||
MetaPropertiesEnsemble ensemble = new MetaPropertiesEnsemble.Loader().
|
||||
addLogDirs(testEnv.directories).
|
||||
load();
|
||||
MetaProperties logDirProps0 = ensemble.logDirProps().get(testEnv.directory(0));
|
||||
assertEquals(expectedDirectoryId, logDirProps0.directoryId().get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneDirectoryFormattedAndOthersNotFormatted() throws Exception {
|
||||
try (TestEnv testEnv = new TestEnv(2)) {
|
||||
|
|
Loading…
Reference in New Issue