Lalant commented on code in PR #7379:
URL: https://github.com/apache/ignite-3/pull/7379#discussion_r2697735284


##########
modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsTest.java:
##########
@@ -217,4 +224,65 @@ void testByteBufferToByteArray() {
         ByteBuffer smallDirectBuffer = 
bigDirectBuffer.position(1).limit(4).slice();
         assertArrayEquals(new byte[] {1, 2, 3}, 
byteBufferToByteArray(smallDirectBuffer));
     }
+
+    @Test
+    @Timeout(value = 1, unit = SECONDS)
+    void testRetryOperationUntilSuccessOrTimeout_SuccessOnFirstAttempt() {
+        Executor executor = Executors.newSingleThreadExecutor();
+        AtomicInteger callCount = new AtomicInteger(0);
+
+        CompletableFuture<String> result = retryOperationUntilSuccessOrTimeout(
+                () -> {
+                    callCount.incrementAndGet();
+                    return completedFuture("success");
+                },
+                1000,
+                executor
+        );
+
+        assertThat(result, willBe(equalTo("success")));
+        assertThat(callCount.get(), equalTo(1));
+    }
+
+    @Test
+    @Timeout(value = 1, unit = SECONDS)
+    void testRetryOperationUntilSuccessOrTimeout_SuccessAfterRetries() throws 
Exception {
+        Executor executor = Executors.newSingleThreadExecutor();
+        AtomicInteger callCount = new AtomicInteger(0);
+
+        CompletableFuture<String> result = retryOperationUntilSuccessOrTimeout(
+                () -> {
+                    int count = callCount.incrementAndGet();
+                    if (count < 3) {
+                        return failedFuture(new IOException("Temporary 
failure"));
+                    }
+                    return completedFuture("success");
+                },
+                1000,
+                executor
+        );
+
+        assertThat(result, willBe(equalTo("success")));
+        assertThat(callCount.get(), equalTo(3));
+    }
+
+    @Test
+    @Timeout(value = 1, unit = SECONDS)

Review Comment:
   I will increase up to 5 seconds



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