Skip to content

Commit

Permalink
KAFKA-16771 First log directory printed twice when formatting storage (
Browse files Browse the repository at this point in the history
…apache#16010)

Reviewers: Chia-Ping Tsai <[email protected]>
  • Loading branch information
gongxuanzhang authored May 29, 2024
1 parent 2d9994e commit 0f0c9ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/kafka/tools/StorageTool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
14 changes: 9 additions & 5 deletions core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -489,3 +492,4 @@ Found problem:
}
}
}

0 comments on commit 0f0c9ec

Please sign in to comment.