ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject ignite git commit: Minor improvements
Date Mon, 05 Jun 2017 07:57:18 GMT
Repository: ignite
Updated Branches:
  refs/heads/master e273f2e55 -> 31ac7e9a0


Minor improvements


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

Branch: refs/heads/master
Commit: 31ac7e9a06457cb967e37bef11fe70d6e13fbf5d
Parents: e273f2e
Author: Pavel Kovalenko <jokserfn@gmail.com>
Authored: Mon Jun 5 10:48:46 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Mon Jun 5 10:56:31 2017 +0300

----------------------------------------------------------------------
 ...gniteCacheInvokeReadThroughAbstractTest.java | 92 ++++++++++----------
 .../testframework/junits/GridAbstractTest.java  | 24 +++++
 .../ignite/testframework/junits/IgniteMock.java | 11 +--
 .../junits/IgniteTestResources.java             | 52 +++++------
 .../cache/GridAbstractCacheStoreSelfTest.java   |  5 +-
 5 files changed, 102 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/31ac7e9a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
index 1caf157..963271f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughAbstractTest.java
@@ -90,6 +90,13 @@ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends
GridCommo
     }
 
     /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        ignite(0).destroyCache(DEFAULT_CACHE_NAME);
+    }
+
+    /** {@inheritDoc} */
     @Override protected void afterTestsStopped() throws Exception {
         stopAllGrids();
 
@@ -127,76 +134,71 @@ public abstract class IgniteCacheInvokeReadThroughAbstractTest extends
GridCommo
 
         ignite0.createCache(ccfg);
 
-        try {
-            int key = 0;
+        int key = 0;
 
-            for (Ignite node : G.allGrids()) {
-                if (node.configuration().isClientMode() && ccfg.getNearConfiguration()
!= null)
-                    node.createNearCache(ccfg.getName(), ccfg.getNearConfiguration());
-            }
+        for (Ignite node : G.allGrids()) {
+            if (node.configuration().isClientMode() && ccfg.getNearConfiguration()
!= null)
+                node.createNearCache(ccfg.getName(), ccfg.getNearConfiguration());
+        }
 
-            for (Ignite node : G.allGrids()) {
-                log.info("Test for node: " + node.name());
+        for (Ignite node : G.allGrids()) {
+            log.info("Test for node: " + node.name());
 
-                IgniteCache<Object, Object> cache = node.cache(ccfg.getName());
+            IgniteCache<Object, Object> cache = node.cache(ccfg.getName());
 
-                for (int i = 0; i < 50; i++)
-                    checkReadThrough(cache, key++, null, null);
+            for (int i = 0; i < 50; i++)
+                checkReadThrough(cache, key++, null, null);
 
-                Set<Object> keys = new HashSet<>();
+            Set<Object> keys = new HashSet<>();
 
-                for (int i = 0; i < 5; i++)
-                    keys.add(key++);
+            for (int i = 0; i < 5; i++)
+                keys.add(key++);
 
-                checkReadThroughInvokeAll(cache, keys, null, null);
+            checkReadThroughInvokeAll(cache, keys, null, null);
 
-                keys = new HashSet<>();
+            keys = new HashSet<>();
 
-                for (int i = 0; i < 100; i++)
-                    keys.add(key++);
+            for (int i = 0; i < 100; i++)
+                keys.add(key++);
 
-                checkReadThroughInvokeAll(cache, keys, null, null);
+            checkReadThroughInvokeAll(cache, keys, null, null);
 
-                if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
-                    for (TransactionConcurrency concurrency : TransactionConcurrency.values())
{
-                        for (TransactionIsolation isolation : TransactionIsolation.values())
{
-                            log.info("Test tx [concurrency=" + concurrency + ", isolation="
+ isolation + ']');
+            if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
+                for (TransactionConcurrency concurrency : TransactionConcurrency.values())
{
+                    for (TransactionIsolation isolation : TransactionIsolation.values())
{
+                        log.info("Test tx [concurrency=" + concurrency + ", isolation=" +
isolation + ']');
 
-                            for (int i = 0; i < 50; i++)
-                                checkReadThrough(cache, key++, concurrency, isolation);
+                        for (int i = 0; i < 50; i++)
+                            checkReadThrough(cache, key++, concurrency, isolation);
 
-                            keys = new HashSet<>();
+                        keys = new HashSet<>();
 
-                            for (int i = 0; i < 5; i++)
-                                keys.add(key++);
+                        for (int i = 0; i < 5; i++)
+                            keys.add(key++);
 
-                            checkReadThroughInvokeAll(cache, keys, concurrency, isolation);
+                        checkReadThroughInvokeAll(cache, keys, concurrency, isolation);
 
-                            keys = new HashSet<>();
+                        keys = new HashSet<>();
 
-                            for (int i = 0; i < 100; i++)
-                                keys.add(key++);
+                        for (int i = 0; i < 100; i++)
+                            keys.add(key++);
 
-                            checkReadThroughInvokeAll(cache, keys, concurrency, isolation);
-                        }
+                        checkReadThroughInvokeAll(cache, keys, concurrency, isolation);
                     }
+                }
 
-                    for (TransactionConcurrency concurrency : TransactionConcurrency.values())
{
-                        for (TransactionIsolation isolation : TransactionIsolation.values())
{
-                            log.info("Test tx2 [concurrency=" + concurrency + ", isolation="
+ isolation + ']');
+                for (TransactionConcurrency concurrency : TransactionConcurrency.values())
{
+                    for (TransactionIsolation isolation : TransactionIsolation.values())
{
+                        log.info("Test tx2 [concurrency=" + concurrency + ", isolation="
+ isolation + ']');
 
-                            for (int i = 0; i < 50; i++)
-                                checkReadThroughGetAndInvoke(cache, key++, concurrency, isolation);
-                        }
+                        for (int i = 0; i < 50; i++)
+                            checkReadThroughGetAndInvoke(cache, key++, concurrency, isolation);
                     }
                 }
             }
-
-            ignite0.cache(ccfg.getName()).removeAll();
-        }
-        finally {
-            ignite0.destroyCache(ccfg.getName());
         }
+
+        ignite0.cache(ccfg.getName()).removeAll();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/31ac7e9a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 29c6396..1f096e4 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -270,6 +270,13 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
+     * @return Test resources.
+     */
+    protected IgniteTestResources getTestResources(IgniteConfiguration cfg) throws IgniteCheckedException
{
+        return getTestCounters(cfg).getTestResources();
+    }
+
+    /**
      * @param msg Message to print.
      */
     protected void info(String msg) {
@@ -1867,6 +1874,15 @@ public abstract class GridAbstractTest extends TestCase {
         return tc;
     }
 
+    /**
+     * @param cfg Ignite configuration
+     * @return Test counters
+     * @throws IgniteCheckedException In case of error
+     */
+    protected synchronized TestCounters getTestCounters(IgniteConfiguration cfg) throws IgniteCheckedException
{
+        return new TestCounters(cfg);
+    }
+
     /** {@inheritDoc} */
     @SuppressWarnings({"ProhibitedExceptionDeclared"})
     @Override protected void runTest() throws Throwable {
@@ -2224,6 +2240,14 @@ public abstract class GridAbstractTest extends TestCase {
         }
 
         /**
+         * @param cfg Ignite configuration
+         * @throws IgniteCheckedException In case of error
+         */
+        public TestCounters(IgniteConfiguration cfg) throws IgniteCheckedException {
+            rsrcs = new IgniteTestResources(cfg);
+        }
+
+        /**
          * @return Reset flag.
          */
         public boolean isReset() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/31ac7e9a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index 1f95dd9..97157a8 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -26,22 +26,22 @@ import org.apache.ignite.IgniteAtomicLong;
 import org.apache.ignite.IgniteAtomicReference;
 import org.apache.ignite.IgniteAtomicSequence;
 import org.apache.ignite.IgniteAtomicStamped;
+import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteCluster;
 import org.apache.ignite.IgniteCompute;
 import org.apache.ignite.IgniteCountDownLatch;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLock;
-import org.apache.ignite.IgniteSemaphore;
 import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.IgniteEvents;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.IgniteLock;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.IgniteQueue;
 import org.apache.ignite.IgniteScheduler;
+import org.apache.ignite.IgniteSemaphore;
 import org.apache.ignite.IgniteServices;
 import org.apache.ignite.IgniteSet;
 import org.apache.ignite.IgniteTransactions;
@@ -109,13 +109,14 @@ public class IgniteMock implements Ignite {
      * @param home Ignite home.
      */
     public IgniteMock(
-        String name, String locHost, UUID nodeId, Marshaller marshaller, MBeanServer jmx,
String home) {
+        String name, String locHost, UUID nodeId, Marshaller marshaller, MBeanServer jmx,
String home, IgniteConfiguration staticCfg) {
         this.locHost = locHost;
         this.nodeId = nodeId;
         this.marshaller = marshaller;
         this.jmx = jmx;
         this.home = home;
         this.name = name;
+        this.staticCfg = staticCfg;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/31ac7e9a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
index 2222274..5fef8bc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteTestResources.java
@@ -58,21 +58,24 @@ public class IgniteTestResources {
     private final IgniteLogger log;
 
     /** Local host. */
-    private final String locHost;
+    private final String locHost = localHost();
 
     /** */
-    private final UUID nodeId;
+    private final UUID nodeId = UUID.randomUUID();
 
     /** */
     private final MBeanServer jmx;
 
     /** */
-    private final String home;
+    private final String home = U.getIgniteHome();
 
     /** */
     private ThreadPoolExecutor execSvc;
 
     /** */
+    private IgniteConfiguration cfg;
+
+    /** */
     private GridResourceProcessor rsrcProc;
 
     /**
@@ -84,14 +87,18 @@ public class IgniteTestResources {
         else
             log = rootLog.getLogger(getClass());
 
-        nodeId = UUID.randomUUID();
-        jmx = ManagementFactory.getPlatformMBeanServer();
-        home = U.getIgniteHome();
-        locHost = localHost();
-
-        GridTestKernalContext ctx = new GridTestKernalContext(log);
+        this.jmx = ManagementFactory.getPlatformMBeanServer();
+        this.rsrcProc = new GridResourceProcessor(new GridTestKernalContext(this.log));
+    }
 
-        rsrcProc = new GridResourceProcessor(ctx);
+    /**
+     * @param cfg Ignite configuration
+     */
+    public IgniteTestResources(IgniteConfiguration cfg) throws IgniteCheckedException {
+        this.cfg = cfg;
+        this.log = rootLog.getLogger(getClass());
+        this.jmx = ManagementFactory.getPlatformMBeanServer();
+        this.rsrcProc = new GridResourceProcessor(new GridTestKernalContext(this.log, this.cfg));
     }
 
     /**
@@ -101,16 +108,8 @@ public class IgniteTestResources {
         assert jmx != null;
 
         this.jmx = jmx;
-
-        log = rootLog.getLogger(getClass());
-
-        nodeId = UUID.randomUUID();
-        home = U.getIgniteHome();
-        locHost = localHost();
-
-        GridTestKernalContext ctx = new GridTestKernalContext(log);
-
-        rsrcProc = new GridResourceProcessor(ctx);
+        this.log = rootLog.getLogger(getClass());
+        this.rsrcProc = new GridResourceProcessor(new GridTestKernalContext(this.log));
     }
 
     /**
@@ -120,15 +119,8 @@ public class IgniteTestResources {
         assert log != null;
 
         this.log = log.getLogger(getClass());
-
-        nodeId = UUID.randomUUID();
-        jmx = ManagementFactory.getPlatformMBeanServer();
-        home = U.getIgniteHome();
-        locHost = localHost();
-
-        GridTestKernalContext ctx = new GridTestKernalContext(log);
-
-        rsrcProc = new GridResourceProcessor(ctx);
+        this.jmx = ManagementFactory.getPlatformMBeanServer();
+        this.rsrcProc = new GridResourceProcessor(new GridTestKernalContext(this.log));
     }
 
     /**
@@ -185,7 +177,7 @@ public class IgniteTestResources {
 
         rsrcProc.injectBasicResource(target, LoggerResource.class, getLogger().getLogger(target.getClass()));
         rsrcProc.injectBasicResource(target, IgniteInstanceResource.class,
-            new IgniteMock(null, locHost, nodeId, getMarshaller(), jmx, home));
+            new IgniteMock(null, locHost, nodeId, getMarshaller(), jmx, home, cfg));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/31ac7e9a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
index 8aba684..c5673b3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
@@ -466,9 +466,10 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends CacheStore<Object
     }
 
     /**
-     * @return Store.
+     * @return Store
+     * @throws Exception In case of error
      */
-    protected abstract T store();
+    protected abstract T store() throws Exception;
 
     /**
      * Dummy transaction for test purposes.


Mime
View raw message