dengziming commented on a change in pull request #9639: URL: https://github.com/apache/kafka/pull/9639#discussion_r538989377
########## File path: raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java ########## @@ -207,6 +208,41 @@ public void testEndQuorumEpochRetriesWhileResigned() throws Exception { assertEquals(1, retries.size()); } + @Test + public void testResignWillCompleteFetchPurgatory() throws Exception { + int localId = 0; + int otherNodeId = 1; + Set<Integer> voters = Utils.mkSet(localId, otherNodeId); + + RaftClientTestContext context = new RaftClientTestContext.Builder(localId, voters) + .build(); + + context.becomeLeader(); + assertEquals(OptionalInt.of(localId), context.currentLeader()); + + // send fetch request when become leader + int epoch = context.currentEpoch(); + context.deliverRequest(context.fetchRequest(epoch, otherNodeId, context.log.endOffset().offset, epoch, 1000)); + context.client.poll(); + assertEquals(context.client.numWaitingFetch(), 1); + + // append some record, but the fetch in purgatory will still fail + context.log.appendAsLeader(Collections.singleton(new SimpleRecord("raft".getBytes())), epoch); + + // when transition to resign, all request in fetchPurgatory will fail + context.client.shutdown(1000); + context.client.poll(); + assertTrue(context.client.quorumState().isResigned()); + assertEquals(context.client.numWaitingFetch(), 0); Review comment: This is just a double-check, it's better to be removed. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org