nizhikov commented on code in PR #11673:
URL: https://github.com/apache/ignite/pull/11673#discussion_r1908317916


##########
modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java:
##########
@@ -752,6 +774,174 @@ public void 
testIdleVerifyOnInactiveClusterWithPersistence() throws Exception {
         assertContains(log, testOut.toString(), "The check procedure has 
finished, no conflicts have been found.");
     }
 
+    /**
+     *
+     */
+    @Test
+    public void testIdleVerifyCancelCommandOnCheckpoint() throws Exception {
+        final int gridsCnt = 4;
+
+        IgniteEx srv = startGrids(gridsCnt);
+
+        srv.cluster().state(ACTIVE);
+
+        CountDownLatch beforeCancelLatch = new CountDownLatch(1);
+
+        CountDownLatch afterCancelLatch = new CountDownLatch(1);
+
+        GridCacheDatabaseSharedManager dbMgr =
+            
(GridCacheDatabaseSharedManager)grid(1).context().cache().context().database();
+
+        dbMgr.addCheckpointListener(new CheckpointListener() {
+            @Override public void beforeCheckpointBegin(Context ctx) {
+                if (ctx.progress().reason().equals("VerifyBackupPartitions"))
+                    beforeCancelLatch.countDown();
+            }
+
+            @Override public void afterCheckpointEnd(Context ctx) throws 
IgniteCheckedException {
+                if (ctx.progress().reason().equals("VerifyBackupPartitions"))
+                    try {
+                        afterCancelLatch.await();
+                    }
+                    catch (InterruptedException e) {
+                        throw new IgniteInterruptedCheckedException(e);
+                    }
+            }
+
+            @Override public void onMarkCheckpointBegin(Context ctx) {
+            }
+
+            @Override public void onCheckpointBegin(Context ctx) {
+
+            }
+        });
+
+        List<LogListener> listeners = registerIdleVerifyCancelListeners();
+
+        IgniteCache<Integer, Integer> cache = srv.createCache(new 
CacheConfiguration<Integer, Integer>(DEFAULT_CACHE_NAME).setBackups(3));
+
+        for (int i = 0; i < 10000; i++)
+            cache.put(i, i);
+
+        IgniteInternalFuture<Integer> idleVerifyFut = 
GridTestUtils.runAsync(() -> execute("--cache", "idle_verify"));
+
+        beforeCancelLatch.await();
+
+        assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", 
"--cancel"));
+
+        afterCancelLatch.countDown();
+
+        checkSystemViewsNoIdleVerify(gridsCnt);
+
+        idleVerifyFut.get(getTestTimeout());
+
+        for (LogListener listener : listeners)
+            assertTrue(listener.check());
+    }
+
+    /**
+     *
+     */
+    @Test
+    public void testIdleVerifyTrackedForkJoinPool() throws Exception {
+        final int gridsCnt = 4;
+
+        IgniteEx srv = startGrids(gridsCnt);
+
+        srv.cluster().state(ACTIVE);
+
+        List<LogListener> listeners = registerIdleVerifyCancelListeners();
+
+        IgniteCache<Integer, Integer> cache = srv.createCache(new 
CacheConfiguration<Integer, Integer>(DEFAULT_CACHE_NAME).setBackups(3));
+
+        for (int i = 0; i < 10000; i++)
+            cache.put(i, i);
+
+        CountDownLatch beforeCancelLatch = new CountDownLatch(1);
+        CountDownLatch afterCancelLatch = new CountDownLatch(1);
+
+        ForkJoinPool forkJoinPool = new ForkJoinPool() {
+            @Override public <T> ForkJoinTask<T> submit(Callable<T> task) {
+                beforeCancelLatch.countDown();
+
+                ForkJoinTask<T> submitted = super.submit(task);
+
+                try {
+                    afterCancelLatch.await();
+                }
+                catch (InterruptedException e) {
+                    throw new RuntimeException(e);
+                }
+
+                return submitted;
+            }
+        };
+
+        VerifyBackupPartitionsTaskV2.poolSupplier = () -> forkJoinPool;
+
+        IgniteInternalFuture<Integer> idleVerifyFut = 
GridTestUtils.runAsync(() -> execute("--cache", "idle_verify"));
+
+        doSleep(1000);

Review Comment:
   Do we really need this? Let's remove explicit sleep.



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to