-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-7938: Fix test flakiness in DeleteConsumerGroupsTest #6306
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,7 @@ class DeleteConsumerGroupsTest extends ConsumerGroupCommandTest { | |
| val service = getConsumerGroupService(cgcArgs) | ||
|
|
||
| TestUtils.waitUntilTrue(() => { | ||
| service.listGroups().contains(group) | ||
| service.collectGroupMembers(false)._2.get.size == 1 | ||
| }, "The group did not initialize as expected.", maxRetries = 3) | ||
|
|
||
| val output = TestUtils.grabConsoleOutput(service.deleteGroups()) | ||
|
|
@@ -88,10 +88,12 @@ class DeleteConsumerGroupsTest extends ConsumerGroupCommandTest { | |
| val service = getConsumerGroupService(cgcArgs) | ||
|
|
||
| TestUtils.waitUntilTrue(() => { | ||
| service.listGroups().contains(group) | ||
| service.collectGroupMembers(false)._2.get.size == 1 | ||
| }, "The group did not initialize as expected.", maxRetries = 3) | ||
|
|
||
| val result = service.deleteGroups() | ||
| println(result) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unintentional line here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, quite intentional :) Those failures are difficult to reproduce, so more info in the console output of the test will help us next time. I can add a comment if this is confusing.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this prints the output even when the test passes. If we want the output on failures only maybe that output can be added to the assertion error messages that follow. Unless there is another reason to have the output in either scenario?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, that makes sense. Will send the improvement tomorrow morning :) |
||
| assertNotNull("Group was deleted successfully, but it shouldn't have been", result.get(group).get) | ||
| assertTrue(s"The expected error (${Errors.NON_EMPTY_GROUP}) was not detected while deleting consumer group", | ||
| result.size == 1 && result.keySet.contains(group) && result.get(group).get.getCause.isInstanceOf[GroupNotEmptyException]) | ||
| } | ||
|
|
@@ -199,30 +201,6 @@ class DeleteConsumerGroupsTest extends ConsumerGroupCommandTest { | |
| result.keySet.contains(missingGroup) && result.get(missingGroup).get.getMessage.contains(Errors.GROUP_ID_NOT_FOUND.message)) | ||
| } | ||
|
|
||
| @Test | ||
| def testDeleteCmdWithShortInitialization() { | ||
| // run one consumer in the group | ||
| addConsumerGroupExecutor(numConsumers = 1) | ||
| val cgcArgs = Array("--bootstrap-server", brokerList, "--delete", "--group", group) | ||
| val service = getConsumerGroupService(cgcArgs) | ||
|
|
||
| val output = TestUtils.grabConsoleOutput(service.deleteGroups()) | ||
| assertTrue(s"The consumer group deletion did not work as expected", | ||
| output.contains(s"Group '$group' could not be deleted due to")) | ||
| } | ||
|
|
||
| @Test | ||
| def testDeleteWithShortInitialization() { | ||
| // run one consumer in the group | ||
| addConsumerGroupExecutor(numConsumers = 1) | ||
| val cgcArgs = Array("--bootstrap-server", brokerList, "--delete", "--group", group) | ||
| val service = getConsumerGroupService(cgcArgs) | ||
|
|
||
| val result = service.deleteGroups() | ||
| assertTrue(s"The consumer group deletion did not work as expected", | ||
| result.size == 1 && result.keySet.contains(group)) | ||
| } | ||
|
|
||
| @Test(expected = classOf[OptionException]) | ||
| def testDeleteWithUnrecognizedNewConsumerOption() { | ||
| val cgcArgs = Array("--new-consumer", "--bootstrap-server", brokerList, "--delete", "--group", group) | ||
|
|
||
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 improving this check. Do you think it's worth doing the same in a few other unit tests in this file?
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 went over the other tests, and none of them required a non-empty group specifically. Did I miss something?
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.
You're right, sorry my mistake.