alievmirza commented on a change in pull request #481:
URL: https://github.com/apache/ignite-3/pull/481#discussion_r769776573



##########
File path: 
modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java
##########
@@ -3330,6 +3330,134 @@ public void testBlockedElection() throws Exception {
         leader = cluster.getLeader();
         LOG.info("Elect new leader is {}, curTerm={}", leader.getLeaderId(), 
((NodeImpl) leader).getCurrentTerm());
     }
+    
+    @Test
+    public void testElectionTimeoutAutoAdjustWhenBlockedAllMesssages() throws 
Exception {
+        List<PeerId> peers = TestUtils.generatePeers(3);
+        cluster = new TestCluster("unittest", dataPath, peers,  testInfo);
+        
+        
+        for (PeerId peer : peers)
+            assertTrue(cluster.start(peer.getEndpoint()));
+        
+        cluster.waitLeader();
+        
+        Node leader = cluster.getLeader();
+        
+        int initElectionTimeout = leader.getOptions().getElectionTimeoutMs();
+        
+        LOG.warn("Current leader {}, electTimeout={}", 
leader.getNodeId().getPeerId(), leader.getOptions().getElectionTimeoutMs());
+        
+        List<Node> followers = cluster.getFollowers();
+    
+        for (Node follower : followers) {
+            NodeImpl follower0 = (NodeImpl) follower;
+    
+            assertEquals(initElectionTimeout, 
follower0.getOptions().getElectionTimeoutMs());
+        }
+        
+        for (Node follower : followers) {
+            NodeImpl follower0 = (NodeImpl) follower;
+            DefaultRaftClientService rpcService = (DefaultRaftClientService) 
follower0.getRpcClientService();
+            RpcClientEx rpcClientEx = (RpcClientEx) rpcService.getRpcClient();
+            rpcClientEx.blockMessages((msg, nodeId) -> true);
+        }
+        
+        LOG.warn("Stop leader {}, curTerm={}", leader.getNodeId().getPeerId(), 
((NodeImpl) leader).getCurrentTerm());
+
+        assertTrue(cluster.stop(leader.getNodeId().getPeerId().getEndpoint()));
+        
+        assertNull(cluster.getLeader());
+        
+        assertTrue(waitForCondition(() -> followers.stream().allMatch(f -> 
f.getOptions().getElectionTimeoutMs() > initElectionTimeout),
+                (long) NodeOptions.MAX_ELECTION_ROUNDS_WITHOUT_ADJUSTING
+                        // need to multiply to 2 because stepDown happens 
after voteTimer timeout
+                        * (initElectionTimeout + 
followers.get(0).getOptions().getRaftOptions().getMaxElectionDelayMs()) * 2));
+        
+        for (Node follower : followers) {
+            NodeImpl follower0 = (NodeImpl) follower;
+            DefaultRaftClientService rpcService = (DefaultRaftClientService) 
follower0.getRpcClientService();
+            RpcClientEx rpcClientEx = (RpcClientEx) rpcService.getRpcClient();
+            rpcClientEx.stopBlock();
+        }
+        
+        // elect new leader
+        cluster.waitLeader();
+        leader = cluster.getLeader();
+        
+        LOG.info("Elect new leader is {}, curTerm={}", leader.getLeaderId(), 
((NodeImpl) leader).getCurrentTerm());
+    
+        assertTrue(waitForCondition(() -> followers.stream().allMatch(f -> 
f.getOptions().getElectionTimeoutMs() == initElectionTimeout),
+                3_000));
+    }
+    
+    @Test
+    public void testElectionTimeoutAutoAdjustWhenBlockedRequestVoteMessages() 
throws Exception {

Review comment:
       done

##########
File path: modules/raft/src/main/java/org/apache/ignite/internal/raft/Loza.java
##########
@@ -67,7 +67,7 @@
 
     /** Network timeout. */
     // TODO: IGNITE-15705 Correct value should be investigated
-    private static final int NETWORK_TIMEOUT = 3000;
+    private static final int RPC_TIMEOUT = 3000;

Review comment:
       done




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