Cyrill commented on code in PR #7242:
URL: https://github.com/apache/ignite-3/pull/7242#discussion_r2741101740


##########
modules/raft/src/test/java/org/apache/ignite/internal/raft/client/RaftGroupServiceTest.java:
##########
@@ -680,6 +680,51 @@ public void testRetryOnErrorWithTimeout(RaftError error) {
         assertThat(response, willThrow(TimeoutException.class, "Send with 
retry timed out"));
     }
 
+    /**
+     * Tests that UNKNOWN/EINTERNAL/ENOENT errors retry on the same peer (the 
leader) for ActionRequests.
+     * This is because these errors are transient and the leader is likely to 
recover.
+     */
+    @ParameterizedTest
+    @EnumSource(names = {"UNKNOWN", "EINTERNAL", "ENOENT"})
+    public void testRetryOnTransientErrorRetriesOnSamePeer(RaftError error) {
+        Peer leaderPeer = NODES.get(0);
+
+        // First call returns error, second call succeeds - both to the same 
leader.
+        when(messagingService.invoke(
+                argThat((InternalClusterNode node) -> node != null && 
node.name().equals(leaderPeer.consistentId())),
+                any(ReadActionRequest.class),
+                anyLong())
+        )
+                .thenReturn(completedFuture(FACTORY.errorResponse()
+                        .errorCode(error.getNumber())
+                        .build()))
+                
.thenReturn(completedFuture(FACTORY.actionResponse().result(null).build()));
+
+        RaftGroupService service = 
startRaftGroupServiceWithRefreshLeader(NODES);
+
+        assertThat(service.leader(), is(leaderPeer));
+
+        CompletableFuture<Object> response = 
service.run(mock(ReadCommand.class));
+
+        assertThat(response, willBe(nullValue()));
+
+        // Verify that only the leader was called (twice: once with error, 
once with success).
+        verify(messagingService, atLeastOnce()).invoke(
+                argThat((InternalClusterNode target) -> target != null && 
target.name().equals(leaderPeer.consistentId())),
+                any(ReadActionRequest.class),
+                anyLong()
+        );
+
+        // Verify that other peers were NOT called.
+        for (Peer otherPeer : NODES.subList(1, NODES.size())) {
+            verify(messagingService, org.mockito.Mockito.never()).invoke(

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