ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-4436 Added tests.
Date Mon, 30 Jan 2017 13:54:09 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-4436-2 2416432e7 -> fd94b0ac9


IGNITE-4436 Added tests.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fd94b0ac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fd94b0ac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fd94b0ac

Branch: refs/heads/ignite-4436-2
Commit: fd94b0ac9b3bc6871968cf678d84d75c41b4845b
Parents: 2416432
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Jan 30 20:54:00 2017 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Jan 30 20:54:00 2017 +0700

----------------------------------------------------------------------
 .../cache/GridCacheCrossCacheQuerySelfTest.java | 55 ++++++++++++++++++--
 1 file changed, 51 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fd94b0ac/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
index 4da31ab..a28e670 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
@@ -60,9 +60,13 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest
{
     /** */
     private Ignite ignite;
 
-    /***/
+    /**
+     * Utility class with custom SQL functions.
+     */
     public static class TestSQLFunctions {
         /**
+         * Sleep function to simulate long running queries.
+         *
          * @param x Time to sleep.
          * @return Return specified argument.
          */
@@ -264,17 +268,60 @@ public class GridCacheCrossCacheQuerySelfTest extends GridCommonAbstractTest
{
             }
         }, 1);
 
-        Thread.sleep(100);
+        Thread.sleep(1000);
 
         GridQueryIndexing idx = ((IgniteKernal)ignite).context().query().indexing();
 
-        Collection<GridQuery> queries = idx.runningQueries(50);
+        Collection<GridQuery> queries = idx.runningQueries(500);
 
         assertEquals(1, queries.size());
 
         fut.get();
 
-        queries = idx.runningQueries(50);
+        queries = idx.runningQueries(500);
+
+        assertEquals(0, queries.size());
+    }
+
+    /**
+     * Test collecting info about running.
+     *
+     * @throws Exception If failed.
+     */
+    public void testCancelingQueries() throws Exception {
+        IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+            @Override public void run() {
+                try {
+                    SqlFieldsQuery qry = new SqlFieldsQuery("select productId, sleep(500)
from FactPurchase limit 100");
+
+                    ignite.cache("partitioned").query(qry).getAll();
+                }
+                catch (Throwable e) {
+                    e.printStackTrace();
+                }
+            }
+        }, 1);
+
+        Thread.sleep(1000);
+
+        GridQueryIndexing idx = ((IgniteKernal)ignite).context().query().indexing();
+
+        Collection<GridQuery> queries = idx.runningQueries(500);
+
+        assertEquals(1, queries.size());
+
+        for (GridQuery query : queries)
+            idx.cancelQueries(Collections.singleton(query.id()));
+
+        Thread.sleep(2000); // Give cluster some time to cancel query and cleanup resources.
+
+        queries = idx.runningQueries(500);
+
+        assertEquals(0, queries.size());
+
+        fut.get();
+
+        queries = idx.runningQueries(500);
 
         assertEquals(0, queries.size());
     }


Mime
View raw message