Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/src/main/scala/kafka/tools/StorageTool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ object StorageTool extends Logging {
metaPropertiesEnsemble.verify(metaProperties.clusterId(), metaProperties.nodeId(),
util.EnumSet.noneOf(classOf[VerificationFlag]))

stream.println(s"metaPropertiesEnsemble=$metaPropertiesEnsemble")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testFormatEmptyDirectory and testFormatSucceedsIfAllDirectoriesAreAvailable need to be updated for this change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmccabe not sure whether this output is debugging-only? it was added by #14628, and the code was System.out.println(s"metaPropertiesEnsemble=${metaPropertiesEnsemble}"). Hence, I assume it was used to debug only before.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmccabe not sure whether this output is debugging-only? it was added by #14628, and the code was System.out.println(s"metaPropertiesEnsemble=${metaPropertiesEnsemble}"). Hence, I assume it was used to debug only before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

val copier = new MetaPropertiesEnsemble.Copier(metaPropertiesEnsemble)
if (!(ignoreFormatted || copier.logDirProps().isEmpty)) {
val firstLogDir = copier.logDirProps().keySet().iterator().next()
Expand Down
11 changes: 3 additions & 8 deletions core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,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(stringAfterFirstLine(stream.toString()).startsWith("Formatting %s".format(tempDir)))
assertTrue(stream.toString().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 @@ -195,15 +195,10 @@ 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(), stringAfterFirstLine(stream2.toString()))
assertEquals("All of the log directories are already formatted.%n".format(), stream2.toString())
} finally Utils.delete(tempDir)
}

def stringAfterFirstLine(input: String): String = {
val firstNewline = input.indexOf("\n")
input.substring(firstNewline + 1)
}

private def runFormatCommand(stream: ByteArrayOutputStream, directories: Seq[String], ignoreFormatted: Boolean = false): Int = {
val metaProperties = new MetaProperties.Builder().
setVersion(MetaPropertiesVersion.V1).
Expand All @@ -221,7 +216,7 @@ Found problem:
assertEquals(0, runFormatCommand(stream, availableDirs))
val actual = stream.toString().split("\\r?\\n")
val expect = availableDirs.map("Formatting %s".format(_))
assertEquals(availableDirs.size + 1, actual.size)
assertEquals(availableDirs.size, actual.size)
expect.foreach(dir => {
assertEquals(1, actual.count(_.startsWith(dir)))
})
Expand Down