AndrewJSchofield commented on code in PR #23664:
URL: https://github.com/apache/kafka/pull/23664#discussion_r4553154694
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManagerTest.java:
##########
@@ -3047,6 +3063,116 @@ void testWhenLeadershipChangedAfterDisconnected() {
fetchedRecords = partitionRecords.get(tp0);
assertEquals(1, fetchedRecords.size());
+
+ // The redirect leaves tp0 on node 1. The next poll removes tp0 from
the share session on node 0.
+ assertEquals(nodeId1.id(),
shareConsumeRequestManager.shareSessionNodeId(tip0));
+ pollResult = shareConsumeRequestManager.sendFetchesReturnPollResult();
+ requestsByNode.clear();
+ pollResult.unsentRequests.forEach(unsentRequest ->
+ requestsByNode.put(unsentRequest.node().get().id(),
((ShareFetchRequest.Builder) unsentRequest.requestBuilder()).data()));
+ node0Request = requestsByNode.get(nodeId0.id());
+ assertNotNull(node0Request);
+ assertTrue(node0Request.topics().isEmpty());
+ assertEquals(1, node0Request.forgottenTopicsData().size());
+ assertEquals(List.of(tip0.partition()),
node0Request.forgottenTopicsData().get(0).partitions());
+ }
+
+ /**
+ * A disconnect forgets the cached leader, but if the metadata still names
the same node, the next fetch simply
+ * retries that node with a new share session containing the partition.
+ */
+ @Test
+ void testDisconnectWithoutLeadershipChangeRetriesSameNode() {
+ buildRequestManager();
+
+ subscriptions.subscribeToShareGroup(Set.of(topicName));
Review Comment:
Hmm. Funny how the build didn't fail, but you're absolutely right. Fixed.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]