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


##########
modules/raft/src/test/java/org/apache/ignite/internal/raft/client/PhysicalTopologyAwareRaftGroupServiceRunTest.java:
##########
@@ -436,6 +472,217 @@ void 
testBoundedTimeoutSucceedsWhenLeaderAppearsBeforeTimeout() {
         assertThat(result, willCompleteSuccessfully());
     }
 
+    /**
+     * Tests that with bounded timeout, the command fails if peer responses 
are slow and exceed the deadline.
+     */
+    @Test
+    void testBoundedTimeoutExpiresWhileTryingPeers() {
+        // Each peer response takes 200ms and returns EPERM (no leader).
+        // With 3 peers and 500ms timeout, we should exceed the deadline.
+        when(messagingService.invoke(
+                any(InternalClusterNode.class),
+                argThat(this::isTestWriteCommand),
+                anyLong()
+        )).thenAnswer(invocation -> {
+            return CompletableFuture.supplyAsync(() -> {
+                try {
+                    Thread.sleep(200);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+                return FACTORY.errorResponse()
+                        .errorCode(RaftError.EPERM.getNumber())
+                        .build();
+            }, executor);
+        });
+
+        PhysicalTopologyAwareRaftGroupService svc = startService();
+
+        // With 500ms timeout and 3 peers each taking 200ms, total time ~600ms 
> 500ms.
+        CompletableFuture<Object> result = svc.run(testWriteCommand(), 500);

Review Comment:
   The constants here are used for calculation: 
   T is the time of one request, we pick time X chosen so that 3*T < X.
   So we can pick pretty much any values as long as the equation is true 



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