MINOR; Add `--standalone --ignore-formatted` formatter test (#19643)
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:
Kevin Wu 2025-05-07 09:41:18 -05:00 committed by GitHub
parent f3a4a1b185
commit 6cb6aa2030
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 0 deletions

View File

@ -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 @Test
public void testOneDirectoryFormattedAndOthersNotFormatted() throws Exception { public void testOneDirectoryFormattedAndOthersNotFormatted() throws Exception {
try (TestEnv testEnv = new TestEnv(2)) { try (TestEnv testEnv = new TestEnv(2)) {