slfan1989 commented on code in PR #1571:
URL: https://github.com/apache/ratis/pull/1571#discussion_r3888635992
##########
ratis-server/src/test/java/org/apache/ratis/server/impl/RaftReconfigurationBaseTest.java:
##########
@@ -507,86 +513,119 @@ void runTestBootstrapReconf(int numNewPeer, boolean
startNewPeer, CLUSTER cluste
* retrying.
*/
@Test
- @Flaky("RATIS-2251")
+ @Timeout(120)
public void testKillLeaderDuringReconf() throws Exception {
// originally 3 peers
runWithNewCluster(3, this::runTestKillLeaderDuringReconf);
}
+ /**
+ * Checks whether the server is bootstrapping the given peer.
+ *
+ * @param server the server division to check
+ * @param peerId the ID of the peer to check
+ * @return true if the peer is being bootstrapped in the leader staging
state; otherwise, false
+ */
+ private static boolean isBootstrappingPeer(RaftServer.Division server,
RaftPeerId peerId) {
+ return ((RaftServerImpl) server).getRole().getLeaderState()
+ .filter(LeaderStateImpl::inStagingState)
+ .map(state -> state.isBootStrappingPeer(peerId))
+ .orElse(false);
+ }
+
void runTestKillLeaderDuringReconf(CLUSTER cluster) throws Exception {
- final AtomicBoolean clientRunning = new AtomicBoolean(true);
- Thread clientThread = null;
+ final ExecutorService executor = ConcurrentUtils.newSingleThreadExecutor(
Review Comment:
Run `setConfiguration` asynchronously in a named single-thread executor so
that the test can kill the leader while reconfiguration is in progress. The
returned `Future` allows the test to validate the reply, propagate failures,
and clean up the background task reliably.
--
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]