zstan commented on a change in pull request #8837:
URL: https://github.com/apache/ignite/pull/8837#discussion_r601098529



##########
File path: 
modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerIndexForceRebuildTest.java
##########
@@ -332,65 +339,89 @@ public void testAsyncIndexesRebuild() throws 
IgniteInterruptedCheckedException {
         assertTrue("Failed to wait for index rebuild start for second cache.",
             GridTestUtils.waitForCondition(() -> 
getActiveRebuildCaches(grid(0)).size() == 2, 10_000));
 
-        cacheNamesBlockedIdxRebuild.clear();
+        blockRebuildIdx.clear();
 
         assertTrue("Failed to wait for final index rebuild.", 
waitForIndexesRebuild(grid(0)));
     }
 
     /**
      * Checks how index force rebuild command behaves when caches are under 
load.
+     *
+     * @throws Exception If failed.
      */
     @Test
-    public void testIndexRebuildUnderLoad() throws 
IgniteInterruptedCheckedException {
-        IgniteEx ignite = grid(0);
+    public void testIndexRebuildUnderLoad() throws Exception {
+        IgniteEx n = grid(0);
 
         AtomicBoolean stopLoad = new AtomicBoolean(false);
 
-        Random rand = new Random();
+        String cacheName1 = "tmpCache1";
+        String cacheName2 = "tmpCache2";
 
-        final String cacheName1 = "tmpCache1";
-        final String cacheName2 = "tmpCache2";
-        final String grpName = "tmpGrp";
+        List<String> caches = F.asList(cacheName1, cacheName2);
 
         try {
-            createAndFillCache(ignite, cacheName1, grpName);
-            createAndFillCache(ignite, cacheName2, grpName);
+            for (String c : caches)
+                createAndFillCache(n, c, "tmpGrp");
 
-            IgniteCache<Long, Person> cache1 = ignite.cache(cacheName1);
+            int cacheSize = n.cache(cacheName1).size();
 
-            cacheNamesBlockedIdxRebuild.add(cacheName1);
-            cacheNamesBlockedIdxRebuild.add(cacheName2);
+            for (String c : caches)
+                blockRebuildIdx.put(c, new GridFutureAdapter<>());
 
             assertEquals(EXIT_CODE_OK, execute("--cache", 
"indexes_force_rebuild",
-                "--node-id", ignite.localNode().id().toString(),
+                "--node-id", n.localNode().id().toString(),
                 "--cache-names", cacheName1 + "," + cacheName2));
 
-            GridTestUtils.runAsync(() -> {
+            IgniteInternalFuture<?> putCacheFut = runAsync(() -> {
+                ThreadLocalRandom r = ThreadLocalRandom.current();
+
                 while (!stopLoad.get())
-                    cache1.put(rand.nextLong(), new Person(rand.nextInt(), 
valueOf(rand.nextLong())));
+                    n.cache(cacheName1).put(r.nextInt(), new 
Person(r.nextInt(), valueOf(r.nextLong())));
             });
 
-            ignite.destroyCache(cacheName2);
+            assertTrue(waitForCondition(() -> n.cache(cacheName1).size() > 
cacheSize, getTestTimeout()));
+
+            for (String c : caches) {
+                IgniteInternalFuture<?> rebIdxFut = 
n.context().query().indexRebuildFuture(CU.cacheId(c));
+                assertNotNull(rebIdxFut);
+                assertFalse(rebIdxFut.isDone());
+
+                blockRebuildIdx.get(c).get(getTestTimeout());
+            }
+
+            GridFutureAdapter<?> startDestroyFut = new GridFutureAdapter<>();
+
+            IgniteInternalFuture<?> destroyCacheFut = runAsync(() -> {
+                startDestroyFut.onDone();

Review comment:
       u will obtain _onDone_ before cache destroy will complete + why we need 
async here ?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to