You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2024/05/29 17:08:24 UTC
(kafka) branch trunk updated: KAFKA-16771 First log directory printed twice when formatting storage (#16010)
This is an automated email from the ASF dual-hosted git repository.
chia7712 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 0f0c9ecbf33 KAFKA-16771 First log directory printed twice when formatting storage (#16010)
0f0c9ecbf33 is described below
commit 0f0c9ecbf330923ad653cc2ff4fca6c4dced1cf7
Author: gongxuanzhang <go...@gmail.com>
AuthorDate: Thu May 30 01:08:17 2024 +0800
KAFKA-16771 First log directory printed twice when formatting storage (#16010)
Reviewers: Chia-Ping Tsai <ch...@gmail.com>
---
core/src/main/scala/kafka/tools/StorageTool.scala | 4 ++--
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala | 14 +++++++++-----
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/core/src/main/scala/kafka/tools/StorageTool.scala b/core/src/main/scala/kafka/tools/StorageTool.scala
index 148be404bf7..86c82f1a195 100644
--- a/core/src/main/scala/kafka/tools/StorageTool.scala
+++ b/core/src/main/scala/kafka/tools/StorageTool.scala
@@ -253,7 +253,7 @@ object StorageTool extends Logging {
.setServerKey(formatter.serverKey(saltedPassword))
.setIterations(iterations)
} catch {
- case e: Throwable =>
+ case e: Throwable =>
throw new TerseFailure(s"Error attempting to create UserScramCredentialRecord: ${e.getMessage}")
}
myrecord
@@ -464,8 +464,8 @@ object StorageTool extends Logging {
copier.setWriteErrorHandler((logDir, e) => {
throw new TerseFailure(s"Error while writing meta.properties file $logDir: ${e.getMessage}")
})
- copier.writeLogDirChanges()
})
+ copier.writeLogDirChanges()
}
0
}
diff --git a/core/src/test/scala/unit/kafka/tools/StorageToolTest.scala b/core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
index 0fe72cfa667..9f48348b812 100644
--- a/core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
+++ b/core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
@@ -206,12 +206,15 @@ Found problem:
@Test
def testFormatSucceedsIfAllDirectoriesAreAvailable(): Unit = {
- val availableDir1 = TestUtils.tempDir()
- val availableDir2 = TestUtils.tempDir()
+ val availableDirs = Seq(TestUtils.tempDir(), TestUtils.tempDir(), TestUtils.tempDir()).map(dir => dir.toString)
val stream = new ByteArrayOutputStream()
- assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, availableDir2.toString)))
- assertTrue(stream.toString().contains("Formatting %s".format(availableDir1)))
- assertTrue(stream.toString().contains("Formatting %s".format(availableDir2)))
+ assertEquals(0, runFormatCommand(stream, availableDirs))
+ val actual = stream.toString().split("\\r?\\n")
+ val expect = availableDirs.map("Formatting %s".format(_))
+ assertEquals(availableDirs.size, actual.size)
+ expect.foreach(dir => {
+ assertEquals(1, actual.count(_.startsWith(dir)))
+ })
}
@Test
@@ -489,3 +492,4 @@ Found problem:
}
}
}
+