ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [01/42] incubator-ignite git commit: # IGNITE-745 Updated test for metrics.
Date Wed, 03 Jun 2015 15:06:02 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-883_1 7a2e898dd -> 4184f363c


# IGNITE-745 Updated test for metrics.


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

Branch: refs/heads/ignite-883_1
Commit: 211754df0579a6ac23e54a9d730e3104a453080d
Parents: 59b11b4
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Tue Apr 14 16:38:35 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Tue Apr 14 16:38:35 2015 +0700

----------------------------------------------------------------------
 .../cache/GridCacheQueryMetricsSelfTest.java    | 106 ++++++++++++++-----
 1 file changed, 77 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/211754df/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java
index 45d605c..24011b4 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryMetricsSelfTest.java
@@ -17,18 +17,15 @@
 
 package org.apache.ignite.internal.processors.cache;
 
+import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.common.*;
 
-import java.util.*;
-
 import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
 
@@ -65,32 +62,80 @@ public class GridCacheQueryMetricsSelfTest extends GridCommonAbstractTest
{
 
         cfg.setDiscoverySpi(disco);
 
-        CacheConfiguration cacheCfg = defaultCacheConfiguration();
+        CacheConfiguration<String, Integer> cacheCfg1 = defaultCacheConfiguration();
+
+        cacheCfg1.setName("A");
+        cacheCfg1.setCacheMode(CACHE_MODE);
+        cacheCfg1.setWriteSynchronizationMode(FULL_SYNC);
+        cacheCfg1.setIndexedTypes(String.class, Integer.class);
+
+        CacheConfiguration<String, Integer> cacheCfg2 = defaultCacheConfiguration();
 
-        cacheCfg.setCacheMode(CACHE_MODE);
-        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
-        cacheCfg.setIndexedTypes(String.class, Integer.class);
+        cacheCfg2.setName("B");
+        cacheCfg2.setCacheMode(CACHE_MODE);
+        cacheCfg2.setWriteSynchronizationMode(FULL_SYNC);
+        cacheCfg2.setIndexedTypes(String.class, Integer.class);
 
-        cfg.setCacheConfiguration(cacheCfg);
+        cfg.setCacheConfiguration(cacheCfg1, cacheCfg2);
 
         return cfg;
     }
 
     /**
-     * JUnit.
+     * Test metrics for SQL queries.
      *
      * @throws Exception In case of error.
      */
-    public void testAccumulativeMetrics() throws Exception {
-        GridCacheAdapter<String, Integer> cache = ((IgniteKernal)grid(0)).internalCache();
+    public void testSqlFieldsQueryMetrics() throws Exception {
+        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
+
+        // Execute query.
+        SqlFieldsQuery qry = new SqlFieldsQuery("select * from Integer");
+
+        cache.query(qry).getAll();
+
+        QueryMetrics m = cache.queryMetrics();
+
+        assert m != null;
+
+        info("Metrics: " + m);
+
+        assertEquals(1, m.executions());
+        assertEquals(0, m.fails());
+        assertTrue(m.averageTime() >= 0);
+        assertTrue(m.maximumTime() >= 0);
+        assertTrue(m.minimumTime() >= 0);
+
+        // Execute again with the same parameters.
+        cache.query(qry).getAll();
+
+        m = cache.queryMetrics();
+
+        assert m != null;
 
-        CacheQuery<Map.Entry<String, Integer>> qry = cache.queries().createSqlQuery(Integer.class,
"_val >= 0")
-            .projection(grid(0).cluster());
+        info("Metrics: " + m);
+
+        assertEquals(2, m.executions());
+        assertEquals(0, m.fails());
+        assertTrue(m.averageTime() >= 0);
+        assertTrue(m.maximumTime() >= 0);
+        assertTrue(m.minimumTime() >= 0);
+    }
+
+    /**
+     * Test metrics for Scan queries.
+     *
+     * @throws Exception In case of error.
+     */
+    public void testScanQueryMetrics() throws Exception {
+        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
 
         // Execute query.
-        qry.execute().get();
+        ScanQuery<String, Integer> qry = new ScanQuery<>();
 
-        QueryMetrics m = cache.queries().metrics();
+        cache.query(qry).getAll();
+
+        QueryMetrics m = cache.queryMetrics();
 
         assert m != null;
 
@@ -103,9 +148,9 @@ public class GridCacheQueryMetricsSelfTest extends GridCommonAbstractTest
{
         assertTrue(m.minimumTime() >= 0);
 
         // Execute again with the same parameters.
-        qry.execute().get();
+        cache.query(qry).getAll();
 
-        m = cache.queries().metrics();
+        m = cache.queryMetrics();
 
         assert m != null;
 
@@ -119,20 +164,21 @@ public class GridCacheQueryMetricsSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
-     * JUnit.
+     * Test metrics for SQL cross cache queries.
      *
      * @throws Exception In case of error.
      */
-    public void testSingleQueryMetrics() throws Exception {
-        GridCacheAdapter<String, Integer> cache = ((IgniteKernal)grid(0)).internalCache();
+    public void testSqlCrossCacheQueryMetrics() throws Exception {
+        IgniteCache<String, Integer> cache = grid(0).context().cache().jcache("A");
+
+        // Execute query.
+        SqlFieldsQuery qry = new SqlFieldsQuery("select * from \"B\".Integer");
 
-        CacheQuery<Map.Entry<String, Integer>> qry = cache.queries().createSqlQuery(Integer.class,
"_val >= 0")
-            .projection(grid(0).cluster());
+        cache.query(qry).getAll();
 
-        // Execute.
-        qry.execute().get();
+        QueryMetrics m = cache.queryMetrics();
 
-        QueryMetrics m = qry.metrics();
+        assert m != null;
 
         info("Metrics: " + m);
 
@@ -142,10 +188,12 @@ public class GridCacheQueryMetricsSelfTest extends GridCommonAbstractTest
{
         assertTrue(m.maximumTime() >= 0);
         assertTrue(m.minimumTime() >= 0);
 
-        // Execute.
-        qry.execute().get();
+        // Execute again with the same parameters.
+        cache.query(qry).getAll();
 
-        m = qry.metrics();
+        m = cache.queryMetrics();
+
+        assert m != null;
 
         info("Metrics: " + m);
 


Mime
View raw message