ahuang98 commented on code in PR #20318:
URL: https://github.com/apache/kafka/pull/20318#discussion_r2414603345


##########
raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java:
##########
@@ -633,6 +634,49 @@ public void testBeginQuorumEpochHeartbeat(boolean 
withKip853Rpc) throws Exceptio
         context.assertSentBeginQuorumEpochRequest(epoch, Set.of(remoteId1, 
remoteId2));
     }
 
+    @ParameterizedTest
+    @ValueSource(booleans = { true, false })
+    public void testBeginQuorumShouldNotSendAfterFetchRequest(boolean 
withKip853Rpc) throws Exception {
+        ReplicaKey localId = replicaKey(randomReplicaId(), true);
+        int remoteId1 = localId.id() + 1;
+        int remoteId2 = localId.id() + 2;
+        ReplicaKey replicaKey1 = replicaKey(remoteId1, withKip853Rpc);
+        ReplicaKey replicaKey2 = replicaKey(remoteId2, withKip853Rpc);
+
+        RaftClientTestContext context = new RaftClientTestContext.Builder(
+                localId.id(), localId.directoryId().get())
+                .withKip853Rpc(withKip853Rpc)
+                .withStartingVoters(VoterSetTest.voterSet(Stream.of(localId, 
replicaKey1, replicaKey2)), KRaftVersion.KRAFT_VERSION_1)
+                .build();
+
+        context.unattachedToLeader();
+        int epoch = context.currentEpoch();
+        assertEquals(OptionalInt.of(localId.id()), context.currentLeader());
+
+        // begin epoch requests sent out every beginQuorumEpochTimeoutMs if 
replicas have not fetched
+        context.time.sleep(context.beginQuorumEpochTimeoutMs);
+        context.client.poll();
+        context.assertSentBeginQuorumEpochRequest(epoch, Set.of(remoteId1, 
remoteId2));
+
+        long partialDelay = context.beginQuorumEpochTimeoutMs / 3;
+        context.time.sleep(context.beginQuorumEpochTimeoutMs / 3);
+        context.deliverRequest(context.fetchRequest(epoch, replicaKey1, 0, 0, 
0));
+        context.pollUntilResponse();
+
+        context.time.sleep(context.beginQuorumEpochTimeoutMs - partialDelay);
+        context.client.poll();
+        // don't send BeginQuorumEpochRequest again for replicaKey1 since 
fetchRequest is sent.

Review Comment:
   suggestion: `// leader will not send BeginQuorumEpochRequest again for 
replica 1 since fetchRequest was received before beginQuorumEpochTimeoutMs time 
has elapsed`



-- 
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]

Reply via email to