OmniaGM commented on code in PR #23639:
URL: https://github.com/apache/kafka/pull/23639#discussion_r4456131537
##########
metadata/src/test/java/org/apache/kafka/controller/QuorumControllerTest.java:
##########
@@ -1789,4 +1788,51 @@ public void
testBrokerHeartbeatDuringMigration(MetadataVersion metadataVersion)
}
}
+
+ @Test
+ public void testForceRenounceResignsActiveController() throws Throwable {
+ try (
+ LocalLogManagerTestEnv logEnv = new
LocalLogManagerTestEnv.Builder(3).
+ build();
+ QuorumControllerTestEnv controlEnv = new
QuorumControllerTestEnv.Builder(logEnv).
+ build()
+ ) {
+ QuorumController active = controlEnv.activeController(true);
+ int previousEpoch = active.curClaimEpoch();
+
+ active.forceRenounce().get(20, TimeUnit.SECONDS);
+
+ assertEquals(-1, active.curClaimEpoch());
Review Comment:
I believe this assertion can be flaky. `renounce()` calls
`raftClient.resign`. In `LocalLogManager`, `tryAppend` then calls
`electLeaderIfNeeded`, which picks a random node straight away. With 3
controllers in this test, the node that just renounced can be picked again. If
its controller thread processes that `handleLeaderChange` and calls `claim`
again before the test thread reads `curClaimEpoch()`, and then this assertion
fails. That's more likely on a busy CI machine.
The check below, `newActive.curClaimEpoch() > previousEpoch`, already proves
the renounce happened. Could we drop this one? WDYT?
--
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]