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


##########
modules/raft/src/test/java/org/apache/ignite/internal/raft/client/PhysicalTopologyAwareRaftGroupServiceRunTest.java:
##########
@@ -344,20 +358,42 @@ void testInfiniteTimeoutSuccessWhenLeaderAvailable() {
     }
 
     /**
-     * Tests that with Long.MAX_VALUE timeout, the command waits for leader 
and succeeds when leader appears.
+     * Tests that with Long.MAX_VALUE timeout, all peers are tried first, then 
waits for leader, and succeeds when leader appears.
      */
     @Test
-    void testInfiniteTimeoutWaitsForLeaderAndSucceeds() {
-        mockLeaderRequest();
-        mockUserInputSuccess();
+    void testInfiniteTimeoutWaitsForLeaderAndSucceeds() throws Exception {
+        // First 3 WriteActionRequest calls return EPERM (no leader), then 
success after leader appears.
+        AtomicInteger callCount = new AtomicInteger(0);
+        CountDownLatch allPeersTried = new CountDownLatch(3);
+
+        when(messagingService.invoke(
+                any(InternalClusterNode.class),
+                argThat(this::isTestWriteCommand),
+                anyLong()
+        )).thenAnswer(invocation -> {
+            if (callCount.incrementAndGet() <= 3) {
+                allPeersTried.countDown();
+                return completedFuture(FACTORY.errorResponse()
+                        .errorCode(RaftError.EPERM.getNumber())
+                        .build());
+            }
+            return completedFuture(FACTORY.actionResponse().result(new 
TestResponse()).build());
+        });
 
         PhysicalTopologyAwareRaftGroupService svc = startService();
 
-        // Start the command - it should wait for leader.
+        // Start the command - it should try all peers first, then wait for 
leader.
         CompletableFuture<Object> result = svc.run(testWriteCommand(), 
Long.MAX_VALUE);
 
+        // Wait for all peer attempts to complete.
+        assertTrue(allPeersTried.await(5, TimeUnit.SECONDS), "All peers should 
be tried");
+
+        verifyExact3PeersCalled();
+
         // Initially not complete (waiting for leader).
-        // After a short delay, simulate leader election.
+        assertThat(result.isDone(), is(false));

Review Comment:
   I guess the answer is no because public method for such await looks wrong



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