FrankYang0529 commented on code in PR #17165: URL: https://github.com/apache/kafka/pull/17165#discussion_r1762256492
########## 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: Hi @TaiJuWu, thanks for the suggestion. It's hard to say waiting how much time can make sure `KafkaConsumer#subscribe` doesn't send a join request. I add two unit tests to check the behavior. In `ApplicationEventProcessorTest#testSubscriptionChangeEvent`, we check `ApplicationEventProcessor#process(SubscriptionChangeEvent)` doesn't call `ConsumerMembershipManager#maybeJoinGroup`. In `ConsumerMembershipManagerTest#testOnSubscriptionUpdatedTransitionsToJoiningOnlyIfNotInGroup`, we check `ConsumerMembershipManager#onSubscriptionUpdated` keeps member state as `UNSUBSCRIBED` and calling `transitionToJoining` in `maybeJoinGroup`. -- 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