Skip to content

Commit

Permalink
KAFKA-16888 Fix failed StorageToolTest.testFormatSucceedsIfAllDirecto…
Browse files Browse the repository at this point in the history
…riesAreAvailable and StorageToolTest.testFormatEmptyDirectory (#16186)

Reviewers: Luke Chen <[email protected]>, Chia-Ping Tsai <[email protected]>
  • Loading branch information
brandboat authored Jun 4, 2024
1 parent eea9ebf commit a08db65
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Found problem:
val bootstrapMetadata = StorageTool.buildBootstrapMetadata(MetadataVersion.latestTesting(), None, "test format command")
assertEquals(0, StorageTool.
formatCommand(new PrintStream(stream), Seq(tempDir.toString), metaProperties, bootstrapMetadata, MetadataVersion.latestTesting(), ignoreFormatted = false))
assertTrue(stream.toString().startsWith("Formatting %s".format(tempDir)))
assertTrue(stream.toString().split("\\r?\\n").exists(_.startsWith("Formatting %s".format(tempDir))))

try assertEquals(1, StorageTool.
formatCommand(new PrintStream(new ByteArrayOutputStream()), Seq(tempDir.toString), metaProperties, bootstrapMetadata, MetadataVersion.latestTesting(), ignoreFormatted = false)) catch {
Expand All @@ -194,7 +194,7 @@ Found problem:
val stream2 = new ByteArrayOutputStream()
assertEquals(0, StorageTool.
formatCommand(new PrintStream(stream2), Seq(tempDir.toString), metaProperties, bootstrapMetadata, MetadataVersion.latestTesting(), ignoreFormatted = true))
assertEquals("All of the log directories are already formatted.%n".format(), stream2.toString())
assertEquals(1, stream2.toString().split("\\r?\\n").count(_.startsWith("All of the log directories are already formatted")))
} finally Utils.delete(tempDir)
}

Expand All @@ -215,7 +215,6 @@ Found problem:
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)))
})
Expand Down

0 comments on commit a08db65

Please sign in to comment.