hachikuji commented on a change in pull request #10913:
URL: https://github.com/apache/kafka/pull/10913#discussion_r656588602
##########
File path: raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java
##########
@@ -359,6 +360,150 @@ public void testResignWillCompleteFetchPurgatory() throws
Exception {
assertFalse(context.client.isShuttingDown());
}
+ @Test
+ public void testResignInOlderEpochIgnored() 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());
+
+ int currentEpoch = context.currentEpoch();
+ context.client.resign(currentEpoch - 1);
+ context.assertElectedLeader(currentEpoch, localId);
+ }
+
+ @Test
+ public void testHandleBeginQuorumEpochAfterUserInitiatedResign() throws
Exception {
+ int localId = 0;
+ int remoteId1 = 1;
+ int remoteId2 = 2;
+ Set<Integer> voters = Utils.mkSet(localId, remoteId1, remoteId2);
+
+ RaftClientTestContext context = new
RaftClientTestContext.Builder(localId, voters).build();
+
+ context.becomeLeader();
+ assertEquals(OptionalInt.of(localId), context.currentLeader());
+
+ int resignedEpoch = context.currentEpoch();
+
+ context.client.resign(resignedEpoch);
+ context.pollUntil(context.client.quorum()::isResigned);
+
+ context.deliverRequest(context.beginEpochRequest(resignedEpoch + 1,
remoteId1));
+ context.pollUntilResponse();
+ context.assertSentBeginQuorumEpochResponse(Errors.NONE);
+ context.assertElectedLeader(resignedEpoch + 1, remoteId1);
Review comment:
I'm inclined to do it in other tests to keep the test from getting too
bloated. It looks like we do not have many tests for `handleLeaderChange` at
the moment, so let me try to address the gap.
--
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:
[email protected]