This is an automated email from the ASF dual-hosted git repository.

jsancio pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 6cb6aa2030f MINOR; Add `--standalone --ignore-formatted` formatter 
test (#19643)
6cb6aa2030f is described below

commit 6cb6aa2030f67f7b20c8df55e1347c74d14d5a75
Author: Kevin Wu <[email protected]>
AuthorDate: Wed May 7 09:41:18 2025 -0500

    MINOR; Add `--standalone --ignore-formatted` formatter test (#19643)
    
    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 <[email protected]>
---
 .../kafka/metadata/storage/FormatterTest.java      | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git 
a/metadata/src/test/java/org/apache/kafka/metadata/storage/FormatterTest.java 
b/metadata/src/test/java/org/apache/kafka/metadata/storage/FormatterTest.java
index ebb6f586969..2eeeab2259a 100644
--- 
a/metadata/src/test/java/org/apache/kafka/metadata/storage/FormatterTest.java
+++ 
b/metadata/src/test/java/org/apache/kafka/metadata/storage/FormatterTest.java
@@ -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)) {

Reply via email to