TaiJuWu commented on code in PR #17165: URL: https://github.com/apache/kafka/pull/17165#discussion_r1762204798
########## clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java: ########## @@ -3443,6 +3443,33 @@ public void testPreventMultiThread(GroupProtocol groupProtocol) throws Interrupt } } + @ParameterizedTest + @EnumSource(value = GroupProtocol.class) + public void testPollSendRequestForRebalance(GroupProtocol groupProtocol) throws InterruptedException { + ConsumerMetadata metadata = createMetadata(subscription); + MockClient client = new MockClient(time, metadata); + initMetadata(client, Collections.singletonMap(topic, 1)); + Node node = metadata.fetch().nodes().get(0); + + client.prepareResponseFrom(FindCoordinatorResponse.prepareResponse(Errors.NONE, groupId, node), node); + KafkaConsumer<String, String> consumer = newConsumer(groupProtocol, time, client, subscription, metadata, + assignor, true, groupInstanceId); + consumer.subscribe(singletonList(topic)); Review Comment: Sorry for unclear. Make `application` sleep here is just for making `network` have time to send `join request` without poll in original code. It can help to reproduce this bug easier and more stable, the test can pass sometime without it. In order to make sure this behavior which we promise in docs, two operation (subscribe and poll) should not too close in timeline. Does it make sense? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org