-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-16888 Fix failed StorageToolTest.testFormatSucceedsIfAllDirectoriesAreAvailable and StorageToolTest.testFormatEmptyDirectory #16186
Conversation
…riesAreAvailable and StorageToolTest.testFormatEmptyDirectory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @brandboat ! I assume the patch fixes the broken tests, but could you please add some info in the PR description for reviewers know why this fixes the issue. Something like:
- Why it is broken
- In which commit changes the behavior and why changes
- How do you fix it
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brandboat thanks for this hot-fix!
@@ -213,7 +213,7 @@ Found problem: | |||
val availableDirs = Seq(TestUtils.tempDir(), TestUtils.tempDir(), TestUtils.tempDir()).map(dir => dir.toString) | |||
val stream = new ByteArrayOutputStream() | |||
assertEquals(0, runFormatCommand(stream, availableDirs)) | |||
val actual = stream.toString().split("\\r?\\n") | |||
val actual = stream.toString().split("\\r?\\n").drop(1) | |||
val expect = availableDirs.map("Formatting %s".format(_)) | |||
assertEquals(availableDirs.size, actual.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me this (failed) check can be removed. All we wan to test is the folders get formatted only once, and that is verified in the following assert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've addressed comments in the latest commit, thanks for reviewing.
@@ -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").drop(1)(0).startsWith("Formatting %s".format(tempDir))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can check that output contains the expected content. for example:
assertTrue(stream.toString().split("\\r?\\n").exists(_.startsWith("Formatting %s".format(tempDir))))
drop(1)(0)
is too magic to understand to me :)
@@ -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("All of the log directories are already formatted.".format(), stream2.toString().split("\\r?\\n").drop(1)(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Added some description in pr, thanks ! 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…riesAreAvailable and StorageToolTest.testFormatEmptyDirectory (#16186) Reviewers: Luke Chen <[email protected]>, Chia-Ping Tsai <[email protected]>
…riesAreAvailable and StorageToolTest.testFormatEmptyDirectory (apache#16186) Reviewers: Luke Chen <[email protected]>, Chia-Ping Tsai <[email protected]>
…riesAreAvailable and StorageToolTest.testFormatEmptyDirectory (apache#16186) Reviewers: Luke Chen <[email protected]>, Chia-Ping Tsai <[email protected]>
a quick fix for https://issues.apache.org/jira/browse/KAFKA-16888
459da47#diff-4bacfdbf0e63a4d5f3deb1a0d39037a18510ac24ee5ec276fe70bc818ba4d209L505 put extra information as follows to the beginning of the output which break some tests in StorageToolTest that rely on the original output.
This pr modified the test
testFormatSucceedsIfAllDirectoriesAreAvailable
,testFormatEmptyDirectory
to get rid of those extra infos to avoid test failed.Committer Checklist (excluded from commit message)